Skip to content

Commit

Permalink
add term to custom events on backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Slo1k committed Jan 7, 2025
1 parent 11a89f3 commit 074d013
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/antalmanac/tests/custom-events.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest';
import { RepeatingCustomEvent, RepeatingCustomEventSchema } from '@packages/antalmanac-types';
import { describe, test, expect } from 'vitest';

describe('Custom Events', () => {
const customEvent: RepeatingCustomEvent = {
Expand All @@ -10,6 +10,7 @@ describe('Custom Events', () => {
customEventID: 999,
color: 'placeholderColor',
building: undefined,
term: '2023 Fall',
};

test('schema does not throw error when building property exists and is undefined', async () => {
Expand Down
1 change: 1 addition & 0 deletions apps/antalmanac/tests/download-ics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('download-ics', () => {
isCustomEvent: true,
days: ['M', 'W', 'F'],
building: 'placeholderCustomEventBuilding',
term: '2023 Fall', // Cannot be a random placeholder; it has to be in `quarterStartDates` otherwise it'll be undefined
},
];

Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/db/schema/schedule/custom_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const customEvents = pgTable(
building: text('building'),

lastUpdated: timestamp('last_updated', { withTimezone: true }).defaultNow(),

term: text('term'),
}
);

Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/lib/rds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export class RDS {
color: event.color,
building: event.building,
lastUpdated: new Date(),
term: event.term
}));

await db.transaction(async (tx) => await tx.insert(customEvents).values(dbCustomEvents));
Expand Down Expand Up @@ -328,6 +329,7 @@ export class RDS {
days: customEvent.days.split('').map((day) => day === '1'),
color: customEvent.color ?? undefined,
building: customEvent.building ?? undefined,
term: customEvent.term ?? undefined,
});
}

Expand Down

0 comments on commit 074d013

Please sign in to comment.