mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-25 00:48:22 +03:00
Merge branch 'master' into unhide-vote
This commit is contained in:
@@ -197,24 +197,29 @@ async function queueDump(): Promise<void> {
|
||||
const startTime = Date.now();
|
||||
updateRunning = true;
|
||||
|
||||
await removeOutdatedDumps(appExportPath);
|
||||
try {
|
||||
await removeOutdatedDumps(appExportPath);
|
||||
|
||||
const dumpFiles = [];
|
||||
const dumpFiles = [];
|
||||
|
||||
for (const table of tables) {
|
||||
const fileName = `${table.name}_${startTime}.csv`;
|
||||
const file = `${postgresExportPath}/${fileName}`;
|
||||
await db.prepare('run', `COPY (SELECT * FROM "${table.name}"${table.order ? ` ORDER BY "${table.order}"` : ``})
|
||||
TO '${file}' WITH (FORMAT CSV, HEADER true);`);
|
||||
dumpFiles.push({
|
||||
fileName,
|
||||
tableName: table.name,
|
||||
});
|
||||
}
|
||||
latestDumpFiles = [...dumpFiles];
|
||||
|
||||
for (const table of tables) {
|
||||
const fileName = `${table.name}_${startTime}.csv`;
|
||||
const file = `${postgresExportPath}/${fileName}`;
|
||||
await db.prepare('run', `COPY (SELECT * FROM "${table.name}"${table.order ? ` ORDER BY "${table.order}"` : ``})
|
||||
TO '${file}' WITH (FORMAT CSV, HEADER true);`);
|
||||
dumpFiles.push({
|
||||
fileName,
|
||||
tableName: table.name,
|
||||
});
|
||||
lastUpdate = startTime;
|
||||
} catch(e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
updateQueued = false;
|
||||
updateRunning = false;
|
||||
}
|
||||
latestDumpFiles = [...dumpFiles];
|
||||
|
||||
updateQueued = false;
|
||||
updateRunning = false;
|
||||
lastUpdate = startTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,6 +289,13 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
||||
//check if user voting on own submission
|
||||
const isOwnSubmission = (await db.prepare("get", `SELECT "UUID" as "submissionCount" FROM "sponsorTimes" where "userID" = ? AND "UUID" = ?`, [nonAnonUserID, UUID])) !== undefined;
|
||||
|
||||
// disallow vote types 10/11
|
||||
if (type === 10 || type === 11) {
|
||||
// no longer allow type 10/11 alternative votes
|
||||
res.sendStatus(400)
|
||||
return;
|
||||
}
|
||||
|
||||
// If not upvote
|
||||
if (!isVIP && type !== 1) {
|
||||
const isSegmentLocked = async () => !!(await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]))?.locked;
|
||||
@@ -343,10 +350,10 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
||||
let incrementAmount = 0;
|
||||
let oldIncrementAmount = 0;
|
||||
|
||||
if (type == 1 || type == 11) {
|
||||
if (type == 1) {
|
||||
//upvote
|
||||
incrementAmount = 1;
|
||||
} else if (type == 0 || type == 10) {
|
||||
} else if (type == 0) {
|
||||
//downvote
|
||||
incrementAmount = -1;
|
||||
} else if (type == 20) {
|
||||
@@ -358,10 +365,10 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
||||
return;
|
||||
}
|
||||
if (votesRow != undefined) {
|
||||
if (votesRow.type === 1 || type === 11) {
|
||||
if (votesRow.type === 1) {
|
||||
//upvote
|
||||
oldIncrementAmount = 1;
|
||||
} else if (votesRow.type === 0 || type === 10) {
|
||||
} else if (votesRow.type === 0) {
|
||||
//downvote
|
||||
oldIncrementAmount = -1;
|
||||
} else if (votesRow.type === 2) {
|
||||
|
||||
Reference in New Issue
Block a user