Skip to content

Commit e218dc5

Browse files
committed
Added late night to event types mapper
1 parent e6eb39e commit e218dc5

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

prisma/mappers.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import type { RawCampusArea, RawEateryType, RawPayMethod } from './scraperTypes.js';
2-
31
import {
42
CampusArea,
53
EateryType,
64
EventType,
75
PaymentMethod,
86
} from '@prisma/client';
9-
import { EATERY_IMAGES_BASE_URL, Weekday, WEEKDAY_TO_DAY_OF_WEEK } from '../src/constants.js';
7+
8+
import {
9+
EATERY_IMAGES_BASE_URL,
10+
WEEKDAY_TO_DAY_OF_WEEK,
11+
Weekday,
12+
} from '../src/constants.js';
13+
import type {
14+
RawCampusArea,
15+
RawEateryType,
16+
RawPayMethod,
17+
} from './scraperTypes.js';
1018

1119
export function mapCampusArea(area: RawCampusArea): CampusArea {
1220
// Only consider descrshort for mapping
@@ -54,7 +62,7 @@ export function mapEateryType(type: RawEateryType): EateryType {
5462
case 'Dining Room':
5563
return EateryType.DINING_ROOM;
5664
case 'Cafe':
57-
return EateryType.CAFE;
65+
return EateryType.CAFE;
5866
case 'Coffee Shop':
5967
return EateryType.COFFEE_SHOP;
6068
case 'Food Court':
@@ -67,7 +75,7 @@ export function mapEateryType(type: RawEateryType): EateryType {
6775
return EateryType.GENERAL;
6876
default:
6977
throw new Error(`Unknown eatery type: ${type.descr}`);
70-
}
78+
}
7179
}
7280

7381
export function mapEventType(eventDescription: string): EventType {
@@ -80,6 +88,8 @@ export function mapEventType(eventDescription: string): EventType {
8088
return EventType.BRUNCH;
8189
case 'Dinner':
8290
return EventType.DINNER;
91+
case 'Late Night':
92+
return EventType.LATE_NIGHT;
8393
case '':
8494
// Could be empty string in the case of general events (e.g. Amit Bhatia Libe Cafe since it serves all day)
8595
return EventType.EMPTY;
@@ -90,7 +100,7 @@ export function mapEventType(eventDescription: string): EventType {
90100
case 'Open':
91101
return EventType.OPEN;
92102
case 'Pants':
93-
return EventType.PANTS;
103+
return EventType.PANTS; // pants
94104
case 'General':
95105
return EventType.GENERAL;
96106
case 'Free Food':
@@ -167,15 +177,19 @@ export function parseTime(timeStr: string): { hours: number; minutes: number } {
167177
return { hours: hours ?? 0, minutes: minutes ?? 0 };
168178
}
169179

170-
export function createWeeklyDate(weekday: string, timeStr: string, baseDate: Date = new Date()): Date {
180+
export function createWeeklyDate(
181+
weekday: string,
182+
timeStr: string,
183+
baseDate: Date = new Date(),
184+
): Date {
171185
const dayOfWeek = weekdayToDayOfWeek(weekday);
172186
const { hours, minutes } = parseTime(timeStr);
173187
const date = new Date(baseDate);
174188
const currentDay = date.getDay();
175189
const daysUntilTarget = (dayOfWeek - currentDay + 7) % 7;
176-
190+
177191
date.setDate(date.getDate() + daysUntilTarget);
178192
date.setHours(hours, minutes, 0, 0);
179-
193+
180194
return date;
181-
}
195+
}

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum EventType {
4040
BREAKFAST
4141
BRUNCH
4242
DINNER
43+
LATE_NIGHT
4344
EMPTY
4445
LATE_LUNCH
4546
LUNCH

0 commit comments

Comments
 (0)