This commit is contained in:
Atridad Lahiji 2023-10-03 17:06:31 -06:00
parent b4c0b3bd53
commit 4200f9ffc1
No known key found for this signature in database
6 changed files with 9 additions and 39 deletions

View file

@ -11,7 +11,7 @@ A scrum poker tool that helps agile teams plan their sprints in real-time.
- Real-time pub/sub: Ably
- ORM: Drizzle ORM
- Database: Turso (libSQL)
- Cache: Redis
- Cache: Upstash (Redis)
## Versioning

View file

@ -4,7 +4,6 @@ export const EventTypes = {
ROOM_LIST_UPDATE: "room.list.update",
ROOM_UPDATE: "room.update",
VOTE_UPDATE: "vote.update",
STATS_UPDATE: "stats.update",
} as const;
export type EventType = BetterEnum<typeof EventTypes>;

View file

@ -150,8 +150,6 @@ export async function PUT(
}
await db.delete(votes).where(eq(votes.roomId, params.roomId));
await invalidateCache(`kv_votes_${params.roomId}`);
}
const newRoom = await db

View file

@ -47,20 +47,12 @@ export async function PUT(
const success = upsertResult.rowsAffected > 0;
if (success) {
await invalidateCache(`kv_votes_${params.roomId}`);
await publishToChannel(
`${params.roomId}`,
EventTypes.VOTE_UPDATE,
reqBody.value
);
await publishToChannel(
`stats`,
EventTypes.STATS_UPDATE,
JSON.stringify(success)
);
return NextResponse.json(upsertResult, {
status: 200,
statusText: "SUCCESS",

View file

@ -18,31 +18,12 @@ export async function GET(
});
}
const cachedResult = await fetchCache<
{
id: string;
value: string;
created_at: Date;
userId: string;
roomId: string;
}[]
>(`kv_votes_${params.roomId}`);
const votesByRoomId = await db.query.votes.findMany({
where: eq(votes.roomId, params.roomId),
});
if (cachedResult) {
return NextResponse.json(cachedResult, {
status: 200,
statusText: "SUCCESS!",
});
} else {
const votesByRoomId = await db.query.votes.findMany({
where: eq(votes.roomId, params.roomId),
});
await setCache(`kv_votes_${params.roomId}`, votesByRoomId);
return NextResponse.json(votesByRoomId, {
status: 200,
statusText: "SUCCESS!",
});
}
return NextResponse.json(votesByRoomId, {
status: 200,
statusText: "SUCCESS!",
});
}

View file

@ -1,6 +1,6 @@
{
"name": "sprintpadawan",
"version": "3.1.0",
"version": "3.1.1",
"description": "Plan. Sprint. Repeat.",
"private": true,
"scripts": {