Skip to content

Commit

Permalink
feat: update room lastUsedAt on vote and join
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumm committed Jan 19, 2024
1 parent 8b5fa44 commit d3a4605
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/server/api/routers/room.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ export const roomRouter = createTRPCRouter({
userId: userId!,
event,
});
await db
.update(rooms)
.set({
lastUsedAt: new Date(),
})
.where(eq(rooms.id, room.id));
return {
userId: userId!,
roomId: room.id,
Expand Down
11 changes: 10 additions & 1 deletion src/server/room-state/room-state.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { env } from 'fpp/env.mjs';
import { TRPCError } from '@trpc/server';

import { Redis } from '@upstash/redis';
import { eq } from 'drizzle-orm';
import { type PlanetScaleDatabase } from 'drizzle-orm/planetscale-serverless/driver';

import { estimations, votes } from 'fpp/server/db/schema';
import { estimations, rooms, votes } from 'fpp/server/db/schema';

import {
type RoomStateDto,
Expand Down Expand Up @@ -100,6 +101,14 @@ export async function setRoomState({
}),
);
}
promises.push(
db
.update(rooms)
.set({
lastUsedAt: new Date(),
})
.where(eq(rooms.id, roomId)),
);
roomState.isFlipAction = false;
}

Expand Down

1 comment on commit d3a4605

@vercel
Copy link

@vercel vercel bot commented on d3a4605 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.