Skip to content

Commit dc5b1d6

Browse files
authored
feat: cleanup (#1911)
1 parent 14cb3f9 commit dc5b1d6

File tree

5 files changed

+163
-2
lines changed

5 files changed

+163
-2
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ docs
44
LICENSE
55
README.md
66
renovate.json
7+
**/Thumbs.db
8+
**/.DS_Store
79
**/staticroot
810
**/__pycache__
911
**/.pytest_cache

.github/workflows/sonarqube.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- '.github/workflows/sonarqube.yaml'
99
- 'CodeListLibrary_project/**'
1010
- 'docker/**'
11-
- 'docs/**'
1211
push:
1312
branches:
1413
# We're using the free version of Sonarqube so we can only scan a single branch and not PRs

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ CodeListLibrary_project/staticroot/*
5151

5252
# Platform / OS files
5353
.idea
54-
.DS_Stores
54+
**/Thumbs.db
55+
**/.DS_Store
5556

5657
# Misc. files
5758
docs/~$plication Guide.docx

CodeListLibrary_project/cll/static/js/clinicalcode/services/organisationService/view.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ const initMetrics = (accordion, mapping) => {
451451
}
452452

453453
if (isNullOrUndefined(dataset.promise) || isResolved(dataset.promise)) {
454+
const spinner = startLoadingSpinner(container, true);
455+
dataset?.spinner?.remove?.();
456+
457+
dataset.spinner = spinner;
454458
dataset.promise = fetch(
455459
getCurrentURL(),
456460
{
@@ -481,6 +485,12 @@ const initMetrics = (accordion, mapping) => {
481485
.catch((e) => {
482486
console.error(`Failed to resolve metrics w/ err:\n${e}`);
483487
})
488+
.finally(() => {
489+
spinner?.remove?.();
490+
if (dataset.spinner === spinner) {
491+
dataset.spinner = null;
492+
}
493+
})
484494
}
485495
})
486496
};

docs/dev.cleanup.sql

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
-- vacuum (analyze, verbose);
2+
3+
-- do $$declare r record;
4+
-- begin
5+
-- for r in (
6+
-- select table_name
7+
-- from information_schema.tables
8+
-- where table_name ~ '^(django_|auth_|easyaudit_|clinicalcode_).*$'
9+
-- )
10+
-- loop
11+
-- execute format('reindex table %s.%s;', quote_ident('public'), quote_ident(r.table_name));
12+
-- end loop;
13+
-- end$$;
14+
15+
-- vacuum (full, analyze, verbose);
16+
17+
select
18+
table_name as name,
19+
pg_size_pretty(pg_total_relation_size(quote_ident(table_name))) as total_size,
20+
pg_size_pretty(pg_relation_size(quote_ident(table_name))) as table_size,
21+
pg_size_pretty(pg_indexes_size(quote_ident(table_name))) as index_size
22+
from information_schema.tables
23+
where table_schema = 'public'
24+
order by pg_total_relation_size(quote_ident(table_name)) desc;
25+
26+
-- truncate table public.django_session;
27+
28+
-- truncate
29+
-- table public.django_admin_log
30+
-- restart identity;
31+
32+
-- truncate
33+
-- table public.easyaudit_crudevent
34+
-- restart identity;
35+
36+
-- truncate
37+
-- table public.easyaudit_loginevent
38+
-- restart identity;
39+
40+
-- truncate
41+
-- table public.easyaudit_requestevent
42+
-- restart identity;
43+
44+
-- truncate
45+
-- table public.django_celery_beat_periodictask
46+
-- restart identity;
47+
48+
-- truncate
49+
-- table public.django_celery_results_taskresult
50+
-- restart identity;
51+
52+
-- alter sequence public.django_admin_log_id_seq restart with 1;
53+
54+
-- alter sequence public.easyaudit_crudevent_id_seq restart with 1;
55+
56+
-- alter sequence public.easyaudit_loginevent_id_seq restart with 1;
57+
58+
-- alter sequence public.easyaudit_requestevent_id_seq restart with 1;
59+
60+
-- alter sequence public.django_celery_beat_periodictask_id_seq restart with 1;
61+
62+
-- alter sequence public.django_celery_results_taskresult_id_seq restart with 1;
63+
64+
-- begin;
65+
-- create temporary table tmp_code(
66+
-- code text
67+
-- );
68+
69+
-- with
70+
-- ont as (
71+
-- select cast(t0.properties::json->'code' as varchar) as code
72+
-- from public.clinicalcode_ontologytag as t0
73+
-- where json_typeof(t0.properties::json->'code') = 'string'
74+
-- union all
75+
-- select t0.code::varchar
76+
-- from public.clinicalcode_code as t0
77+
-- ),
78+
-- unq as (
79+
-- select code::varchar
80+
-- from ont
81+
-- group by code
82+
-- )
83+
-- insert into tmp_code(code) (
84+
-- select t0.code
85+
-- from public.clinicalcode_snomed_codes as t0
86+
-- left join unq as t1
87+
-- on t0.code = t1.code
88+
-- where t1.code is null
89+
-- );
90+
-- delete
91+
-- from public.clinicalcode_snomed_codes as t0
92+
-- using tmp_code as t1
93+
-- where t0.code = t1.code;
94+
-- commit;
95+
96+
-- begin;
97+
-- create temporary table tmp_code(
98+
-- code text
99+
-- );
100+
101+
-- with
102+
-- unq as (
103+
-- select code
104+
-- from public.clinicalcode_code
105+
-- group by code
106+
-- )
107+
-- insert into tmp_code(code) (
108+
-- select t0.term_id as code
109+
-- from public.clinicalcode_read_cd_cv3_terms_scd as t0
110+
-- left join unq as t1
111+
-- on t0.term_id = t1.code
112+
-- where t1.code is null
113+
-- );
114+
-- delete
115+
-- from public.clinicalcode_read_cd_cv3_terms_scd as t0
116+
-- using tmp_code as t1
117+
-- where t0.term_id = t1.code;
118+
-- commit;
119+
120+
-- with
121+
-- used as (
122+
-- select t1.value::text::bigint
123+
-- from public.clinicalcode_genericentity as t0,
124+
-- json_array_elements(t0.template_data::json->'ontology') as t1
125+
-- where json_typeof(t0.template_data::json->'ontology') = 'array'
126+
-- and json_array_length(t0.template_data::json->'ontology') > 0
127+
-- union all
128+
-- select t1.value::text::bigint
129+
-- from public.clinicalcode_historicalgenericentity as t0,
130+
-- json_array_elements(t0.template_data::json->'ontology') as t1
131+
-- where json_typeof(t0.template_data::json->'ontology') = 'array'
132+
-- and json_array_length(t0.template_data::json->'ontology') > 0
133+
-- ),
134+
-- unq_used as (
135+
-- select value
136+
-- from used
137+
-- group by value
138+
-- )
139+
-- delete
140+
-- from public.clinicalcode_ontologytag as t0
141+
-- where t0.id not in (table unq_used)
142+
-- and t0.id > 100;
143+
144+
145+
-- select t0.*
146+
-- from public.clinicalcode_ontologytag as t0
147+
-- where t0.id in (table unq_used)
148+
-- join public.clinicalcode_ontologytag as t1
149+
-- on t0.template_data::json->'ontology' @> t1.id,

0 commit comments

Comments
 (0)