From feeb943544afe69a931bb6466e1a840934a883f6 Mon Sep 17 00:00:00 2001 From: Eric Chang <55172722+echang594@users.noreply.github.com> Date: Sat, 9 Mar 2024 14:10:34 -0800 Subject: [PATCH 1/6] Added discord and google calendar event columns --- api/validators/EventControllerRequests.ts | 7 ++++ ...d-and-google-calendar-event-uuid-fields.ts | 33 +++++++++++++++++++ models/EventModel.ts | 8 +++++ types/ApiRequests.ts | 2 ++ types/ApiResponses.ts | 2 ++ 5 files changed, 52 insertions(+) create mode 100644 migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts diff --git a/api/validators/EventControllerRequests.ts b/api/validators/EventControllerRequests.ts index 64e7a57d1..6e0e02232 100644 --- a/api/validators/EventControllerRequests.ts +++ b/api/validators/EventControllerRequests.ts @@ -7,6 +7,7 @@ import { PatchEventRequest as IPatchEventRequest, SubmitEventFeedbackRequest as ISubmitEventFeedbackRequest, Event as IEvent, + Uuid, } from '../../types'; import { IsValidEventFeedback } from '../decorators/Validators'; @@ -28,6 +29,12 @@ export class OptionalEventProperties implements IOptionalEventProperties { @Allow() staffPointBonus?: number; + + @Allow() + discordEventUuid?: Uuid; + + @Allow() + googleCalendarEventUuid?: Uuid; } export class Event extends OptionalEventProperties implements IEvent { diff --git a/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts b/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts new file mode 100644 index 000000000..4e8acbc80 --- /dev/null +++ b/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts @@ -0,0 +1,33 @@ +import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; + +const TABLE_NAME = 'Events'; + +export class AddDiscordAndGoogleCalendarEventUuidFields1710016392452 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumns(TABLE_NAME, [ + new TableColumn({ + name: 'discordEventUuid', + type: 'uuid', + isNullable: true, + }), + new TableColumn({ + name: 'googleCalendarEventUuid', + type: 'uuid', + isNullable: true, + }), + ]); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumns(TABLE_NAME, [ + new TableColumn({ + name: 'discordEventUuid', + type: 'uuid', + }), + new TableColumn({ + name: 'googleCalendarEventUuid', + type: 'uuid', + }), + ]); + } +} diff --git a/models/EventModel.ts b/models/EventModel.ts index 99f2d20ef..5c66820a9 100644 --- a/models/EventModel.ts +++ b/models/EventModel.ts @@ -63,6 +63,12 @@ export class EventModel extends BaseEntity { @OneToMany((type) => ExpressCheckinModel, (expressCheckin) => expressCheckin.event, { cascade: true }) expressCheckins: ExpressCheckinModel[]; + @Column('uuid') + discordEventUuid: Uuid; + + @Column('uuid') + googleCalendarEventUuid: Uuid; + public getPublicEvent(canSeeAttendanceCode = false): PublicEvent { const publicEvent: PublicEvent = { uuid: this.uuid, @@ -79,6 +85,8 @@ export class EventModel extends BaseEntity { pointValue: this.pointValue, requiresStaff: this.requiresStaff, staffPointBonus: this.staffPointBonus, + discordEventUuid: this.discordEventUuid, + googleCalendarEventUuid: this.googleCalendarEventUuid, }; if (canSeeAttendanceCode) publicEvent.attendanceCode = this.attendanceCode; return publicEvent; diff --git a/types/ApiRequests.ts b/types/ApiRequests.ts index 44447fb9e..080a4923c 100644 --- a/types/ApiRequests.ts +++ b/types/ApiRequests.ts @@ -146,6 +146,8 @@ export interface OptionalEventProperties { eventLink?: string; requiresStaff?: boolean; staffPointBonus?: number; + discordEventUuid?: Uuid; + googleCalendarEventUuid?: Uuid; } export interface Event extends OptionalEventProperties { diff --git a/types/ApiResponses.ts b/types/ApiResponses.ts index f449b2d5b..cc610d3df 100644 --- a/types/ApiResponses.ts +++ b/types/ApiResponses.ts @@ -117,6 +117,8 @@ export interface PublicEvent { pointValue: number; requiresStaff: boolean; staffPointBonus: number; + discordEventUuid: Uuid; + googleCalendarEventUuid: Uuid; } export interface GetPastEventsResponse extends ApiResponse { From 60a639f30a132d74092cefdb84c9f79fc3ff4e6e Mon Sep 17 00:00:00 2001 From: Eric Chang <55172722+echang594@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:43:50 -0800 Subject: [PATCH 2/6] Fix event model --- models/EventModel.ts | 4 ++-- tests/data/EventFactory.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/EventModel.ts b/models/EventModel.ts index 5c66820a9..7f2309264 100644 --- a/models/EventModel.ts +++ b/models/EventModel.ts @@ -63,10 +63,10 @@ export class EventModel extends BaseEntity { @OneToMany((type) => ExpressCheckinModel, (expressCheckin) => expressCheckin.event, { cascade: true }) expressCheckins: ExpressCheckinModel[]; - @Column('uuid') + @Column('uuid', { nullable: true }) discordEventUuid: Uuid; - @Column('uuid') + @Column('uuid', { nullable: true }) googleCalendarEventUuid: Uuid; public getPublicEvent(canSeeAttendanceCode = false): PublicEvent { diff --git a/tests/data/EventFactory.ts b/tests/data/EventFactory.ts index d07f523b3..1c66c9c43 100644 --- a/tests/data/EventFactory.ts +++ b/tests/data/EventFactory.ts @@ -41,6 +41,8 @@ export class EventFactory { deleted: false, eventLink: faker.internet.url(), thumbnail: FactoryUtils.getRandomImageUrl(), + discordEventUuid: uuid(), + googleCalendarEventUuid: uuid(), }); return EventModel.merge(fake, substitute); } From 7e508ccaa0a686e2439630cf19cc202b089308da Mon Sep 17 00:00:00 2001 From: Eric Chang <55172722+echang594@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:57:00 -0800 Subject: [PATCH 3/6] Made names less verbose --- api/validators/EventControllerRequests.ts | 4 ++-- ...dd-discord-and-google-calendar-event-uuid-fields.ts | 10 +++++----- models/EventModel.ts | 8 ++++---- tests/data/EventFactory.ts | 4 ++-- types/ApiRequests.ts | 4 ++-- types/ApiResponses.ts | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api/validators/EventControllerRequests.ts b/api/validators/EventControllerRequests.ts index 6e0e02232..1a8a13064 100644 --- a/api/validators/EventControllerRequests.ts +++ b/api/validators/EventControllerRequests.ts @@ -31,10 +31,10 @@ export class OptionalEventProperties implements IOptionalEventProperties { staffPointBonus?: number; @Allow() - discordEventUuid?: Uuid; + discordEvent?: Uuid; @Allow() - googleCalendarEventUuid?: Uuid; + googleCalendarEvent?: Uuid; } export class Event extends OptionalEventProperties implements IEvent { diff --git a/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts b/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts index 4e8acbc80..9a7627e85 100644 --- a/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts +++ b/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts @@ -2,16 +2,16 @@ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; const TABLE_NAME = 'Events'; -export class AddDiscordAndGoogleCalendarEventUuidFields1710016392452 implements MigrationInterface { +export class AddDiscordAndGoogleCalendarEventFields1710016392452 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.addColumns(TABLE_NAME, [ new TableColumn({ - name: 'discordEventUuid', + name: 'discordEvent', type: 'uuid', isNullable: true, }), new TableColumn({ - name: 'googleCalendarEventUuid', + name: 'googleCalendarEvent', type: 'uuid', isNullable: true, }), @@ -21,11 +21,11 @@ export class AddDiscordAndGoogleCalendarEventUuidFields1710016392452 implements public async down(queryRunner: QueryRunner): Promise { await queryRunner.dropColumns(TABLE_NAME, [ new TableColumn({ - name: 'discordEventUuid', + name: 'discordEvent', type: 'uuid', }), new TableColumn({ - name: 'googleCalendarEventUuid', + name: 'googleCalendarEvent', type: 'uuid', }), ]); diff --git a/models/EventModel.ts b/models/EventModel.ts index 7f2309264..a82cb3b69 100644 --- a/models/EventModel.ts +++ b/models/EventModel.ts @@ -64,10 +64,10 @@ export class EventModel extends BaseEntity { expressCheckins: ExpressCheckinModel[]; @Column('uuid', { nullable: true }) - discordEventUuid: Uuid; + discordEvent: Uuid; @Column('uuid', { nullable: true }) - googleCalendarEventUuid: Uuid; + googleCalendarEvent: Uuid; public getPublicEvent(canSeeAttendanceCode = false): PublicEvent { const publicEvent: PublicEvent = { @@ -85,8 +85,8 @@ export class EventModel extends BaseEntity { pointValue: this.pointValue, requiresStaff: this.requiresStaff, staffPointBonus: this.staffPointBonus, - discordEventUuid: this.discordEventUuid, - googleCalendarEventUuid: this.googleCalendarEventUuid, + discordEvent: this.discordEvent, + googleCalendarEvent: this.googleCalendarEvent, }; if (canSeeAttendanceCode) publicEvent.attendanceCode = this.attendanceCode; return publicEvent; diff --git a/tests/data/EventFactory.ts b/tests/data/EventFactory.ts index 1c66c9c43..cefd6d146 100644 --- a/tests/data/EventFactory.ts +++ b/tests/data/EventFactory.ts @@ -41,8 +41,8 @@ export class EventFactory { deleted: false, eventLink: faker.internet.url(), thumbnail: FactoryUtils.getRandomImageUrl(), - discordEventUuid: uuid(), - googleCalendarEventUuid: uuid(), + discordEvent: uuid(), + googleCalendarEvent: uuid(), }); return EventModel.merge(fake, substitute); } diff --git a/types/ApiRequests.ts b/types/ApiRequests.ts index 080a4923c..07b38377f 100644 --- a/types/ApiRequests.ts +++ b/types/ApiRequests.ts @@ -146,8 +146,8 @@ export interface OptionalEventProperties { eventLink?: string; requiresStaff?: boolean; staffPointBonus?: number; - discordEventUuid?: Uuid; - googleCalendarEventUuid?: Uuid; + discordEvent?: Uuid; + googleCalendarEvent?: Uuid; } export interface Event extends OptionalEventProperties { diff --git a/types/ApiResponses.ts b/types/ApiResponses.ts index cc610d3df..bd167addc 100644 --- a/types/ApiResponses.ts +++ b/types/ApiResponses.ts @@ -117,8 +117,8 @@ export interface PublicEvent { pointValue: number; requiresStaff: boolean; staffPointBonus: number; - discordEventUuid: Uuid; - googleCalendarEventUuid: Uuid; + discordEvent: Uuid; + googleCalendarEvent: Uuid; } export interface GetPastEventsResponse extends ApiResponse { From 5441ccf370641206fd544ac5b8b309fbb5da161e Mon Sep 17 00:00:00 2001 From: Eric Chang <55172722+echang594@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:42:29 -0700 Subject: [PATCH 4/6] Recreate migration --- ....ts => 0043-add-discord-and-google-calendar-event-fields.ts} | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename migrations/{0042-add-discord-and-google-calendar-event-uuid-fields.ts => 0043-add-discord-and-google-calendar-event-fields.ts} (92%) diff --git a/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts b/migrations/0043-add-discord-and-google-calendar-event-fields.ts similarity index 92% rename from migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts rename to migrations/0043-add-discord-and-google-calendar-event-fields.ts index 9a7627e85..efbbceb87 100644 --- a/migrations/0042-add-discord-and-google-calendar-event-uuid-fields.ts +++ b/migrations/0043-add-discord-and-google-calendar-event-fields.ts @@ -2,7 +2,7 @@ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; const TABLE_NAME = 'Events'; -export class AddDiscordAndGoogleCalendarEventFields1710016392452 implements MigrationInterface { +export class AddDiscordAndGoogleCalendarEventFields1711750534274 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.addColumns(TABLE_NAME, [ new TableColumn({ diff --git a/package.json b/package.json index 42b144b69..09b78f7de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@acmucsd/membership-portal", - "version": "3.4.1", + "version": "3.5.0", "description": "REST API for ACM UCSD's membership portal.", "main": "index.d.ts", "files": [ From ab67cf1ad6bc1d6c1c5e1f4d61194ee385a4cd66 Mon Sep 17 00:00:00 2001 From: Eric Chang <55172722+echang594@users.noreply.github.com> Date: Fri, 29 Mar 2024 23:14:30 -0700 Subject: [PATCH 5/6] Changed name from field to column --- ...ts => 0043-add-discord-and-google-calendar-event-columns.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename migrations/{0043-add-discord-and-google-calendar-event-fields.ts => 0043-add-discord-and-google-calendar-event-columns.ts} (88%) diff --git a/migrations/0043-add-discord-and-google-calendar-event-fields.ts b/migrations/0043-add-discord-and-google-calendar-event-columns.ts similarity index 88% rename from migrations/0043-add-discord-and-google-calendar-event-fields.ts rename to migrations/0043-add-discord-and-google-calendar-event-columns.ts index efbbceb87..0c1a4cded 100644 --- a/migrations/0043-add-discord-and-google-calendar-event-fields.ts +++ b/migrations/0043-add-discord-and-google-calendar-event-columns.ts @@ -2,7 +2,7 @@ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; const TABLE_NAME = 'Events'; -export class AddDiscordAndGoogleCalendarEventFields1711750534274 implements MigrationInterface { +export class AddDiscordAndGoogleCalendarEventColumns1711750534274 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.addColumns(TABLE_NAME, [ new TableColumn({ From c2e894749069fd6878648dd3abbc4e57ec1d4295 Mon Sep 17 00:00:00 2001 From: Eric Chang <55172722+echang594@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:10:24 -0700 Subject: [PATCH 6/6] Renumber migration --- ...ts => 0044-add-discord-and-google-calendar-event-columns.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename migrations/{0043-add-discord-and-google-calendar-event-columns.ts => 0044-add-discord-and-google-calendar-event-columns.ts} (88%) diff --git a/migrations/0043-add-discord-and-google-calendar-event-columns.ts b/migrations/0044-add-discord-and-google-calendar-event-columns.ts similarity index 88% rename from migrations/0043-add-discord-and-google-calendar-event-columns.ts rename to migrations/0044-add-discord-and-google-calendar-event-columns.ts index 0c1a4cded..3cb009c45 100644 --- a/migrations/0043-add-discord-and-google-calendar-event-columns.ts +++ b/migrations/0044-add-discord-and-google-calendar-event-columns.ts @@ -2,7 +2,7 @@ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; const TABLE_NAME = 'Events'; -export class AddDiscordAndGoogleCalendarEventColumns1711750534274 implements MigrationInterface { +export class AddDiscordAndGoogleCalendarEventColumns1712185658430 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.addColumns(TABLE_NAME, [ new TableColumn({