mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
quote & check for db version
This commit is contained in:
parent
bbb1db014c
commit
d9a66a5894
2 changed files with 8 additions and 3 deletions
|
@ -19,7 +19,7 @@ export const archiveDownvoteSegment = async (dayLimit: number, voteLimit: number
|
|||
`INSERT INTO "archivedSponsorTimes"
|
||||
SELECT *
|
||||
FROM "sponsorTimes"
|
||||
WHERE votes < ? AND (? - timeSubmitted) > ?`,
|
||||
WHERE "votes" < ? AND (? - "timeSubmitted") > ?`,
|
||||
[
|
||||
voteLimit,
|
||||
timeNow,
|
||||
|
@ -37,7 +37,7 @@ export const archiveDownvoteSegment = async (dayLimit: number, voteLimit: number
|
|||
try {
|
||||
await db.prepare(
|
||||
'run',
|
||||
'DELETE FROM "sponsorTimes" WHERE votes < ? AND (? - timeSubmitted) > ?',
|
||||
'DELETE FROM "sponsorTimes" WHERE "votes" < ? AND (? - "timeSubmitted") > ?',
|
||||
[
|
||||
voteLimit,
|
||||
timeNow,
|
||||
|
|
|
@ -40,6 +40,11 @@ describe('downvoteSegmentArchiveJob', () => {
|
|||
return;
|
||||
});
|
||||
|
||||
it('Should update the database version when starting the application', async () => {
|
||||
const version = (await db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version'])).value;
|
||||
assert.ok(version >= 21, "version should be greater or equal to 21");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.prepare('run', 'DELETE FROM "sponsorTimes"');
|
||||
await db.prepare('run', 'DELETE FROM "archivedSponsorTimes"');
|
||||
|
@ -52,7 +57,7 @@ describe('downvoteSegmentArchiveJob', () => {
|
|||
const getSegmentsInMainTable = (dayLimit: number, voteLimit: number, now: number): Promise<DBSegment[]> => {
|
||||
return db.prepare(
|
||||
'all',
|
||||
'SELECT * FROM "sponsorTimes" WHERE votes < ? AND (? - timeSubmitted) > ?',
|
||||
'SELECT * FROM "sponsorTimes" WHERE "votes" < ? AND (? - "timeSubmitted") > ?',
|
||||
[
|
||||
voteLimit,
|
||||
now,
|
||||
|
|
Loading…
Reference in a new issue