From 8658304df8c15c3cf679fd266e0179de345ff286 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Thu, 3 Oct 2024 23:13:52 +0330 Subject: [PATCH] Add ballot success field --- .../migrations/20241003194312_/migration.sql | 2 ++ prisma/schema.prisma | 1 + src/flow/flow.controller.ts | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 prisma/migrations/20241003194312_/migration.sql diff --git a/prisma/migrations/20241003194312_/migration.sql b/prisma/migrations/20241003194312_/migration.sql new file mode 100644 index 0000000..3997b0a --- /dev/null +++ b/prisma/migrations/20241003194312_/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "User" ADD COLUMN "ballot_success" INTEGER; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e6ba405..dc57a53 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -11,6 +11,7 @@ generator client { model User { id Int @id @default(autoincrement()) address String @unique() + ballotSuccess Int? @map("ballot_success") opAddress String? @unique() @map("op_address") isBadgeHolder Int @map("is_badgeholder") createdAt DateTime @default(now()) @map("created_at") diff --git a/src/flow/flow.controller.ts b/src/flow/flow.controller.ts index 8dc12b2..8085c7e 100644 --- a/src/flow/flow.controller.ts +++ b/src/flow/flow.controller.ts @@ -185,6 +185,24 @@ export class FlowController { return ballot; } + @UseGuards(AuthGuard) + @ApiOperation({ + summary: 'Used for a pairwise vote between two collections', + }) + @Get('/ballot/success') + async successBallot(@Req() { userId }: AuthedReq) { + await this.prismaService.user.update({ + where: { + id: userId, + }, + data: { + ballotSuccess: 1, + }, + }); + + return 'Success'; + } + @UseGuards(AuthGuard) @ApiOperation({ summary: 'Used for a pairwise vote between two collections',