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

added food field to events table #456

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions api/validators/EventControllerRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class OptionalEventProperties implements IOptionalEventProperties {

@Allow()
googleCalendarEvent?: Uuid;

@Allow()
food?: string;
}

export class Event extends OptionalEventProperties implements IEvent {
Expand Down
24 changes: 24 additions & 0 deletions migrations/0046-add-food-column.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

const TABLE_NAME = 'Events';

export class AddFoodColumn1728959627663 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.addColumns(TABLE_NAME, [
newracket marked this conversation as resolved.
Show resolved Hide resolved
new TableColumn({
name: 'food',
type: 'varchar(255)',
isNullable: true,
}),
]);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumns(TABLE_NAME, [
new TableColumn({
name: 'food',
type: 'varchar(255)',
}),
]);
}
}
4 changes: 4 additions & 0 deletions models/EventModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class EventModel extends BaseEntity {
@Column('varchar', { nullable: true })
googleCalendarEvent: Uuid;

@Column('varchar', { nullable: true })
food: string;
newracket marked this conversation as resolved.
Show resolved Hide resolved

public getPublicEvent(canSeeAttendanceCode = false): PublicEvent {
const publicEvent: PublicEvent = {
uuid: this.uuid,
Expand All @@ -91,6 +94,7 @@ export class EventModel extends BaseEntity {
staffPointBonus: this.staffPointBonus,
discordEvent: this.discordEvent,
googleCalendarEvent: this.googleCalendarEvent,
food: this.food,
};
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.6.2",
"version": "3.6.3",
newracket marked this conversation as resolved.
Show resolved Hide resolved
"description": "REST API for ACM UCSD's membership portal.",
"main": "index.d.ts",
"files": [
Expand Down
1 change: 1 addition & 0 deletions tests/Seeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ async function seed(): Promise<void> {
...EventFactory.daysBefore(6),
attendanceCode: 'galaxybrain',
...staffed,
food: 'Boba',
});
const PAST_HACK_WORKSHOP = EventFactory.fake({
title: 'Hack: Intro to Rust',
Expand Down
1 change: 1 addition & 0 deletions tests/data/EventFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class EventFactory {
thumbnail: FactoryUtils.getRandomImageUrl(),
discordEvent: faker.datatype.hexaDecimal(10),
googleCalendarEvent: faker.datatype.hexaDecimal(10),
food: null,
});
return EventModel.merge(fake, substitute);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('event creation', () => {
start: moment().subtract(2, 'hour').toDate(),
end: moment().subtract(1, 'hour').toDate(),
attendanceCode: 'p4rty',
food: 'Boba',
pointValue: 10,
};

Expand All @@ -57,6 +58,7 @@ describe('event creation', () => {
expect(eventResponse.event.committee).toEqual(event.committee);
expect(eventResponse.event.start).toEqual(event.start);
expect(eventResponse.event.end).toEqual(event.end);
expect(eventResponse.event.food).toEqual(event.food);
expect(eventResponse.event.pointValue).toEqual(event.pointValue);

// verifying response from event lookup
Expand All @@ -83,6 +85,7 @@ describe('event creation', () => {
start: moment().subtract(2, 'hour').toDate(),
end: moment().subtract(1, 'hour').toDate(),
attendanceCode: 'p4rty',
food: '',
pointValue: 10,
};

Expand Down Expand Up @@ -114,6 +117,7 @@ describe('event creation', () => {
start: moment().subtract(1, 'hour').toDate(),
end: moment().subtract(2, 'hour').toDate(),
attendanceCode: 'p4rty',
food: null,
pointValue: 10,
};

Expand Down
1 change: 1 addition & 0 deletions tests/merchOrder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ describe('merch order pickup events', () => {

const persistedPickupEvent = await conn.manager.findOne(OrderPickupEventModel,
{ relations: ['orders', 'linkedEvent'] });

expect(persistedPickupEvent).toStrictEqual(pickupEvent);

// edit a linked event
Expand Down
1 change: 1 addition & 0 deletions types/ApiRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export interface OptionalEventProperties {
staffPointBonus?: number;
discordEvent?: Uuid;
googleCalendarEvent?: Uuid;
food?: string;
}

export interface Event extends OptionalEventProperties {
Expand Down
1 change: 1 addition & 0 deletions types/ApiResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export interface PublicEvent {
staffPointBonus: number;
discordEvent: Uuid;
googleCalendarEvent: Uuid;
food: string;
}

export interface GetPastEventsResponse extends ApiResponse {
Expand Down
Loading