fix(user,sync): resolve trailing slash profile break and daily sync timezone mismatch#316
Open
RishiSingh13 wants to merge 1 commit into
Open
Conversation
Contributor
|
Thank you for submitting a pull request. Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully. Formatting and Branching
|
Author
|
@jagdish-15 i have raised a issue#315 and this was its fix and be assured i have checked everything working great . pls review this and merge it . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This Pull Request addresses two bugs to improve URL routing resilience and synchronization accuracy:
/user/someusername/) completely breaks the page's graphs, headings, and API fetches.Linked Issues
Fixes #315
Changes Made
1. Frontend Profile Page URL Handling
frontend/js/user/historical-graphs.jscurrentUsernamewas fetched usingpathSegments[pathSegments.length - 1]. If the URL had a trailing slash, it retrieved""(empty string) as the username, triggering 404s when fetching/api/user/and leaving the page graphs completely blank.This brings the script in line with the fallback patterns already successfully implemented in badges.js and contest.js.
File: scripts/sync-leaderboard.js
Before: getYesterdaySnapshot() extracted targetDate using d.toISOString().split("T")[0]. During early morning sync runs (e.g., 3:00 AM IST), this UTC conversion rolled the date back a second day, causing the script to fetch a snapshot from two days ago.
After: Constructed the local date format manually to bypass UTC shifts, aligning the logic with getFileName() inside the same script:
javascript
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, "0");
const date = String(d.getDate()).padStart(2, "0");
const targetDate =
${year}-${month}-${date};Type of Change
Bug fix
New feature
UI/Visual update
Documentation update
Refactor
Testing
Tested locally
Tested on mobile viewport (if applicable)
No console errors introduced
Local Testing Steps:
Visited http://localhost:3000/user/jagdish/ (with trailing slash) and verified that the Performance profile page load was successful, page heading resolved properly, and graphs rendered correctly without any console errors.
Ran node scripts/sync-leaderboard.js to ensure the sync pipeline runs without execution issues.
Formatted the codebase locally using npx prettier --write . prior to making commits.
Checklist
My code follows the project's coding style
I have formatted my code locally by running npx prettier --write . before submitting
I am submitting my PR from a dedicated fix/trailing-slash-and-timezone branch, not the main branch
I have performed a self-review of my code
My changes generate no new warnings or errors
I have updated documentation if required
I have linked the relevant issue