Skip to content

Commit

Permalink
support Jitsi instance variants
Browse files Browse the repository at this point in the history
  • Loading branch information
elrido committed Mar 12, 2024
1 parent 37e1856 commit 67cabc6
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 180 deletions.
32 changes: 32 additions & 0 deletions migrations/2022-03-20-112748_add_csp/down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,35 @@ SELECT id, url, version, https, https_redirect, country_id, attachments
FROM _instances;

DROP TABLE _instances;

-- recreating these is necessary to ensure the references point to the new parent
ALTER TABLE checks RENAME TO _checks;

CREATE TABLE checks (
id INTEGER NOT NULL PRIMARY KEY,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
up BOOLEAN NOT NULL DEFAULT 0,
instance_id INTEGER NOT NULL,
FOREIGN KEY(instance_id) REFERENCES instances(id) ON DELETE CASCADE
);

INSERT INTO checks
SELECT * FROM _checks;

DROP TABLE _checks;

ALTER TABLE scans RENAME TO _scans;

CREATE TABLE scans (
id INTEGER NOT NULL PRIMARY KEY,
scanner VARCHAR(255) NOT NULL,
rating VARCHAR(255) NOT NULL DEFAULT "-",
percent INTEGER NOT NULL DEFAULT 0,
instance_id INTEGER NOT NULL,
FOREIGN KEY(instance_id) REFERENCES instances(id) ON DELETE CASCADE
);

INSERT INTO scans
SELECT * FROM _scans;

DROP TABLE _scans;
50 changes: 50 additions & 0 deletions migrations/2024-03-12-044346_add_variant/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ALTER TABLE instances RENAME TO _instances;

CREATE TABLE instances (
id INTEGER NOT NULL PRIMARY KEY,
url VARCHAR(255) NOT NULL,
version VARCHAR(255) NOT NULL,
https BOOLEAN NOT NULL DEFAULT 0,
https_redirect BOOLEAN NOT NULL DEFAULT 0,
country_id CHARACTER(2) NOT NULL DEFAULT "AQ",
attachments BOOLEAN NOT NULL DEFAULT 0,
csp_header BOOLEAN NOT NULL DEFAULT 0
);

INSERT INTO instances (id, url, version, https, https_redirect, country_id, attachments, csp_header)
SELECT id, url, version, https, https_redirect, country_id, attachments, csp_header
FROM _instances;

DROP TABLE _instances;

-- recreating these is necessary to ensure the references point to the new parent
ALTER TABLE checks RENAME TO _checks;

CREATE TABLE checks (
id INTEGER NOT NULL PRIMARY KEY,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
up BOOLEAN NOT NULL DEFAULT 0,
instance_id INTEGER NOT NULL,
FOREIGN KEY(instance_id) REFERENCES instances(id) ON DELETE CASCADE
);

INSERT INTO checks
SELECT * FROM _checks;

DROP TABLE _checks;

ALTER TABLE scans RENAME TO _scans;

CREATE TABLE scans (
id INTEGER NOT NULL PRIMARY KEY,
scanner VARCHAR(255) NOT NULL,
rating VARCHAR(255) NOT NULL DEFAULT "-",
percent INTEGER NOT NULL DEFAULT 0,
instance_id INTEGER NOT NULL,
FOREIGN KEY(instance_id) REFERENCES instances(id) ON DELETE CASCADE
);

INSERT INTO scans
SELECT * FROM _scans;

DROP TABLE _scans;
2 changes: 2 additions & 0 deletions migrations/2024-03-12-044346_add_variant/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE instances
ADD variant INTEGER NOT NULL DEFAULT 0;
1 change: 1 addition & 0 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn get_instances() -> SqlQuery {
SELECT rating, percent, instance_id \
FROM scans WHERE scanner = \"mozilla_observatory\" \
) AS mozilla_observatory ON instances.id = mozilla_observatory.instance_id \
WHERE instances.variant = 0 \
GROUP BY instances.id \
ORDER BY version DESC, https DESC, https_redirect DESC, csp_header DESC, \
mozilla_observatory.percent DESC, attachments DESC, uptime DESC, url ASC \
Expand Down
Loading

0 comments on commit 67cabc6

Please sign in to comment.