Skip to content

Commit ded6174

Browse files
committedDec 17, 2024·
Rename repositories_history table (repology/repology-rs#120)
1 parent 8dfc3bc commit ded6174

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed
 

‎sql.d/schema/create_schema_tables.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ CREATE TABLE repositories (
258258
CREATE UNIQUE INDEX ON repositories(name);
259259

260260
-- history
261-
DROP TABLE IF EXISTS repositories_history_new CASCADE;
261+
DROP TABLE IF EXISTS repositories_history CASCADE;
262262

263-
CREATE TABLE repositories_history_new (
263+
CREATE TABLE repositories_history (
264264
repository_id smallint NOT NULL,
265265
ts timestamp with time zone NOT NULL,
266266
num_problems integer,

‎sql.d/update/update_histories.sql

+1-24
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,7 @@
1919
-- History snapshot
2020
--------------------------------------------------------------------------------
2121

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 (
4623
repository_id,
4724
ts,
4825
num_problems,

‎sql.d/update/update_post.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ WITH duplicate_rows AS (
9090
row({{ fields() }}) AS cur,
9191
lead(row({{ fields() }}), 1) OVER w AS next,
9292
lag(row({{ fields() }}), 1) OVER w AS prev
93-
FROM repositories_history_new
93+
FROM repositories_history
9494
-- Don't unnecessarily thin out the whole table each time -
9595
-- just process last week worth of history. This may produce
9696
-- leftovers for repostories which had no stat changes for more
@@ -100,10 +100,10 @@ WITH duplicate_rows AS (
100100
) AS tmp
101101
WHERE cur = next AND cur = prev
102102
)
103-
DELETE FROM repositories_history_new USING duplicate_rows
103+
DELETE FROM repositories_history USING duplicate_rows
104104
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;
107107

108108
{#
109109
do it manually for now

0 commit comments

Comments
 (0)
Please sign in to comment.