From 7b9e811ccedba177f397302fb7f0d03eb5506ed8 Mon Sep 17 00:00:00 2001 From: msyu Date: Wed, 30 Apr 2025 12:27:10 +0300 Subject: [PATCH] 102 cleaning --- v1/Application.cfc | 2 +- v1/resources/bookmark.cfc | 8 +- v1/resources/bookmark_ls.cfc | 9 +- v1/resources/instance.cfc | 4 +- v1/resources/instance_default.cfc | 9 +- v1/resources/instance_ls.cfc | 103 +++++------------- v1/resources/instance_operation.cfc | 2 +- v1/resources/instance_operation_cfs_param.cfc | 8 +- .../instance_operation_cfs_param_ls.cfc | 17 +-- v1/resources/instance_operation_default.cfc | 2 +- 10 files changed, 51 insertions(+), 113 deletions(-) diff --git a/v1/Application.cfc b/v1/Application.cfc index 24ce8b7..3bcffe4 100644 --- a/v1/Application.cfc +++ b/v1/Application.cfc @@ -51,7 +51,7 @@ //variables.framework.docs={}; variables.framework.docs.APIName="Deck API"; - variables.framework.docs.APIVersion="0.101"; + variables.framework.docs.APIVersion="0.102"; variables.framework.globalHeaders = structNew(); variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location"; diff --git a/v1/resources/bookmark.cfc b/v1/resources/bookmark.cfc index 25cc75b..df469ea 100644 --- a/v1/resources/bookmark.cfc +++ b/v1/resources/bookmark.cfc @@ -2,12 +2,8 @@ - - - - - - + + diff --git a/v1/resources/bookmark_ls.cfc b/v1/resources/bookmark_ls.cfc index 8f5f8d4..856b627 100644 --- a/v1/resources/bookmark_ls.cfc +++ b/v1/resources/bookmark_ls.cfc @@ -115,16 +115,12 @@ - - - - @@ -140,7 +136,6 @@ - insert into bookmark ( bookmark_uid,contragent_id, bookmark,url,icon_url,descr,sort,is_enabled,dt_created,creator_id @@ -157,9 +152,7 @@ , ); - + diff --git a/v1/resources/instance.cfc b/v1/resources/instance.cfc index 29f13df..eb32312 100644 --- a/v1/resources/instance.cfc +++ b/v1/resources/instance.cfc @@ -47,9 +47,9 @@ when (select st.instance_data->>'isDeleted' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'true' then 'deleted' when - (select st.instance_data->>'suspended' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'true' then 'suspended' + (select st.instance_data->>'isSuspended' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'true' then 'suspended' when - (select coalesce(st.instance_data->>'isDeleted','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' AND (select coalesce(st.instance_data->>'suspended','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' then 'running' + (select coalesce(st.instance_data->>'isDeleted','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' AND (select coalesce(st.instance_data->>'isSuspended','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' then 'running' when not exists (select * from instance_operation o where o.instance_uid=e.instance_uid) then 'not configured' when diff --git a/v1/resources/instance_default.cfc b/v1/resources/instance_default.cfc index 039ce05..58e7afd 100644 --- a/v1/resources/instance_default.cfc +++ b/v1/resources/instance_default.cfc @@ -37,14 +37,7 @@ - - - - - + diff --git a/v1/resources/instance_ls.cfc b/v1/resources/instance_ls.cfc index 56eb242..065842c 100644 --- a/v1/resources/instance_ls.cfc +++ b/v1/resources/instance_ls.cfc @@ -120,24 +120,10 @@ - - - - - - - - - - + + - - - + @@ -151,8 +137,6 @@ e.instance_uid::text as instance_uid e.display_name e.service_id - - e.specification_item_id e.is_auxiliary d.contract_id @@ -176,14 +160,22 @@ (select to_char(io.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') from instance_operation io where io.instance_uid=e.instance_uid order by dt_submit desc limit 1) as operation_dt_finish (select round(extract('epoch' from coalesce(io.dt_finish,CURRENT_TIMESTAMP)- io.dt_start),1) from instance_operation io where io.instance_uid=e.instance_uid order by dt_submit desc limit 1) as duration - (select case when io.operation IN ('delete', 'suspend') AND io.is_successful then 0 /*null*/ when io.is_successful then extract('epoch' from CURRENT_TIMESTAMP - coalesce(io.dt_finish,CURRENT_TIMESTAMP)) else 0 end from instance_operation io where io.instance_uid=e.instance_uid order by dt_submit desc limit 1) as uptime/* *** это вообще неправильно, некоторые операции заканчиваются состоянием running, а некоторые нет, переделать */ + (select case + when io.operation IN ('delete', 'suspend') AND io.is_successful then 0 /*null*/ + when io.is_successful then extract('epoch' from CURRENT_TIMESTAMP - coalesce(io.dt_finish,CURRENT_TIMESTAMP)) + else 0 end + from instance_operation io + where io.instance_uid=e.instance_uid + order by dt_submit desc + limit 1) + as uptime (select to_char(io.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') from instance_operation io where io.instance_uid=e.instance_uid AND io.is_successful AND io.operation='create' order by dt_submit desc limit 1) as dt_deploy (select instance_data::text from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as instance_data (select st.instance_state_uid::text from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as instance_state_uid (select st.is_test from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as is_test coalesce((select st.instance_data->>'isDeleted' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1),'false') as is_deleted - (select st.instance_data->>'suspended' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as suspended + (select st.instance_data->>'isSuspended' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as suspended (select cast(st.instance_data->>'params' as json)->>'resourceRealm' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as resource_realm (select to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) as dt_state @@ -191,9 +183,12 @@ when (select st.instance_data->>'isDeleted' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'true' then 'deleted' when - (select st.instance_data->>'suspended' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'true' then 'suspended' + (select st.instance_data->>'isSuspended' from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'true' then 'suspended' when - (select coalesce(st.instance_data->>'isDeleted','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' AND (select coalesce(st.instance_data->>'suspended','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' then 'running' + (select coalesce(st.instance_data->>'isDeleted','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' + AND + (select coalesce(st.instance_data->>'isSuspended','false') from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) = 'false' + then 'running' when not exists (select * from instance_operation o where o.instance_uid=e.instance_uid) then 'not configured' when @@ -204,7 +199,7 @@ (select max(version) from instance_state st where st.instance_uid=e.instance_uid) as version - + select count(*) as cnt @@ -233,8 +228,6 @@ ) inr where 1=1 - @@ -266,8 +259,6 @@ limit #arguments.pageSize# offset #arguments.pageSize*(arguments.page-1)# - - select count(*) as cnt @@ -308,7 +299,7 @@ - + @@ -316,19 +307,14 @@ - - - - - - - - + + + @@ -377,11 +363,8 @@ - - - - + /> + @@ -459,35 +442,3 @@ - \ No newline at end of file diff --git a/v1/resources/instance_operation.cfc b/v1/resources/instance_operation.cfc index 695f0df..a48d1a5 100644 --- a/v1/resources/instance_operation.cfc +++ b/v1/resources/instance_operation.cfc @@ -194,7 +194,7 @@ AND a.is_enabled) join svc s on r.resource_realm_type_id=s.resource_realm_type_id where s.svc_id= - order by r.sort + order by r.sort, r.resource_realm diff --git a/v1/resources/instance_operation_cfs_param.cfc b/v1/resources/instance_operation_cfs_param.cfc index 172f3fa..5437fe6 100644 --- a/v1/resources/instance_operation_cfs_param.cfc +++ b/v1/resources/instance_operation_cfs_param.cfc @@ -59,7 +59,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -124,7 +124,9 @@ - + + + diff --git a/v1/resources/instance_operation_cfs_param_ls.cfc b/v1/resources/instance_operation_cfs_param_ls.cfc index cea548e..27b3b47 100644 --- a/v1/resources/instance_operation_cfs_param_ls.cfc +++ b/v1/resources/instance_operation_cfs_param_ls.cfc @@ -13,7 +13,11 @@ - - + @@ -185,7 +188,9 @@ .withHeaders({location: "./#local.instanceOperationCfsParamUid#"}) .withStatus(201, "Created") /> - + + + @@ -241,15 +246,13 @@ - - + )/> diff --git a/v1/resources/instance_operation_default.cfc b/v1/resources/instance_operation_default.cfc index 4817f75..681b87a 100644 --- a/v1/resources/instance_operation_default.cfc +++ b/v1/resources/instance_operation_default.cfc @@ -187,7 +187,7 @@ AND a.is_enabled) join svc s on r.resource_realm_type_id=s.resource_realm_type_id where s.svc_id= - order by r.sort + order by r.sort, r.resource_realm