From 1f7ea5c3b1f510b417b516017484c5042c24c414 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jun 2026 11:41:59 +0300 Subject: [PATCH] 051 cloud_capacity division by zero --- Application.cfc | 2 +- cloud_capacity.cfm | 20 ++++++++++---------- contragent.cfm | 2 +- contragent_rpt.cfm | 12 +++++++----- crm2cloud.cfm | 2 ++ etc/db/billing-indexes.sql | 8 ++++++++ payg.cfm | 23 +++++++++++++++++++++++ 7 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 etc/db/billing-indexes.sql diff --git a/Application.cfc b/Application.cfc index 2770945..089e265 100644 --- a/Application.cfc +++ b/Application.cfc @@ -76,7 +76,7 @@ - + diff --git a/cloud_capacity.cfm b/cloud_capacity.cfm index 754c635..d7756cc 100644 --- a/cloud_capacity.cfm +++ b/cloud_capacity.cfm @@ -270,9 +270,9 @@ from qRead err" style="font-size:130%">#safeNumberFormat(gb_provisioned - vm_ram_used,"0")# err" style="font-size:130%">#safeNumberFormat(ghz_provisioned-vm_ghz_reserved,".0")# - err" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.2,"0")# - err" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.5,"0")# - err" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.8,"0")# + err" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.2,"0")# + err" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.5,"0")# + err" style="font-size:130%">#safeNumberFormat((ghz_provisioned-vm_ghz_reserved)/ghz/0.8,"0")# - #numberFormat(vm_cores/cores_in_service,".0")# + #numberFormat(vm_cores/cores_in_service,".0")# #numberFormat(ghz_provisioned,".0")# #numberFormat(vm_ghz_reserved,".0")# @@ -391,15 +391,15 @@ from qRead #numberFormat(gb_provisioned,"0")# #numberFormat(vm_ram_alloc,"0")# #numberFormat(vm_ram_used,"0")# - #numberFormat(vm_ram_alloc/ram_in_service*100,"0")# - #numberFormat(vm_ram_used/ram_in_service*100,"0")# + #numberFormat(vm_ram_alloc/ram_in_service*100,"0")# + #numberFormat(vm_ram_used/ram_in_service*100,"0")# #vms# - #numberFormat(vm_cores/vms,".0")# core - #numberFormat(vm_ghz_usage/vms,".0")# GHz - #numberFormat(vm_ghz_usage/vm_cores/ghz*100,"0")#% - #numberFormat(vm_ram_alloc/vms,".0")#(#numberFormat(vm_ram_used/vms,".0")#) GB + #numberFormat(vm_cores/vms,".0")# core + #numberFormat(vm_ghz_usage/vms,".0")# GHz + #numberFormat(vm_ghz_usage/vm_cores/ghz*100,"0")#% + #numberFormat(vm_ram_alloc/vms,".0")#(#numberFormat(vm_ram_used/vms,".0")#) GB diff --git a/contragent.cfm b/contragent.cfm index a019e2e..dc91347 100644 --- a/contragent.cfm +++ b/contragent.cfm @@ -85,7 +85,7 @@
__name
-
#d.__name#
+
diff --git a/contragent_rpt.cfm b/contragent_rpt.cfm index 30b4788..2258513 100644 --- a/contragent_rpt.cfm +++ b/contragent_rpt.cfm @@ -112,8 +112,9 @@ - with - status(status, status_id, probability_pc) as (VALUES + WITH + status(status, status_id, probability_pc) + AS (VALUES ('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70), ('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0) ) @@ -154,11 +155,11 @@ AND d."__deletedAt" IS NULL AND a."__deletedAt" IS NULL AND s.probability_pc >= 50 - --and a.is_actual *** возможно схема версионности противоречива + --and a.is_actual *** возможно, схема версионности противоречива AND siv.type IN (2, 3) AND d._companies = ) - ,component + ,component AS ( SELECT cnt ,code @@ -170,7 +171,7 @@ FROM elma.service_parametrs WHERE "__deletedAt" IS NULL ) - ,stair + ,stair AS ( SELECT * FROM ( @@ -192,6 +193,7 @@ WHERE t.dt_from = t.running_min_dt --AND ( t.dt_to > CURRENT_TIMESTAMP OR t.dt_to IS NULL ) ) + SELECT d.siv_uid::text as siv_uid ,d.siv_index ,d.deal diff --git a/crm2cloud.cfm b/crm2cloud.cfm index 125575b..1def5d3 100644 --- a/crm2cloud.cfm +++ b/crm2cloud.cfm @@ -7,6 +7,8 @@ + + diff --git a/etc/db/billing-indexes.sql b/etc/db/billing-indexes.sql new file mode 100644 index 0000000..fdf0407 --- /dev/null +++ b/etc/db/billing-indexes.sql @@ -0,0 +1,8 @@ +CREATE INDEX ON ngcloud_ru.capacity_resource (timestamp); +CREATE INDEX ON ngcloud_ru.capacity_storage (timestamp); + +CREATE INDEX ON s3billing.bucket_stat (timestamp_addition); +CREATE INDEX ON s3billing.usage_bucket_by_user (time); + +CREATE INDEX ON gpu.vm (dt_load); +CREATE INDEX ON gpu.vm_power_state (ts); diff --git a/payg.cfm b/payg.cfm index 8d7039d..9d3aeda 100644 --- a/payg.cfm +++ b/payg.cfm @@ -29,6 +29,9 @@ where p.type=3 AND aa.is_actual order by p.code + + #getTickCount()-request.startTickCount# + select k.id_klienta as wz, k.__id::text as contragent_uid, k.__name as contragent @@ -36,6 +39,7 @@ where k."__deletedAt" IS NULL + #getTickCount()-request.startTickCount# select k.id_klienta as wz, k.__id::text as contragent_uid, p.code, p.price, p.discount, k.__name as contragent, a.__name as contract, a.__id::text as contract_uid, d.__name as deal, d.__id::text as deal_uid, siv.abstractive_service as abstract_service, siv.modifier, siv.user_description, siv.hash as line_key @@ -53,10 +57,16 @@ AND (siv.date_end > OR siv.date_end IS NULL) order by k.id_klienta, p.code + + #getTickCount()-request.startTickCount# + select max(dt_load) as dt_load from elma.deals_services + + #getTickCount()-request.startTickCount# + @@ -90,6 +100,8 @@ order by m.clientid, vdc.name; + #getTickCount()-request.startTickCount# + @@ -99,6 +111,8 @@ select max(capacity_resource.timestamp) as dt_load from ngcloud_ru.capacity_resource + #getTickCount()-request.startTickCount# + @@ -134,6 +148,9 @@ group by m.clientid, vdc.name, storage_profile_types.name order by m.clientid, vdc.name, storage_profile_types.name; + + #getTickCount()-request.startTickCount# + select max(capacity_storage.timestamp) as dt_load from ngcloud_ru.capacity_storage @@ -143,6 +160,8 @@ + #getTickCount()-request.startTickCount# +