Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Discord and Google Calendar Event ID columns #415

Merged
merged 9 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/validators/EventControllerRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
PatchEventRequest as IPatchEventRequest,
SubmitEventFeedbackRequest as ISubmitEventFeedbackRequest,
Event as IEvent,
Uuid,
} from '../../types';
import { IsValidEventFeedback } from '../decorators/Validators';

Expand All @@ -28,6 +29,12 @@ export class OptionalEventProperties implements IOptionalEventProperties {

@Allow()
staffPointBonus?: number;

@Allow()
discordEvent?: Uuid;

@Allow()
googleCalendarEvent?: Uuid;
}

export class Event extends OptionalEventProperties implements IEvent {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

const TABLE_NAME = 'Events';

export class AddDiscordAndGoogleCalendarEventColumns1712185658430 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.addColumns(TABLE_NAME, [
new TableColumn({
name: 'discordEvent',
type: 'uuid',
isNullable: true,
}),
new TableColumn({
name: 'googleCalendarEvent',
type: 'uuid',
isNullable: true,
}),
]);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumns(TABLE_NAME, [
new TableColumn({
name: 'discordEvent',
type: 'uuid',
}),
new TableColumn({
name: 'googleCalendarEvent',
type: 'uuid',
}),
]);
}
}
8 changes: 8 additions & 0 deletions models/EventModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class EventModel extends BaseEntity {
@OneToMany((type) => ExpressCheckinModel, (expressCheckin) => expressCheckin.event, { cascade: true })
expressCheckins: ExpressCheckinModel[];

@Column('uuid', { nullable: true })
discordEvent: Uuid;

@Column('uuid', { nullable: true })
googleCalendarEvent: Uuid;

public getPublicEvent(canSeeAttendanceCode = false): PublicEvent {
const publicEvent: PublicEvent = {
uuid: this.uuid,
Expand All @@ -83,6 +89,8 @@ export class EventModel extends BaseEntity {
pointValue: this.pointValue,
requiresStaff: this.requiresStaff,
staffPointBonus: this.staffPointBonus,
discordEvent: this.discordEvent,
googleCalendarEvent: this.googleCalendarEvent,
};
if (canSeeAttendanceCode) publicEvent.attendanceCode = this.attendanceCode;
return publicEvent;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acmucsd/membership-portal",
"version": "3.5.1",
"version": "3.6.0",
"description": "REST API for ACM UCSD's membership portal.",
"main": "index.d.ts",
"files": [
Expand Down
2 changes: 2 additions & 0 deletions tests/data/EventFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class EventFactory {
deleted: false,
eventLink: faker.internet.url(),
thumbnail: FactoryUtils.getRandomImageUrl(),
discordEvent: uuid(),
googleCalendarEvent: uuid(),
});
return EventModel.merge(fake, substitute);
}
Expand Down
2 changes: 2 additions & 0 deletions types/ApiRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export interface OptionalEventProperties {
eventLink?: string;
requiresStaff?: boolean;
staffPointBonus?: number;
discordEvent?: Uuid;
googleCalendarEvent?: Uuid;
}

export interface Event extends OptionalEventProperties {
Expand Down
2 changes: 2 additions & 0 deletions types/ApiResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export interface PublicEvent {
pointValue: number;
requiresStaff: boolean;
staffPointBonus: number;
discordEvent: Uuid;
googleCalendarEvent: Uuid;
}

export interface GetPastEventsResponse extends ApiResponse {
Expand Down
Loading