Skip to content

Commit

Permalink
fix: user last updated based on copy pasta create
Browse files Browse the repository at this point in the history
  • Loading branch information
dotslashf committed Oct 4, 2024
1 parent aca70e8 commit fa99b8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/server/api/routers/copyPasta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
publicProcedure,
} from "~/server/api/trpc";

import { getRandomElement, handleEngagementAction } from "~/utils";
import {
getJakartaDate,
getRandomElement,
handleEngagementAction,
} from "~/utils";
import {
type CopyPastaOnlyContent,
type CopyPastaSearchResult,
Expand Down Expand Up @@ -85,6 +89,15 @@ export const copyPastaRouter = createTRPCRouter({
},
});

await ctx.db.user.update({
where: {
id: ctx.session.user.id,
},
data: {
lastPostedAt: getJakartaDate(),
},
});

const payload = handleEngagementAction("CreateCopyPasta", copyPasta.id);
await updateUserEngagementScore(ctx.db, ctx.session.user.id, payload);
if (isSuperAdmin) {
Expand Down
1 change: 0 additions & 1 deletion src/server/api/routers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export async function updateUserStreak(userId: string, db: PrismaClient) {
data: {
currentStreak: newStreak,
longestStreak: Math.max(newStreak, user.longestStreak || 0),
lastPostedAt: now,
},
});

Expand Down

0 comments on commit fa99b8b

Please sign in to comment.