mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-25 08:58:23 +03:00
Add more things to read from replica
This commit is contained in:
@@ -5,7 +5,7 @@ import { userFeatureKey } from "./redisKeys";
|
||||
|
||||
export async function hasFeature(userID: HashedUserID, feature: Feature): Promise<boolean> {
|
||||
return await QueryCacher.get(async () => {
|
||||
const result = await db.prepare("get", 'SELECT "feature" from "userFeatures" WHERE "userID" = ? AND "feature" = ?', [userID, feature]);
|
||||
const result = await db.prepare("get", 'SELECT "feature" from "userFeatures" WHERE "userID" = ? AND "feature" = ?', [userID, feature], { useReplica: true });
|
||||
return !!result;
|
||||
}, userFeatureKey(userID, feature));
|
||||
}
|
||||
@@ -2,5 +2,6 @@ import { db } from "../databases/databases";
|
||||
import { HashedUserID } from "../types/user.model";
|
||||
|
||||
export async function isUserVIP(userID: HashedUserID): Promise<boolean> {
|
||||
return (await db.prepare("get", `SELECT count(*) as "userCount" FROM "vipUsers" WHERE "userID" = ? LIMIT 1`, [userID]))?.userCount > 0;
|
||||
return (await db.prepare("get", `SELECT count(*) as "userCount" FROM "vipUsers" WHERE "userID" = ? LIMIT 1`,
|
||||
[userID], { useReplica: true }))?.userCount > 0;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function getReputation(userID: UserID): Promise<number> {
|
||||
SELECT * FROM "lockCategories" as l
|
||||
WHERE l."videoID" = "a"."videoID" AND l."service" = "a"."service" AND l."category" = "a"."category" LIMIT 1)
|
||||
THEN 1 ELSE 0 END) AS "mostUpvotedInLockedVideoSum"
|
||||
FROM "sponsorTimes" as "a" WHERE "userID" = ?`, [userID, weekAgo, pastDate, userID]) as Promise<ReputationDBResult>;
|
||||
FROM "sponsorTimes" as "a" WHERE "userID" = ?`, [userID, weekAgo, pastDate, userID], { useReplica: true }) as Promise<ReputationDBResult>;
|
||||
|
||||
const result = await QueryCacher.get(fetchFromDB, reputationKey(userID));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user