Skip to content

TIG-306: Add location and event similarity signals to the For You feed - #65

Merged
yubimamiya merged 4 commits into
stagingfrom
rohan-TIG306-11-01-2026
Nov 15, 2026
Merged

yubimamiya merged 4 commits into
stagingfrom
rohan-TIG306-11-01-2026

Conversation

@rohanmatta11

@rohanmatta11 rohanmatta11 commented Nov 7, 2026 •

Copy link
Copy Markdown

Summary

Complete the recommendation algorithm by ranking events using students’ preferred campus areas and similarity to their saved/RSVP’d events.

  • Places frequented: Add a nullable area column to campus_locations and a 1.5-point boost when a venue matches a user’s selected areas.
  • Similarity to My Events: Average existing 1536-dimensional tag embeddings into event vectors, then average distinct saved/RSVP’d event vectors into a user profile. Cosine similarity contributes up to 3 points.
  • Candidate retrieval: Include preferred-area and semantically related events in the personalized expansion when the candidate pool reaches its cap.
  • Cold starts: Missing preferences, history, areas, or usable embeddings contribute zero to the new signals.

Data and sync

  • Assign venue areas during Forum’s location sync and seeding, using known venue IDs, normalized names, and geographic fallbacks.
  • Add an idempotent db:setup-recommendations command to populate tag embeddings and backfill areas, with --dry-run support.
  • Preserve published imported events after natural expiration so their saves/RSVPs continue informing recommendations. Withdrawn, duplicate, and no-longer-publishable events still become drafts.
  • Existing drafts are not automatically restored because their unpublication reason isn’t recorded.
    InboxEngine’s implementation and submodule reference are unchanged. No new embedding service or per-event embedding storage is required.

Validation

  • 27 unit tests passed for scoring, vector math, cold starts, missing data, and real venue mappings.
  • 4 database integration tests passed for setup, sync lifecycle, personalized ordering, pagination, and candidate expansion.
  • TypeScript checks for both apps and Biome passed.
  • The area migration applied successfully to a fresh disposable database.

Deployment

Recommendation setup now runs automatically on every staging and production deploy. deploy/build-release.sh bundles tools/setup-recommendations.js and includes tools/seeddata/eventTags_embeddings.json at the runtime path the script expects.

deploy/run-release.sh runs migrations, then recommendation setup using the same shared/environment file, before switching the current release. Setup upserts all tag embeddings and backfills venue areas in an idempotent transaction. A setup failure aborts deployment before traffic switches; already-applied migrations are not rolled back. No manual production setup command is required. Subsequent InboxEngine syncs assign areas to incoming venues.

Local verification

  • Built the merged web app and ran deploy/build-release.sh locally to produce a release tarball.
  • Extracted the tarball and confirmed tools/setup-recommendations.js and its tools/seeddata/eventTags_embeddings.json exist; the packaged JSON matches the source file.
  • Applied migrations from the extracted release to a fresh disposable local database.
  • Ran the extracted bundled setup from an unrelated working directory using --env-file, with NODE_ENV=production. It found its JSON, loaded all 22 embeddings (1536 dimensions each), mapped the test venues correctly, and exited with code 0.
  • Ran the bundled setup again: exit code 0, identical embedding checksum and venue mappings, no duplicate embedding rows, and no users or events created.
  • Web build, lint, shell syntax checks for both release scripts, and git diff --check passed.

https://github.com/user-attachments/assets/4168c891-0260-4d97-8a22-f55fadbb003d
https://github.com/user-attachments/assets/b34379fe-21f1-43a8-ae5a-4cb94e4b8c00

@linear

linear Bot commented Nov 7, 2026

Copy link
Copy Markdown

TIG-306

@yubimamiya

Copy link
Copy Markdown

The deploy already applies migration 0007 on its own: deploy/run-release.sh runs tools/migrate.js before switching traffic, and the post-deploy sync fills in area for synced venues. One step is still manual, though. db:setup-recommendations isn't in the release package, so staging and production never get event_tag_embeddings loaded, and the similarity signal will score 0 for everyone there.

Since the script is safe to re-run, could you run it on every deploy?

deploy/build-release.sh, next to the other tools:

bun build "$root/apps/database/src/setup-recommendations.ts" --target=bun --outfile "$stage/tools/setup-recommendations.js" >/dev/null
mkdir -p "$stage/tools/seeddata"
cp "$root/apps/database/src/seeddata/eventTags_embeddings.json" "$stage/tools/seeddata/"

(The script reads ${import.meta.dir}/seeddata/eventTags_embeddings.json at runtime, so once it's bundled into tools/, the JSON has to sit at tools/seeddata/. Alternatively, switch to a static JSON import so it's bundled inline.)

deploy/run-release.sh, right after the migrate line:

"$bun" --env-file="$root/shared/environment" "$dir/tools/setup-recommendations.js"

It runs before traffic moves, so a failure aborts the deploy and the current release keeps serving. Please also update the Deployment section of the PR description and docs/ranking.md so they no longer list it as a manual step, and mention that you checked it with deploy/build-release.sh locally (the bundled script finds the JSON and exits 0) after you check it.

Otherwise this looks good to me, thanks so much!

@rohanmatta11

Copy link
Copy Markdown
Author

Changed it so that the recommendation setup now runs automatically after migrations and before switching releases and updated the docs

@yubimamiya
yubimamiya merged commit 190f74f into staging Nov 15, 2026
1 check passed
@yubimamiya
yubimamiya deleted the rohan-TIG306-11-01-2026 branch November 15, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants