Repository navigation
feat: add weighted global Surprise Me - #19
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 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
GlobalSurpriseMeclient component that fetches and selects fromglobal-surprise.jsonusing weighted randomness. - Extends the build-time generator to emit
global-surprise.json(andquestions-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.
Vardhan-IMMIDI
left a comment
There was a problem hiding this comment.
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>
Implemented in 96c9d1a. The global |
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. |
|
@varma1221 Agreed! |
Summary
Surprise meaction to the home page.Surprise mebehavior and keep it scoped to the current company and filters.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-checknpm run lintnpm run validatenpm run test:validationnpm run buildThe production build generated 662 static pages successfully.
Manual testing
Closes #18