From 0b2064813dd0b812a2328d1373febd5fba60280e Mon Sep 17 00:00:00 2001 From: stanleymw <107821509+stanleymw@users.noreply.github.com> Date: Sat, 1 Nov 2025 16:58:01 -0400 Subject: [PATCH 1/2] add dining images to API --- src/containers/locationBuilder.ts | 8 ++++++++ src/types.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/containers/locationBuilder.ts b/src/containers/locationBuilder.ts index b67a1a8..c6f22c5 100644 --- a/src/containers/locationBuilder.ts +++ b/src/containers/locationBuilder.ts @@ -4,6 +4,7 @@ import type { Element } from "domhandler"; import { getTimeRangesFromString } from "./timeBuilder"; import { ICoordinate, ILocation, ISpecial, ITimeRange } from "../types"; import { sortAndMergeTimeRanges } from "utils/timeUtils"; +import assert from "assert"; /** * For building the location data structure @@ -19,6 +20,7 @@ export default class LocationBuilder { private url?: string; private location?: string; private menu?: string; + private image: URL; private coordinates?: ICoordinate; private acceptsOnlineOrders?: boolean; private times?: ITimeRange[]; @@ -71,6 +73,11 @@ export default class LocationBuilder { this.description = $("div.description p").text().trim(); this.menu = $("div.navItems > a#getMenu").attr("href"); this.location = $("div.location a").text().trim(); + + const conceptImageUrl = $(".conceptImage").children("img").first().prop("src"); + assert(conceptImageUrl != undefined, `concept ${this.url} did not have a Concept Image!`) + this.image = new URL(conceptImageUrl); + this.acceptsOnlineOrders = $("div.navItems.orderOnline").toArray().length > 0; @@ -121,6 +128,7 @@ export default class LocationBuilder { url: this.url, location: this.location, menu: this.menu, + image: this.image, coordinates: this.coordinates, acceptsOnlineOrders: this.acceptsOnlineOrders, times: this.times, diff --git a/src/types.ts b/src/types.ts index 0a5cef5..7a32421 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,6 +5,7 @@ export interface ILocation { description: string; url: string; menu?: string; + image: URL; location: string; coordinates?: ICoordinate; acceptsOnlineOrders: boolean; From c0637b6779b1a892e5b94909e3ec7c668af1520b Mon Sep 17 00:00:00 2001 From: stanleymw <107821509+stanleymw@users.noreply.github.com> Date: Sat, 1 Nov 2025 17:07:59 -0400 Subject: [PATCH 2/2] fix --- src/containers/locationBuilder.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/containers/locationBuilder.ts b/src/containers/locationBuilder.ts index c6f22c5..7e55d84 100644 --- a/src/containers/locationBuilder.ts +++ b/src/containers/locationBuilder.ts @@ -4,7 +4,6 @@ import type { Element } from "domhandler"; import { getTimeRangesFromString } from "./timeBuilder"; import { ICoordinate, ILocation, ISpecial, ITimeRange } from "../types"; import { sortAndMergeTimeRanges } from "utils/timeUtils"; -import assert from "assert"; /** * For building the location data structure @@ -20,7 +19,7 @@ export default class LocationBuilder { private url?: string; private location?: string; private menu?: string; - private image: URL; + private image?: URL; private coordinates?: ICoordinate; private acceptsOnlineOrders?: boolean; private times?: ITimeRange[]; @@ -75,8 +74,8 @@ export default class LocationBuilder { this.location = $("div.location a").text().trim(); const conceptImageUrl = $(".conceptImage").children("img").first().prop("src"); - assert(conceptImageUrl != undefined, `concept ${this.url} did not have a Concept Image!`) - this.image = new URL(conceptImageUrl); + // assert(conceptImageUrl != undefined, `concept ${this.url} did not have a Concept Image!`) + this.image = conceptImageUrl ? new URL(conceptImageUrl) : undefined; this.acceptsOnlineOrders = $("div.navItems.orderOnline").toArray().length > 0; @@ -109,7 +108,8 @@ export default class LocationBuilder { this.url === undefined || this.location === undefined || this.conceptId === undefined || - this.name === undefined + this.name === undefined || + this.image === undefined ) { throw Error( "Didn't finish configuring location before building metadata!"