Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
♻️ Drop per-participant votes from the v1 participants endpoint (#3283)
Luke Vella510a0ff1d4d3
diff --git a/apps/web/src/app/api/v1/[...route]/route.test.ts b/apps/web/src/app/api/v1/[...route]/route.test.tsindex 2c85e62c7..1a3fc530f 100644--- a/apps/web/src/app/api/v1/[...route]/route.test.ts+++ b/apps/web/src/app/api/v1/[...route]/route.test.ts@@ -1516,9 +1516,6 @@ describe("API v1 - /polls", () => {expect(schemas.TimeOption.properties.id.example).toMatch(cuidExample);expect(schemas.DateOption.properties.id.example).toMatch(cuidExample);expect(schemas.Participant.properties.id.example).toMatch(cuidExample);- expect(schemas.ParticipantVote.properties.optionId.example).toMatch(- cuidExample,- );expect(JSON.stringify(json)).not.toMatch(/p_123abc|opt_abc123|participant_abc123|space_abc123/,);@@ -2606,21 +2603,16 @@ describe("API v1 - /polls", () => {name: "Alice",email: "[email protected]",createdAt: new Date("2025-01-10T10:00:00Z"),- votes: [- { optionId: "opt-1", type: "yes" },- { optionId: "opt-2", type: "no" },- ],},{id: "participant-2",name: "Bob",email: null,createdAt: new Date("2025-01-10T11:00:00Z"),- votes: [{ optionId: "opt-1", type: "ifNeedBe" }],},];- it("should return participants with their votes in the list shape", async () => {+ it("should return participants in the list shape", async () => {mockGetPollParticipants.mockResolvedValue({pollId: "test-poll-id",participants,@@ -2644,10 +2636,6 @@ describe("API v1 - /polls", () => {name: "Alice",email: "[email protected]",createdAt: "2025-01-10T10:00:00.000Z",- votes: [- { optionId: "opt-1", type: "yes" },- { optionId: "opt-2", type: "no" },- ],});expect(json.data[1].email).toBeNull();expect(json.nextCursor).toBeNull();@@ -2660,30 +2648,6 @@ describe("API v1 - /polls", () => {});});- it("should pass through a vote type the schema does not know", async () => {- mockGetPollParticipants.mockResolvedValue({- pollId: "test-poll-id",- participants: [- { ...participants[0], votes: [{ optionId: "opt-1", type: "maybe" }] },- ],- nextCursor: null,- });-- const res = await app.request("/v1/polls/test-poll-id/participants", {- method: "GET",- headers: {- Authorization: `Bearer ${testApiKey}`,- },- });-- expect(res.status).toBe(200);- const json = await res.json();- expectMatchesContract(getPollParticipantsSuccessResponseSchema, json);- expect(json.data[0].votes).toEqual([- { optionId: "opt-1", type: "maybe" },- ]);- });-it("should pass the cursor and limit through and return the next cursor", async () => {mockGetPollParticipants.mockResolvedValue({pollId: "test-poll-id",diff --git a/apps/web/src/app/api/v1/[...route]/route.ts b/apps/web/src/app/api/v1/[...route]/route.tsindex 68723250a..d92a1b71e 100644--- a/apps/web/src/app/api/v1/[...route]/route.ts+++ b/apps/web/src/app/api/v1/[...route]/route.ts@@ -876,7 +876,7 @@ app.get(tags: ["Polls"],summary: "Get poll results",description: [- "Retrieves aggregated voting results for a poll: vote counts per option without individual participant data. Use `GET /polls/:pollId/participants` for per-person availability.",+ "Retrieves aggregated voting results for a poll: vote counts per option without individual participant data. Use `GET /polls/:pollId/participants` to list who responded.","","`votes` lists every vote type the poll offers with its count, zero included. `score` is an opaque ranking value: sort by it to order options from best to worst, and use `isTopChoice` or `highScore` to find the leading options. Its formula is not part of the contract, so do not decode it, compare it across polls or threshold on it.",].join("\n"),@@ -948,9 +948,9 @@ app.get(tags: ["Polls"],summary: "List poll participants",description: [- "Lists the participants of a poll with their votes, oldest response first. The poll must belong to the space associated with the API key.",+ "Lists the participants of a poll, oldest response first. The poll must belong to the space associated with the API key.","",- "Each participant's `votes` pairs an `optionId` from the poll with the answer they gave, so this is the endpoint for per-person availability. Results are paginated with a cursor: pass the `nextCursor` value from the previous response to fetch the next page.",+ "Results are paginated with a cursor: pass the `nextCursor` value from the previous response to fetch the next page. Per-option answers are not included; use the results endpoint for aggregate availability.",].join("\n"),security: [{ bearerAuth: [] }],responses: {@@ -1009,7 +1009,6 @@ app.get(name: participant.name,email: participant.email,createdAt: participant.createdAt.toISOString(),- votes: participant.votes,})),nextCursor: data.nextCursor,}),diff --git a/apps/web/src/app/api/v1/schemas.ts b/apps/web/src/app/api/v1/schemas.tsindex dec8872f8..e29287b48 100644--- a/apps/web/src/app/api/v1/schemas.ts+++ b/apps/web/src/app/api/v1/schemas.ts@@ -468,23 +468,12 @@ export const getPollResultsSuccessResponseSchema = z}).meta({ id: "GetPollResultsResponse" });-export const participantVoteSchema = z- .object({- optionId: z.string().meta({ example: "cm5h8x2k40000q9l4f7e2d3an" }),- type: voteTypeSchema,- })- .meta({ id: "ParticipantVote" });-export const participantSchema = z.object({id: z.string().meta({ example: "cm5j2r8wb0003q9l4a1x6p0zt" }),name: z.string().meta({ example: "Jane Smith" }),email: z.string().nullable().meta({ example: "[email protected]" }),createdAt: z.iso.datetime().meta({ example: "2025-01-10T12:00:00.000Z" }),- votes: z.array(participantVoteSchema).meta({- description:- "The participant's vote for each option, keyed by `optionId`. An option missing from the list has no recorded vote from this participant.",- }),}).meta({ id: "Participant" });diff --git a/apps/web/src/features/poll/data.ts b/apps/web/src/features/poll/data.tsindex c1a3cb2a5..6641bae9f 100644--- a/apps/web/src/features/poll/data.ts+++ b/apps/web/src/features/poll/data.ts@@ -163,12 +163,6 @@ export async function getPollParticipants({name: true,email: true,createdAt: true,- votes: {- select: {- optionId: true,- type: true,- },- },},orderBy: [{ createdAt: "asc" }, { id: "asc" }],...(limit !== undefined && { take: limit + 1 }),