Commit ded6174 committed Dec 17, 2024 · 1 / 1
1 parent 8dfc3bc commit ded6174 Copy full SHA for ded6174
File tree 3 files changed +7
-30
lines changed
3 files changed +7
-30
lines changed Original file line number Diff line number Diff line change @@ -258,9 +258,9 @@ CREATE TABLE repositories (
258
258
CREATE UNIQUE INDEX ON repositories(name);
259
259
260
260
-- history
261
- DROP TABLE IF EXISTS repositories_history_new CASCADE;
261
+ DROP TABLE IF EXISTS repositories_history CASCADE;
262
262
263
- CREATE TABLE repositories_history_new (
263
+ CREATE TABLE repositories_history (
264
264
repository_id smallint NOT NULL ,
265
265
ts timestamp with time zone NOT NULL ,
266
266
num_problems integer ,
Original file line number Diff line number Diff line change 19
19
-- History snapshot
20
20
-- ------------------------------------------------------------------------------
21
21
22
- -- per-repository counters
23
- -- INSERT INTO repositories_history (
24
- -- ts,
25
- -- snapshot
26
- -- )
27
- -- SELECT
28
- -- now(),
29
- -- jsonb_object_agg(snapshot.name, to_jsonb(snapshot) - 'name')
30
- -- FROM (
31
- -- SELECT
32
- -- name,
33
- -- num_metapackages,
34
- -- num_metapackages_unique,
35
- -- num_metapackages_newest,
36
- -- num_metapackages_outdated,
37
- -- num_metapackages_comparable,
38
- -- num_metapackages_problematic,
39
- -- num_problems,
40
- -- num_maintainers,
41
- -- num_metapackages_vulnerable
42
- -- FROM repositories
43
- -- ) AS snapshot;
44
-
45
- INSERT INTO repositories_history_new (
22
+ INSERT INTO repositories_history (
46
23
repository_id,
47
24
ts,
48
25
num_problems,
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ WITH duplicate_rows AS (
90
90
row({{ fields() }}) AS cur,
91
91
lead(row({{ fields() }}), 1 ) OVER w AS next,
92
92
lag(row({{ fields() }}), 1 ) OVER w AS prev
93
- FROM repositories_history_new
93
+ FROM repositories_history
94
94
-- Don't unnecessarily thin out the whole table each time -
95
95
-- just process last week worth of history. This may produce
96
96
-- leftovers for repostories which had no stat changes for more
@@ -100,10 +100,10 @@ WITH duplicate_rows AS (
100
100
) AS tmp
101
101
WHERE cur = next AND cur = prev
102
102
)
103
- DELETE FROM repositories_history_new USING duplicate_rows
103
+ DELETE FROM repositories_history USING duplicate_rows
104
104
WHERE
105
- repositories_history_new .repository_id = duplicate_rows .repository_id AND
106
- repositories_history_new .ts = duplicate_rows .ts ;
105
+ repositories_history .repository_id = duplicate_rows .repository_id AND
106
+ repositories_history .ts = duplicate_rows .ts ;
107
107
108
108
{#
109
109
do it manually for now
You can’t perform that action at this time.
0 commit comments