Skip to content

Commit

Permalink
added food field to events table (#456)
Browse files Browse the repository at this point in the history
* added food field to events table

* fixed lint errors

* updated api version

* fixed version, changed food to foodItems

* fix lint error
  • Loading branch information
newracket authored Oct 25, 2024
1 parent 2d73efb commit ff05d6b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 1 deletion.
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()
foodItems?: string;
}

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

const TABLE_NAME = 'Events';

export class AddFoodItemsColumn1728959627663 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.addColumn(TABLE_NAME,
new TableColumn({
name: 'foodItems',
type: 'varchar(255)',
isNullable: true,
}));
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn(TABLE_NAME,
new TableColumn({
name: 'foodItems',
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 })
foodItems: string;

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,
foodItems: this.foodItems,
};
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.7.0",
"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,
foodItems: '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),
foodItems: 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',
foodItems: '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.foodItems).toEqual(event.foodItems);
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',
foodItems: '',
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',
foodItems: 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;
foodItems?: 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;
foodItems: string;
}

export interface GetPastEventsResponse extends ApiResponse {
Expand Down

0 comments on commit ff05d6b

Please sign in to comment.