filtering cleanup, hits rendered

This commit is contained in:
Michael Freno
2025-12-23 01:02:55 -05:00
parent dc8111e7b6
commit 9cc682bda4
4 changed files with 133 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
import { createTRPCRouter, publicProcedure } from "../utils";
import { ConnectionFactory } from "~/server/utils";
import { withCacheAndStale } from "~/server/cache";
import { z } from "zod";
const BLOG_CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours
@@ -98,5 +99,18 @@ export const blogRouter = createTRPCRouter({
return { posts, tags, tagMap, privilegeLevel };
}
);
})
}),
incrementPostRead: publicProcedure
.input(z.object({ postId: z.number() }))
.mutation(async ({ input }) => {
const conn = ConnectionFactory();
await conn.execute({
sql: "UPDATE Post SET reads = reads + 1 WHERE id = ?",
args: [input.postId]
});
return { success: true };
})
});