Last change before work :)

This commit is contained in:
Atridad Lahiji 2023-08-09 13:01:25 -06:00
parent 5cb8a18b83
commit 06a5f05250
No known key found for this signature in database
GPG key ID: 7CB8245F56BC3880
5 changed files with 8 additions and 8 deletions

View file

@ -25,14 +25,14 @@ export const restRouter = createTRPCRouter({
.input(z.void()) .input(z.void())
.output(z.number()) .output(z.number())
.query(async ({ ctx }) => { .query(async ({ ctx }) => {
const cachedResult = await fetchCache<number>(`kv_votecount_admin`); const cachedResult = await fetchCache<number>(`kv_votecount`);
if (cachedResult) { if (cachedResult) {
return cachedResult; return cachedResult;
} else { } else {
const votesCount = await ctx.prisma.vote.count(); const votesCount = await ctx.prisma.vote.count();
await setCache(`kv_votecount_admin`, votesCount); await setCache(`kv_votecount`, votesCount);
return votesCount; return votesCount;
} }

View file

@ -25,7 +25,7 @@ export const roomRouter = createTRPCRouter({
}, },
}); });
if (room) { if (room) {
await invalidateCache(`kv_roomcount_admin`); await invalidateCache(`kv_roomcount`);
await invalidateCache(`kv_roomlist_${ctx.session.user.id}`); await invalidateCache(`kv_roomlist_${ctx.session.user.id}`);
await publishToChannel( await publishToChannel(
@ -215,8 +215,8 @@ export const roomRouter = createTRPCRouter({
}); });
if (deletedRoom) { if (deletedRoom) {
await invalidateCache(`kv_roomcount_admin`); await invalidateCache(`kv_roomcount`);
await invalidateCache(`kv_votecount_admin`); await invalidateCache(`kv_votecount`);
await invalidateCache(`kv_roomlist_${ctx.session.user.id}`); await invalidateCache(`kv_roomlist_${ctx.session.user.id}`);
await publishToChannel( await publishToChannel(

View file

@ -118,7 +118,7 @@ export const userRouter = createTRPCRouter({
react: Goodbye({ name: user.name }), react: Goodbye({ name: user.name }),
}); });
await invalidateCache(`kv_usercount_admin`); await invalidateCache(`kv_usercount`);
await invalidateCache(`kv_userlist_admin`); await invalidateCache(`kv_userlist_admin`);
await publishToChannel( await publishToChannel(

View file

@ -85,7 +85,7 @@ export const voteRouter = createTRPCRouter({
}); });
if (vote) { if (vote) {
await invalidateCache(`kv_votecount_admin`); await invalidateCache(`kv_votecount`);
await invalidateCache(`kv_votes_${input.roomId}`); await invalidateCache(`kv_votes_${input.roomId}`);
await publishToChannel( await publishToChannel(

View file

@ -66,7 +66,7 @@ export const authOptions: NextAuthOptions = {
react: Welcome({ name: user.name }), react: Welcome({ name: user.name }),
}); });
await invalidateCache(`kv_userlist_admin`); await invalidateCache(`kv_userlist_admin`);
await invalidateCache(`kv_usercount_admin`); await invalidateCache(`kv_usercount`);
await publishToChannel( await publishToChannel(
`stats`, `stats`,