Skip to content

Commit

Permalink
Don't produce history for removed repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Nov 20, 2024
1 parent 523f1a7 commit e868b44
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions sql.d/update/update_histories.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@
--------------------------------------------------------------------------------

-- per-repository counters
INSERT INTO repositories_history (
ts,
snapshot
)
SELECT
now(),
jsonb_object_agg(snapshot.name, to_jsonb(snapshot) - 'name')
FROM (
WITH repositories_counters AS (
SELECT
name,
num_metapackages,
Expand All @@ -40,7 +33,22 @@ FROM (
num_maintainers,
num_metapackages_vulnerable
FROM repositories
) AS snapshot;
WHERE state = 'active'
), snapshot_candidate AS (
SELECT
now() AS ts,
jsonb_object_agg(repositories_counters.name, to_jsonb(repositories_counters) - 'name') AS snapshot
FROM repositories_counters
)
INSERT INTO repositories_history (
ts,
snapshot
)
SELECT
ts,
snapshot
FROM snapshot_candidate
WHERE snapshot IS NOT NULL;

INSERT INTO repositories_history_new (
repository_id,
Expand All @@ -67,7 +75,8 @@ SELECT
num_metapackages_comparable,
num_metapackages_problematic,
num_metapackages_vulnerable
FROM repositories;
FROM repositories
WHERE state != 'legacy';

-- global statistics
INSERT INTO statistics_history (
Expand Down

0 comments on commit e868b44

Please sign in to comment.