Skip to content

Commit

Permalink
webapp: Update history tables schemas (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Dec 16, 2024
1 parent 5607bd6 commit 385f112
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 5 additions & 6 deletions migrations/00000000000004_Init_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
);

--------------------------------------------------------------------------------
Expand Down
10 changes: 3 additions & 7 deletions repology-webapp/tests/integration_tests/fixtures/graphs_data.sql
Original file line number Diff line number Diff line change
@@ -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),
Expand Down

0 comments on commit 385f112

Please sign in to comment.