From 385f1123c2167079848e2532f5fbef01778c5f25 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Dec 2024 19:27:33 +0300 Subject: [PATCH] webapp: Update history tables schemas (#120) --- migrations/00000000000004_Init_tables.sql | 11 +++++------ .../tests/integration_tests/fixtures/graphs_data.sql | 10 +++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/migrations/00000000000004_Init_tables.sql b/migrations/00000000000004_Init_tables.sql index 398e586..f7004ea 100644 --- a/migrations/00000000000004_Init_tables.sql +++ b/migrations/00000000000004_Init_tables.sql @@ -246,11 +246,6 @@ CREATE TABLE repositories ( CREATE UNIQUE INDEX ON repositories(name); -- history -CREATE TABLE repositories_history ( - ts timestamp with time zone NOT NULL PRIMARY KEY, - snapshot jsonb NOT NULL -); - CREATE TABLE repositories_history_new ( repository_id smallint NOT NULL, ts timestamp with time zone NOT NULL, @@ -434,7 +429,11 @@ INSERT INTO statistics VALUES(DEFAULT); -- statistics_history CREATE TABLE statistics_history ( ts timestamp with time zone NOT NULL PRIMARY KEY, - snapshot jsonb NOT NULL + snapshot jsonb NOT NULL, + num_packages integer, + num_projects integer, + num_problems integer, + num_maintainers integer ); -------------------------------------------------------------------------------- diff --git a/repology-webapp/tests/integration_tests/fixtures/graphs_data.sql b/repology-webapp/tests/integration_tests/fixtures/graphs_data.sql index 08a5d66..701ddf1 100644 --- a/repology-webapp/tests/integration_tests/fixtures/graphs_data.sql +++ b/repology-webapp/tests/integration_tests/fixtures/graphs_data.sql @@ -1,12 +1,8 @@ -- first point is intentionally long in the past to check whether it's handled properly producing a line -INSERT INTO statistics_history(ts, snapshot) VALUES - (now() - interval '128 day', '{"num_packages":1,"num_problems":1,"num_maintainers":1,"num_metapackages":1}'), +INSERT INTO statistics_history(ts, snapshot, num_packages, num_problems, num_maintainers, num_projects) VALUES + (now() - interval '128 day', '{"num_packages":1,"num_problems":1,"num_maintainers":1,"num_metapackages":1}', 1, 1, 1, 1), -- emulate time difference between application and database - (now() + interval '5 second', '{"num_packages":10,"num_problems":10,"num_maintainers":10,"num_metapackages":10}'); - -INSERT INTO repositories_history(ts, snapshot) VALUES - (now() - interval '128 day', '{"freebsd":{"num_maintainers":1,"num_problems":1,"num_metapackages":1,"num_metapackages_unique":1,"num_metapackages_newest":1,"num_metapackages_outdated":1,"num_metapackages_problematic":1,"num_metapackages_vulnerable":1}}'::jsonb), - (now() + interval '5 second', '{"freebsd":{"num_maintainers":10,"num_problems":10,"num_metapackages":10,"num_metapackages_unique":10,"num_metapackages_newest":10,"num_metapackages_outdated":10,"num_metapackages_problematic":10,"num_metapackages_vulnerable":10}}'::jsonb); + (now() + interval '5 second', '{"num_packages":10,"num_problems":10,"num_maintainers":10,"num_metapackages":10}', 1, 1, 1, 1); INSERT INTO repositories_history_new(repository_id, ts, num_maintainers, num_problems, num_projects, num_projects_unique, num_projects_newest, num_projects_outdated, num_projects_problematic, num_projects_vulnerable) VALUES (1, now() - interval '128 day', 1, 1, 1, 1, 1, 1, 1, 1),