Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build & Push and Deploy to dev for eatery-blue-backend
name: Docker Build & Push and Deploy to dev for eatery-backend

on:
push:
Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:
context: ./
file: ./Dockerfile
push: true
tags: cornellappdev/eatery-blue-dev:${{ steps.vars.outputs.sha_short }}
tags: cornellappdev/eatery-dev:${{ steps.vars.outputs.sha_short }}

- name: Remote SSH and Deploy
uses: appleboy/ssh-action@v1.0.3
Expand All @@ -45,7 +45,7 @@ jobs:
script: |
export IMAGE_TAG=${{ steps.vars.outputs.sha_short }}
cd docker-compose
docker stack rm thestack
docker-compose down
sleep 20s
docker stack deploy -c docker-compose.yml thestack
docker-compose up -d
yes | docker system prune -a
12 changes: 10 additions & 2 deletions prisma/scraper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromZonedTime } from 'date-fns-tz';
import 'dotenv/config';
import { readFileSync } from 'fs';
import cron from 'node-cron';
Expand All @@ -11,6 +12,7 @@ import {
} from '@prisma/client';

import { DEFAULT_IMAGE_URL } from '../src/constants.js';
import { TimeZone } from '../src/constants.js';
import {
createWeeklyDate,
mapCampusArea,
Expand Down Expand Up @@ -197,8 +199,14 @@ function transformStaticEatery(rawStaticEatery: RawStaticEatery) {

for (const operatingHour of rawStaticEatery.operatingHours) {
for (const event of operatingHour.events) {
const startDate = createWeeklyDate(operatingHour.weekday, event.start);
const endDate = createWeeklyDate(operatingHour.weekday, event.end);
const startDate = fromZonedTime(
createWeeklyDate(operatingHour.weekday, event.start),
TimeZone.EASTERN,
);
const endDate = fromZonedTime(
createWeeklyDate(operatingHour.weekday, event.end),
TimeZone.EASTERN,
);

if (endDate < startDate) {
endDate.setDate(endDate.getDate() + 1);
Expand Down
7 changes: 0 additions & 7 deletions src/middleware/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export const requireAuth = (
_res: Response,
next: NextFunction,
) => {
// Development bypass
if (process.env.NODE_ENV === 'development') {
req.user = {
userId: 1,
};
return next();
}

const authHeader = req.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ')) {
Expand Down
22 changes: 14 additions & 8 deletions src/users/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export const getFavoriteMatches = async (
const { favoritedItemNames } = user;

if (favoritedItemNames.length === 0) {
return res.json({});
return res.json([]);
}

const { start, end } = getTodayTimeWindow();
Expand Down Expand Up @@ -271,7 +271,10 @@ export const getFavoriteMatches = async (
});

// Format the response
const matches: Record<string, { name: string; events: EventType[] }[]> = {};
const matches: {
eateryName: string;
items: { name: string; events: EventType[] }[];
}[] = [];
const userFavoritesSet = new Set(favoritedItemNames);

for (const eatery of eateries) {
Expand All @@ -292,12 +295,15 @@ export const getFavoriteMatches = async (
}

if (itemToEventsMap.size > 0) {
matches[eatery.name] = Array.from(itemToEventsMap.entries()).map(
([itemName, eventSet]) => ({
name: itemName,
events: Array.from(eventSet).sort(),
}),
);
matches.push({
eateryName: eatery.name,
items: Array.from(itemToEventsMap.entries()).map(
([itemName, eventSet]) => ({
name: itemName,
events: Array.from(eventSet).sort(),
}),
),
});
}
}

Expand Down
Loading