Skip to content

feat: add weighted global Surprise Me - #19

Merged
Vardhan-IMMIDI merged 3 commits into
mainfrom
fix/global-surprise-me
Aug 31, 2026
Merged

Vardhan-IMMIDI merged 3 commits into
mainfrom
fix/global-surprise-me

Conversation

@varma1221

Copy link
Copy Markdown
Collaborator

Summary

  • Add a global Surprise me action to the home page.
  • Preserve the existing company-page Surprise me behavior and keep it scoped to the current company and filters.
  • Add build-time weighted-random question selection across the complete dataset.
  • Remove the dice emoji from the company-page action.

Selection logic

The build pipeline now derives a company weight from the sum of available per-question frequencies, using a question-count fallback when a frequency is unavailable. Each unique question receives a question weight based on the combined weights of the distinct companies that list it. The final selection weight uses log1p(questionWeight) so every question remains eligible while highly cross-company questions receive higher odds without completely dominating the result.

The generated global payload is stored in site/public/data/global-surprise.json, avoiding runtime data-source requests.

Validation

The build-time generator prints the top 20 questions by final weight to the console for temporary ranking validation. A dedicated debug endpoint was not added. The new generated payload is covered by static-data validation.

Checks completed successfully:

  • npm run type-check
  • npm run lint
  • npm run validate
  • npm run test:validation
  • npm run build

The production build generated 662 static pages successfully.

Manual testing

  • Verified the home-page global action opens questions from the complete dataset.
  • Verified the question details panel displays correctly.
  • Verified the company-page action remains company-specific and respects filters.
  • Verified the dice emoji is removed.
  • Verified the new action remains usable at a narrow mobile viewport.

Closes #18

@varma1221
varma1221 requested review from Vardhan-IMMIDI and a lite review from Copilot August 30, 2026 11:27
@varma1221 varma1221 self-assigned this Aug 30, 2026
@varma1221 varma1221 added bug Something isn't working enhancement New feature or request labels Aug 30, 2026
@vercel

vercel Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
by-company Ready Ready Preview Aug 31, 2026 7:09am

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The generated global payload currently stores an order-dependent per-company frequency for each question (misleading in the global context), and the new global-surprise validation path lacks corresponding test coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new global “Surprise me” entry point on the home page that selects a weighted-random question from the entire dataset using a build-generated index, while keeping the existing company-page “Surprise me” scoped to the current company/filters and cleaning up its UI.

Changes:

  • Introduces a home-page GlobalSurpriseMe client component that fetches and selects from global-surprise.json using weighted randomness.
  • Extends the build-time generator to emit global-surprise.json (and questions-index.json) and updates validation to include the new global payload.
  • Extracts question topic tagging into a shared helper and removes the dice emoji from the company-page action.
File summaries
File Description
site/lib/question-topics.ts Extracts topic keyword mapping and topic derivation into a reusable helper.
site/components/GlobalSurpriseMe.tsx Adds a global Surprise Me UI that loads a generated index and opens ProblemPanel for the selected question.
site/app/page.tsx Mounts the new global Surprise Me section on the home page.
site/app/globals.css Styles the new global Surprise Me section and mobile behavior.
site/app/company/[slug]/SortableQuestionTable.tsx Reuses shared topic helper and removes dice emoji from the company-scoped Surprise Me button.
scripts/validate.mjs Adds validation for the generated global-surprise.json payload.
scripts/generate-index.mjs Generates global-surprise.json with log-scaled weights and emits questions-index.json for ProblemPanel.
Review details
  • Files reviewed: 7/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/generate-index.mjs
Comment thread scripts/validate.mjs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Vardhan-IMMIDI Vardhan-IMMIDI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good!
I checked it out in the vercel preview deployment, it works really well too!
The only changes I request are UI changes, currently the button looks a bit odd and out of place, can you maybe change it to look more clean or more standardized to our website UI?
About the mobile UI, the button doesn't adjust to the mobile UI correctly and the button becomes wide and takes up the entire width.
Please make this changes so we can move forward to merging with main.

Btw, Thanks for making my work easy by considering the @copilot review and making those changes!

Co-authored-by: Vardhan-IMMIDI <90963630+Vardhan-IMMIDI@users.noreply.github.com>

Copilot AI commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This looks really good!
I checked it out in the vercel preview deployment, it works really well too!
The only changes I request are UI changes, currently the button looks a bit odd and out of place,...

Implemented in 96c9d1a. The global Surprise me action now uses a cleaner site-aligned style, and the mobile behavior no longer forces full-width so it fits naturally in the layout.

@varma1221

Copy link
Copy Markdown
Collaborator Author

This looks really good! I checked it out in the vercel preview deployment, it works really well too! The only changes I request are UI changes, currently the button looks a bit odd and out of place, can you maybe change it to look more clean or more standardized to our website UI? About the mobile UI, the button doesn't adjust to the mobile UI correctly and the button becomes wide and takes up the entire width. Please make this changes so we can move forward to merging with main.

Btw, Thanks for making my work easy by considering the copilot review and making those changes!

Copilot does its thing even before I looked at this. I have verified the output and everything works as intended @Vardhan-IMMIDI. You can safely merge this with a final look.

@Vardhan-IMMIDI

Copy link
Copy Markdown
Collaborator

@varma1221 Agreed!
Merging rn

@Vardhan-IMMIDI
Vardhan-IMMIDI merged commit 84ba2ce into main Aug 31, 2026
3 checks passed
@Vardhan-IMMIDI
Vardhan-IMMIDI deleted the fix/global-surprise-me branch August 31, 2026 12:29

This branch was successfully deployed

1 active deployment
Preview — 96c9d1a7 Deployed Aug 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Surprise Me only selects questions from the current company

4 participants