From 07aa38ee3e6f30a6ea554ff7568ec84246093580 Mon Sep 17 00:00:00 2001 From: Shadrak Gurupnor <30501401+shadrak98@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:49:52 +0530 Subject: [PATCH 01/11] fix(usage-record): Creation of duplicate usage record Invoice is not set until document is submitted and hence while validating duplicate usage record creation it fails --- press/press/doctype/usage_record/usage_record.py | 1 - 1 file changed, 1 deletion(-) diff --git a/press/press/doctype/usage_record/usage_record.py b/press/press/doctype/usage_record/usage_record.py index 128cfedee2..10aedfc8d1 100644 --- a/press/press/doctype/usage_record/usage_record.py +++ b/press/press/doctype/usage_record/usage_record.py @@ -87,7 +87,6 @@ def validate_duplicate_usage_record(self): "plan": self.plan, "docstatus": 1, "subscription": self.subscription, - "invoice": self.invoice, }, pluck="name", ) From f523912c9d83109cca915a494210b7188e9f9f0d Mon Sep 17 00:00:00 2001 From: Shadrak Gurupnor Date: Tue, 7 Jan 2025 18:03:36 +0530 Subject: [PATCH 02/11] feat(billing-audit): Duplicate usage record creation audit --- press/hooks.py | 2 +- press/press/audit.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/press/hooks.py b/press/hooks.py index af6b0eabc5..859f8b9b7c 100644 --- a/press/hooks.py +++ b/press/hooks.py @@ -291,7 +291,7 @@ "0 8 * * *": [ "press.press.doctype.aws_savings_plan_recommendation.aws_savings_plan_recommendation.create", ], - "0 18 * * *": [ + "0 21 * * *": [ "press.press.audit.billing_audit", "press.press.audit.partner_billing_audit", ], diff --git a/press/press/audit.py b/press/press/audit.py index 39b64e8637..9472aa3a87 100644 --- a/press/press/audit.py +++ b/press/press/audit.py @@ -339,6 +339,7 @@ def __init__(self): "Sites active after trial": self.free_sites_after_trial, "Teams with active sites and unpaid Invoices": self.teams_with_active_sites_and_unpaid_invoices, "Prepaid Unpaid Invoices with Stripe Invoice ID set": self.prepaid_unpaid_invoices_with_stripe_invoice_id_set, + "Subscriptions with duplicate usage records created": self.subscriptions_with_duplicate_usage_records, } log = {a: [] for a in audits} @@ -366,6 +367,29 @@ def subscriptions_without_usage_record(self): pluck="name", ) + def subscriptions_with_duplicate_usage_records(self): + data = frappe.db.sql( + """ + SELECT subscription, Count(name) as count + FROM `tabUsage Record` as UR + WHERE UR.date = CURDATE() + AND UR.docstatus = 1 + AND UR.plan NOT LIKE '%Marketplace%' + GROUP BY UR.document_name, UR.plan, UR.team + HAVING count > 1 + ORDER BY count DESC + """, + as_dict=True, + ) + + if not data: + return data + + result = [] + for d in data: + result.append(d.subscription) + return result + def disabled_teams_with_active_sites(self): return frappe.get_all( "Team", From 27fa563664b357c96042aab49715840b1c44ca90 Mon Sep 17 00:00:00 2001 From: tanmoysrt <57363826+tanmoysrt@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:32:54 +0530 Subject: [PATCH 03/11] refactor(sql-editor): Load the table schema in background --- .../devtools/database/SQLCodeEditor.vue | 43 +++++++++++++------ .../database/DatabaseSQLPlayground.vue | 37 ++++++++-------- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/dashboard/src2/components/devtools/database/SQLCodeEditor.vue b/dashboard/src2/components/devtools/database/SQLCodeEditor.vue index 0cedef2d59..70b18e0782 100644 --- a/dashboard/src2/components/devtools/database/SQLCodeEditor.vue +++ b/dashboard/src2/components/devtools/database/SQLCodeEditor.vue @@ -31,22 +31,38 @@ export default { set(value) { this.$emit('update:query', value); } + }, + extensions() { + if (!this.schema) { + return [ + sql({ + dialect: MySQL, + upperCaseKeywords: true + }), + autocompletion({ + activateOnTyping: true, + closeOnBlur: false, + maxRenderedOptions: 10, + icons: false + }) + ]; + } + return [ + sql({ + dialect: MySQL, + upperCaseKeywords: true, + schema: this.schema + }), + autocompletion({ + activateOnTyping: true, + closeOnBlur: false, + maxRenderedOptions: 10, + icons: false + }) + ]; } }, setup(props, { emit }) { - const extensions = [ - sql({ - dialect: MySQL, - upperCaseKeywords: true, - schema: props.schema - }), - autocompletion({ - activateOnTyping: true, - closeOnBlur: false, - maxRenderedOptions: 10, - icons: false - }) - ]; // Codemirror EditorView instance ref const view = shallowRef(); const handleReady = payload => { @@ -72,7 +88,6 @@ export default { } }; return { - extensions, handleReady }; } diff --git a/dashboard/src2/pages/devtools/database/DatabaseSQLPlayground.vue b/dashboard/src2/pages/devtools/database/DatabaseSQLPlayground.vue index db6dd68da2..923c34876d 100644 --- a/dashboard/src2/pages/devtools/database/DatabaseSQLPlayground.vue +++ b/dashboard/src2/pages/devtools/database/DatabaseSQLPlayground.vue @@ -38,9 +38,9 @@ v-model="site" /> @@ -120,18 +128,7 @@ -
- Select a site to get started -
-
- Setting Up SQL Playground -
+ Date: Wed, 8 Jan 2025 14:48:15 +0530 Subject: [PATCH 04/11] refactor(sql-editor): Hide 'Run Selected Query' btn if query is blank --- dashboard/src2/components/devtools/database/SQLCodeEditor.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dashboard/src2/components/devtools/database/SQLCodeEditor.vue b/dashboard/src2/components/devtools/database/SQLCodeEditor.vue index 70b18e0782..931e0d1f23 100644 --- a/dashboard/src2/components/devtools/database/SQLCodeEditor.vue +++ b/dashboard/src2/components/devtools/database/SQLCodeEditor.vue @@ -82,6 +82,10 @@ export default { selection.from, selection.to ); + if ((selectedText ?? '').trim() === '') { + emit('codeUnselected'); + return; + } emit('codeSelected', selectedText); } else { emit('codeUnselected'); From 19e035740def23569f24af13df365e61cda64b34 Mon Sep 17 00:00:00 2001 From: tanmoysrt <57363826+tanmoysrt@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:19:49 +0530 Subject: [PATCH 05/11] chore(db-analyzer): Reduce margin between sections --- dashboard/src2/pages/devtools/database/DatabaseAnalyzer.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src2/pages/devtools/database/DatabaseAnalyzer.vue b/dashboard/src2/pages/devtools/database/DatabaseAnalyzer.vue index 56d45ead59..0b56b084dd 100644 --- a/dashboard/src2/pages/devtools/database/DatabaseAnalyzer.vue +++ b/dashboard/src2/pages/devtools/database/DatabaseAnalyzer.vue @@ -162,7 +162,7 @@ From da7e4fdacda2af2344618105802c9260643eec0f Mon Sep 17 00:00:00 2001 From: Shadrak Gurupnor <30501401+shadrak98@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:49:41 +0530 Subject: [PATCH 06/11] fix(usage-record): Round the add-on storage daily amount * This fixes the storage add-on line items being added on separate line every day --- press/press/doctype/subscription/subscription.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/press/press/doctype/subscription/subscription.py b/press/press/doctype/subscription/subscription.py index fd707a178b..d474e27c6d 100644 --- a/press/press/doctype/subscription/subscription.py +++ b/press/press/doctype/subscription/subscription.py @@ -7,7 +7,7 @@ import rq from frappe.model.document import Document from frappe.query_builder.functions import Coalesce, Count -from frappe.utils import cint +from frappe.utils import cint, flt from press.overrides import get_permission_query_conditions_for_doctype from press.press.doctype.site_plan.site_plan import SitePlan @@ -152,7 +152,7 @@ def create_usage_record(self, date: DF.Date | None = None): if self.additional_storage: price = plan.price_inr if team.currency == "INR" else plan.price_usd price_per_day = price / plan.period # no rounding off to avoid discrepancies - amount = price_per_day * cint(self.additional_storage) + amount = flt((price_per_day * cint(self.additional_storage)), 2) else: amount = plan.get_price_for_interval(self.interval, team.currency) From 03f69084a457aae355aa19f0acfa80a2a3cef230 Mon Sep 17 00:00:00 2001 From: Bread Genie Date: Thu, 9 Jan 2025 12:05:42 +0530 Subject: [PATCH 07/11] fix(server-charts): show idle at the top of cpu chart --- dashboard/src2/components/server/ServerCharts.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dashboard/src2/components/server/ServerCharts.vue b/dashboard/src2/components/server/ServerCharts.vue index 68a1d1e766..33566975ea 100644 --- a/dashboard/src2/components/server/ServerCharts.vue +++ b/dashboard/src2/components/server/ServerCharts.vue @@ -42,14 +42,14 @@ :data="cpuData" unit="%" :chartTheme="[ - $theme.colors.green[500], // idle $theme.colors.red[500], // iowait $theme.colors.yellow[500], // irq $theme.colors.pink[500], // nice $theme.colors.purple[500], // softirq $theme.colors.blue[500], // steal $theme.colors.teal[500], // system - $theme.colors.cyan[500] // user + $theme.colors.cyan[500], // user + $theme.colors.green[500] // idle ]" :loading="$resources.cpu.loading" :error="$resources.cpu.error" @@ -708,6 +708,13 @@ export default { let cpu = this.$resources.cpu.data; if (!cpu) return; + // move idle to the end + cpu.datasets = cpu.datasets.sort((a, b) => { + if (a.name === 'idle') return 1; + if (b.name === 'idle') return -1; + return 0; + }); + return this.transformMultiLineChartData(cpu, 'cpu', true); }, memoryData() { From b015de5787ab31170e471bde38f0a4b614b8611b Mon Sep 17 00:00:00 2001 From: Bread Genie Date: Thu, 9 Jan 2025 13:03:09 +0530 Subject: [PATCH 08/11] fix(line-chart): add more space to y axis --- dashboard/src/components/charts/LineChart.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/components/charts/LineChart.vue b/dashboard/src/components/charts/LineChart.vue index a7970f567a..1450cee87b 100644 --- a/dashboard/src/components/charts/LineChart.vue +++ b/dashboard/src/components/charts/LineChart.vue @@ -121,7 +121,7 @@ const initOptions = { const options = ref({ grid: { top: 20, - left: 40, + left: 50, right: 20, bottom: data.value.datasets.length > 1 ? 60 : 30 // if there's legend show more space for it }, From 56e4293c5aab02120bd1d0c28a211b3ac647d46d Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 9 Jan 2025 14:15:15 +0530 Subject: [PATCH 09/11] fix: perms for lock report --- press/press/report/mariadb_locks_list/mariadb_locks_list.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/press/press/report/mariadb_locks_list/mariadb_locks_list.py b/press/press/report/mariadb_locks_list/mariadb_locks_list.py index 36f142ce92..5f804d0926 100644 --- a/press/press/report/mariadb_locks_list/mariadb_locks_list.py +++ b/press/press/report/mariadb_locks_list/mariadb_locks_list.py @@ -7,7 +7,7 @@ def execute(filters=None): - frappe.only_for("System Manager") + frappe.only_for(("System Manager", "Support Team")) data = get_data(filters) return get_columns(), data @@ -20,8 +20,7 @@ def get_data(filters): "private_ip": server.private_ip, "mariadb_root_password": server.get_password("mariadb_root_password"), } - rows = agent.post("database/locks", data=data) - return rows + return agent.post("database/locks", data=data) def get_columns(): From ea89088c136df3ca29f26d58cb31fe91ba90b730 Mon Sep 17 00:00:00 2001 From: Bread Genie Date: Thu, 9 Jan 2025 14:38:05 +0530 Subject: [PATCH 10/11] fix: show warning for sites and groups on EOL versions fix #2129 --- dashboard/src2/components/SiteOverview.vue | 16 +++++++++++++++- dashboard/src2/pages/ReleaseGroupBenchSites.vue | 17 ++++++++++++++++- .../doctype/release_group/release_group.py | 7 +++++++ press/press/doctype/site/site.py | 7 +++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/dashboard/src2/components/SiteOverview.vue b/dashboard/src2/components/SiteOverview.vue index 3d511ee84a..3ce10d52fa 100644 --- a/dashboard/src2/components/SiteOverview.vue +++ b/dashboard/src2/components/SiteOverview.vue @@ -19,7 +19,21 @@ + + + + + Date: Thu, 9 Jan 2025 14:49:49 +0530 Subject: [PATCH 11/11] fix(site): show warning on nightly version selector fix #2350 --- dashboard/src2/pages/NewSite.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dashboard/src2/pages/NewSite.vue b/dashboard/src2/pages/NewSite.vue index 8833275ab1..e8df774fb8 100644 --- a/dashboard/src2/pages/NewSite.vue +++ b/dashboard/src2/pages/NewSite.vue @@ -87,9 +87,19 @@ " > {{ v.name }} - - {{ v.status }} - +
+ + + + + {{ v.status }} + +
@@ -266,6 +276,7 @@ import NewSiteAppSelector from '../components/site/NewSiteAppSelector.vue'; import Summary from '../components/Summary.vue'; import { DashboardError } from '../utils/error'; import { getCountry } from '../utils/country'; +import AlertBanner from '../components/AlertBanner.vue'; export default { name: 'NewSite', @@ -276,6 +287,7 @@ export default { SitePlansCards, Autocomplete, ErrorMessage, + AlertBanner, FormControl, FeatherIcon, TextInput,