3.1.1
This commit is contained in:
parent
6b61164db0
commit
217ccad4c2
6 changed files with 9 additions and 39 deletions
|
@ -11,7 +11,7 @@ A scrum poker tool that helps agile teams plan their sprints in real-time.
|
||||||
- Real-time pub/sub: Ably
|
- Real-time pub/sub: Ably
|
||||||
- ORM: Drizzle ORM
|
- ORM: Drizzle ORM
|
||||||
- Database: Turso (libSQL)
|
- Database: Turso (libSQL)
|
||||||
- Cache: Redis
|
- Cache: Upstash (Redis)
|
||||||
|
|
||||||
## Versioning
|
## Versioning
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ export const EventTypes = {
|
||||||
ROOM_LIST_UPDATE: "room.list.update",
|
ROOM_LIST_UPDATE: "room.list.update",
|
||||||
ROOM_UPDATE: "room.update",
|
ROOM_UPDATE: "room.update",
|
||||||
VOTE_UPDATE: "vote.update",
|
VOTE_UPDATE: "vote.update",
|
||||||
STATS_UPDATE: "stats.update",
|
|
||||||
} as const;
|
} as const;
|
||||||
export type EventType = BetterEnum<typeof EventTypes>;
|
export type EventType = BetterEnum<typeof EventTypes>;
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,6 @@ export async function PUT(
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.delete(votes).where(eq(votes.roomId, params.roomId));
|
await db.delete(votes).where(eq(votes.roomId, params.roomId));
|
||||||
|
|
||||||
await invalidateCache(`kv_votes_${params.roomId}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newRoom = await db
|
const newRoom = await db
|
||||||
|
|
|
@ -47,20 +47,12 @@ export async function PUT(
|
||||||
const success = upsertResult.rowsAffected > 0;
|
const success = upsertResult.rowsAffected > 0;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
await invalidateCache(`kv_votes_${params.roomId}`);
|
|
||||||
|
|
||||||
await publishToChannel(
|
await publishToChannel(
|
||||||
`${params.roomId}`,
|
`${params.roomId}`,
|
||||||
EventTypes.VOTE_UPDATE,
|
EventTypes.VOTE_UPDATE,
|
||||||
reqBody.value
|
reqBody.value
|
||||||
);
|
);
|
||||||
|
|
||||||
await publishToChannel(
|
|
||||||
`stats`,
|
|
||||||
EventTypes.STATS_UPDATE,
|
|
||||||
JSON.stringify(success)
|
|
||||||
);
|
|
||||||
|
|
||||||
return NextResponse.json(upsertResult, {
|
return NextResponse.json(upsertResult, {
|
||||||
status: 200,
|
status: 200,
|
||||||
statusText: "SUCCESS",
|
statusText: "SUCCESS",
|
||||||
|
|
|
@ -18,31 +18,12 @@ export async function GET(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachedResult = await fetchCache<
|
const votesByRoomId = await db.query.votes.findMany({
|
||||||
{
|
where: eq(votes.roomId, params.roomId),
|
||||||
id: string;
|
});
|
||||||
value: string;
|
|
||||||
created_at: Date;
|
|
||||||
userId: string;
|
|
||||||
roomId: string;
|
|
||||||
}[]
|
|
||||||
>(`kv_votes_${params.roomId}`);
|
|
||||||
|
|
||||||
if (cachedResult) {
|
return NextResponse.json(votesByRoomId, {
|
||||||
return NextResponse.json(cachedResult, {
|
status: 200,
|
||||||
status: 200,
|
statusText: "SUCCESS!",
|
||||||
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!",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sprintpadawan",
|
"name": "sprintpadawan",
|
||||||
"version": "3.1.0",
|
"version": "3.1.1",
|
||||||
"description": "Plan. Sprint. Repeat.",
|
"description": "Plan. Sprint. Repeat.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue