From cbdd85256633bceb5d2b4b52768e29ced18268dc Mon Sep 17 00:00:00 2001 From: Michael C Date: Thu, 26 May 2022 21:17:58 -0400 Subject: [PATCH 1/2] add additional poi_highlight tests --- test/cases/lockCategoriesRecords.ts | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/cases/lockCategoriesRecords.ts b/test/cases/lockCategoriesRecords.ts index ab96c05..7d6bd4a 100644 --- a/test/cases/lockCategoriesRecords.ts +++ b/test/cases/lockCategoriesRecords.ts @@ -54,6 +54,7 @@ describe("lockCategoriesRecords", () => { await db.prepare("run", insertLockCategoryQuery, [lockVIPUserHash, "delete-record-1", "mute", "sponsor", "reason-5", "YouTube"]); await db.prepare("run", insertLockCategoryQuery, [lockVIPUserHash, "delete-record-1", "skip", "intro", "reason-5", "YouTube"]); await db.prepare("run", insertLockCategoryQuery, [lockVIPUserHash, "delete-record-1", "mute", "intro", "reason-5", "YouTube"]); + await db.prepare("run", insertLockCategoryQuery, [lockVIPUserHash, "delete-record-poi", "poi", "poi_highlight", "reason-6", "YouTube"]); }); it("Should update the database version when starting the application", async () => { @@ -519,4 +520,44 @@ describe("lockCategoriesRecords", () => { }) .catch(err => done(err)); }); + + it("should be able to delete poi type category by type poi", (done) => { + const videoID = "delete-record-poi"; + const json = { + videoID, + userID: lockVIPUser, + categories: [ + "poi_highlight", + ], + actionTypes: ["poi"] + }; + client.delete(endpoint, { data: json }) + .then(async res => { + assert.strictEqual(res.status, 200); + const result = await checkLockCategories(videoID); + assert.strictEqual(result.length, 0); + done(); + }) + .catch(err => done(err)); + }); + + it("should be able to delete poi type category by type poi", (done) => { + const videoID = "delete-record-poi"; + const json = { + videoID, + userID: lockVIPUser, + categories: [ + "poi_highlight", + ], + actionTypes: ["poi"] + }; + client.delete(endpoint, { data: json }) + .then(async res => { + assert.strictEqual(res.status, 200); + const result = await checkLockCategories(videoID); + assert.strictEqual(result.length, 0); + done(); + }) + .catch(err => done(err)); + }); }); From d2730955257a9ae83880d2b3b7f134d8bfe24dbf Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 26 May 2022 22:47:07 -0400 Subject: [PATCH 2/2] Add improved hashed ip index --- databases/_private_indexes.sql | 5 ++--- databases/_upgrade_private_9.sql | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 databases/_upgrade_private_9.sql diff --git a/databases/_private_indexes.sql b/databases/_private_indexes.sql index 7187514..35d3bcc 100644 --- a/databases/_private_indexes.sql +++ b/databases/_private_indexes.sql @@ -1,9 +1,8 @@ -- sponsorTimes -CREATE INDEX IF NOT EXISTS "privateDB_sponsorTimes_v3" +CREATE INDEX IF NOT EXISTS "privateDB_sponsorTimes_v4" ON public."sponsorTimes" USING btree - ("hashedIP" COLLATE pg_catalog."default" ASC NULLS LAST, "videoID" ASC NULLS LAST, service COLLATE pg_catalog."default" ASC NULLS LAST) -; + ("videoID" ASC NULLS LAST, service COLLATE pg_catalog."default" ASC NULLS LAST, "timeSubmitted" ASC NULLS LAST); -- votes diff --git a/databases/_upgrade_private_9.sql b/databases/_upgrade_private_9.sql new file mode 100644 index 0000000..b4baaa9 --- /dev/null +++ b/databases/_upgrade_private_9.sql @@ -0,0 +1,9 @@ +BEGIN TRANSACTION; + +-- Add primary keys + +DROP INDEX "privateDB_sponsorTimes_v3"; --!sqlite-ignore + +UPDATE "config" SET value = 9 WHERE key = 'version'; + +COMMIT; \ No newline at end of file