Feat: bypass google account picker on sign in #261
No reviewers
Labels
No labels
bootcamp
bug
codebase
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
high priority
invalid
javascript
outdated
question
typescript
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ScottyLabs/dining-api!261
Loading…
Reference in a new issue
No description provided.
Delete branch "staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Also adds report data on both the primary
v2/locationsendpoint and a new endpoint for fetching the reports of a single locationPull request overview
The PR's stated goal is to bypass the Google account picker on sign-in by removing the
prompt: "select_account"parameter and adding anhd: "andrew.cmu.edu"hosted-domain hint to the OIDC authorization URL. However, it also includes a sizable set of unrelated changes: a newQueryUtils.getReportsAfterquery helper, a refactor of the/v2/locations/:locationId/reportsendpoint to use it with a 1-day window, a newreportCountfield on the locations API response, a newpnpm-workspace.yaml, and pure formatting churn inauth.ts(trailing commas).Changes:
prompt: "select_account"withhd: "andrew.cmu.edu"in the OIDC auth URL.QueryUtils.getReportsAfter, wire it into the reports endpoint and intogetAllLocationsFromDBto expose a newreportCountper location.pnpm-workspace.yamlworkspace config and apply formatting tweaks acrossauth.ts.Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 14 comments.
Show a summary per file
prompt: "select_account"forhd: "andrew.cmu.edu"; otherwise formatting-only edits./v2/locations/:locationId/reportsto useQueryUtils.getReportsAfterwith a 1-day window; leaves several unused imports.getReportsAfter(start_time, for_location_id?)helper usinggt+ optionaleqfilter onreportsTable.timeSearchCutoff, aggregate by location, attachreportCountto each location object.packages: [.]andstrictDepBuilds: false.Comments suppressed due to low confidence (1)
src/endpoints/reviews.ts:154
createdAt: t.Date(), butgetReportsAfterreturns rows fromreportsTabledirectly, which typically yields a JSDatefrom drizzle but serializes over HTTP as an ISO string or number depending on the schema column type. Please double‑check that thereportsTable.createdAtcolumn type produces a value compatible witht.Date()(Elysia validates outgoing payloads), otherwise responses may fail validation at runtime. Note the other endpoint above usescreatedAt: t.Number()for review timestamps — confirm the inconsistency is intentional.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -1,4 +1,4 @@import { avg, count, sql } from "drizzle-orm";import { avg, count, gt, sql } from "drizzle-orm";import {getReportsAfterusesandandeqfrom drizzle-orm, but onlygtwas added to the import on line 1. This works only becauseandandeqhappen to be imported on line 17 via a second drizzle-orm import statement. For consistency and to avoid two import statements from the same module, consolidate the drizzle-orm imports into a single line (and addgtto that line) instead of maintaining two.The new public method uses snake_case parameter names (
start_time,for_location_id), which is inconsistent with the rest of the codebase (and the rest of this class) which uses camelCase — e.g.todayAsSQLString,timeSearchCutoffStr,locationId. Please rename tostartTimeandforLocationId(or simplylocationId).for_location_idis typed asstring | undefined, but an empty string""is also falsy in the ternaryfor_location_id ? eq(...) : undefined. If a caller ever passes an empty string (e.g. from a route param), the filter will be silently dropped and all reports across all locations will be returned. Prefer an explicitfor_location_id !== undefinedcheck.Indentation in this method is 6 spaces / inconsistent with the rest of the class which uses 2-space indentation (see
getSpecials,getLocationIdToDataMapbelow). Please reformat to match.The new
/v2/locations/:locationId/reportsbehavior and the newreportCountfield added togetAllLocationsFromDBare not covered by any tests in this PR. Given the time-window logic (1‑day cutoff usingDateTime.now()vs. atodayparameter ingetLocations.ts), this is exactly the kind of code that benefits from at least one unit test.@ -21,4 +21,4 @@const generalOverrides = await DB.getGeneralOverrides();const { idToPointOverrides, idToWeeklyOverrides } = await DB.getTimeOverrides(timeSearchCutoff.toSQLDate(),);let reportCountsis never reassigned and should beconst, matching the rest of this file which usesconstexclusively (e.g.timeSearchCutoff,DB,locationIdToData,reports,finalLocationData). The same applies tolet amtinside the reducer — it is mutated only via the subsequentacc[...]assignment, not the variable itself, so it should also beconst.timeSearchCutoffistoday.minus({ days: 1 })— i.e. 1 day before "today". Passing this togetReportsAfterwill count every report created in the last day plus everything older than that as well from "today minus 1 day" forward. Given that the comment on line 14 says "1 day's worth of data before today" (intended for time slot lookback), this same cutoff is probably not what you want forreportCount. If the intent is "reports filed in the last 24 hours", passtoday.minus({ days: 1 }).toJSDate()explicitly, but be aware that today is aDateTimein some local zone, so the JSDateboundary may not match the report-window semantics shown inreviews.ts(which usesDateTime.now()). Please confirm intended window.@ -49,3 +58,4 @@todaysSoups: specials[id]?.soups ?? [],todaysSpecials: specials[id]?.specials ?? [],reportCount: reportCounts[id] ?? 0,};Missing trailing semicolons and a trailing comma on the new
reportCount: reportCounts[id] ?? 0property compared to the surrounding object entries (other lines all terminate with a comma). The block also has formatting drift (no semicolons on lines 35, 38). Please run the project's formatter to keep the file consistent.Adding
reportCountto the location object is a public API change to the locations response. Any downstream consumer / TypeScript client / Elysia response schema for this endpoint should be updated to include the new field; otherwise consumers either miss the field or strict response validation may reject the payload. Please verify the corresponding response schema for the locations endpoint is updated.@ -35,7 +36,7 @@ authEndpoints.get({Rather than leaving
prompt: "select_account"commented out, the line should be deleted. Dead/commented-out code accumulates and obscures intent — version control already preserves the prior behavior.@ -35,7 +36,7 @@ authEndpoints.get({query: t.Object({ redirectURL: t.Nullable(t.String()) }),Setting
hd: "andrew.cmu.edu"is a Google-specific authorization parameter that restricts sign-in to users in that hosted domain. The inline comment itself acknowledges uncertainty ("idk if this excludes cmu.edu emails..."). Per Google's documentation,hdrestricts to a single domain; users with@cmu.edu(faculty/staff) or alumni addresses will be blocked from logging in. Please verify the actual domain(s) issued by the upstream IdP (login.cmu.edu) before merging, and resolve the uncertainty in the comment rather than shipping it. If the OIDC provider is login.cmu.edu rather than Google directly,hdmay also be silently ignored.@ -10,7 +9,8 @@ import {updateTagReview,} from "db/reviews";import { db } from "db/db";andandgtare imported here but never used in this file (the previous directeq(reportsTable.locationId, ...)query has been moved intoQueryUtils.getReportsAfter). Additionally,reportsTable(line 13) is no longer referenced anywhere in this file after the refactor. Please drop these unused imports.@ -132,4 +132,4 @@).get("/v2/locations/:locationId/reports",async ({ params: { locationId } }) => {The PR title and description indicate this PR is about bypassing the Google account picker on sign-in, but it also contains substantial unrelated changes: a new
getReportsAfterquery utility, refactoring of the/v2/locations/:locationId/reportsendpoint to filter by a 1‑day window, and a newreportCountfield added to the locations API response. These should likely be split into a separate PR (or the description updated) so the change set is reviewable and revertable independently.Several stylistic deviations from the surrounding file:
letis used for variables that are never reassigned (yesterday,ret) —constis the convention elsewhere in this file. The endpoint also lacks trailing semicolons on lines 138 and 140 and uses an awkward(new QueryUtils(db)).getReportsAfter(...)rather than just calling a helper or constructing it on a separate line. Considerconst reports = await new QueryUtils(db).getReportsAfter(yesterday.toJSDate(), locationId);and returningreportsdirectly.Coverage Report
File Coverage