fix: Add date range validation to prevent invalid date selection (#572)#587
Open
SinghCharanjeet11 wants to merge 7 commits intofossasia:mainfrom
Open
fix: Add date range validation to prevent invalid date selection (#572)#587SinghCharanjeet11 wants to merge 7 commits intofossasia:mainfrom
SinghCharanjeet11 wants to merge 7 commits intofossasia:mainfrom
Conversation
- Update biome schema version from 2.3.13 to 2.4.10 to match CLI - Add GitLab and Gitea support to roadmap in README - Highlight new multi-platform features in Features section - Document upcoming SCM analytics and Gitea integration Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add commits fetching from GitLab projects with date filtering - Map commits to standard format for report generation - Include commits data in GitLab data processing - Add project metadata to commits for better tracking - Support author filtering using author_name parameter This enables complete feature parity with GitHub support: Projects fetching Merge requests fetchingIssues fetching Commits fetching
…upport feat: complete GitLab support with commits fetching
- Add commits fetching from GitLab projects with date filtering - Map commits to standard format for report generation - Include commits data in GitLab data processing - Add project metadata to commits for better tracking - Support author filtering using author_name parameter This enables complete feature parity with GitHub support: Projects fetching Merge requests fetchingIssues fetching Commits fetching
…upport feat: complete GitLab support with commits fetching
Contributor
Reviewer's GuideImplements front-end date range validation for custom report ranges in the popup, adds user-visible error messaging with i18n support, and extends GitLab integration to fetch/map per-project commits into the existing report generation pipeline along with corresponding README updates. Sequence diagram for Generate Report flow with date range validationsequenceDiagram
actor User
participant Popup
participant Validation as validateDateRange
participant I18n as chrome_i18n
participant Toast as Materialize_toast
participant Report as ReportGenerator
User->>Popup: Click generateBtn
Popup->>Popup: Read yesterdayContribution radio
alt Custom date range selected
Popup->>Popup: Read startingDate and endingDate
Popup->>Validation: validateDateRange(startDate, endDate)
Validation-->>Popup: isValid
alt Date range invalid
Popup->>I18n: getMessage(invalidDateRangeError)
I18n-->>Popup: localizedMessage or null
alt Materialize available
Popup->>Toast: toast(message, 4000, red)
else Fallback
Popup->>User: alert(message)
end
Popup-->>User: Stop report generation
else Date range valid
Popup->>Report: generateScrumReport()
Report-->>User: Generated report content
end
else Yesterday preset selected
Popup->>Report: generateScrumReport()
Report-->>User: Generated report content
end
Sequence diagram for GitLab per-project commits integration into reportsequenceDiagram
participant Popup
participant Scrum as scrumHelper_allIncluded
participant GitLab as GitLabHelper
participant GitLabAPI as GitLab_API
participant Writer as writeGithubIssuesPrs
Popup->>Scrum: allIncluded(outputTarget)
Scrum->>GitLab: getData(username, startDate, endDate)
GitLab->>GitLabAPI: GET users?username=username
GitLabAPI-->>GitLab: users
GitLab->>GitLabAPI: GET projects for user (paginated)
GitLabAPI-->>GitLab: allProjects
loop For each project
GitLab->>GitLabAPI: GET merge requests for project
GitLabAPI-->>GitLab: project merge requests
GitLab->>GitLabAPI: GET issues for project
GitLabAPI-->>GitLab: project issues
GitLab->>GitLabAPI: GET commits for project (author_name, since, until)
GitLabAPI-->>GitLab: project commits
GitLab->>GitLab: Append project metadata to commits
GitLab->>GitLab: Small delay to avoid rate limiting
end
GitLab->>GitLab: Build gitlabData { user, projects, mergeRequests, issues, commits, comments }
GitLab-->>Scrum: gitlabData
Scrum->>Scrum: Map issues to githubIssuesData.items
Scrum->>Scrum: Map mergeRequests to githubPrsReviewData.items
Scrum->>Scrum: Map commits to gitlabCommits (standard commit format)
Scrum->>Writer: writeGithubIssuesPrs(githubIssuesData.items)
Scrum->>Writer: writeGithubIssuesPrs(githubPrsReviewData.items)
alt gitlabCommits not empty
Scrum->>Writer: writeGithubIssuesPrs(githubCommitsData)
end
Scrum-->>Popup: Scrum body ready
Sequence diagram for real-time custom date input validationsequenceDiagram
actor User
participant Popup
participant Validation as validateDateRange
participant I18n as chrome_i18n
participant Toast as Materialize_toast
User->>Popup: Type into startingDate input
Popup->>Popup: browser.storage.local.set({ startingDate })
Popup->>Popup: Read yesterdayContribution radio
alt Custom date range selected
Popup->>Popup: Read startingDate and endingDate
alt Both dates present
Popup->>Validation: validateDateRange(startDate, endDate)
Validation-->>Popup: isValid
alt Invalid
Popup->>I18n: getMessage(invalidDateRangeError)
I18n-->>Popup: localizedMessage or null
alt Materialize available
Popup->>Toast: toast(message, 4000, red)
else Fallback
Popup->>User: alert(message)
end
else Valid
Popup-->>User: No error shown
end
else Only one date present
Popup-->>User: Wait for other date
end
else Yesterday preset selected
Popup-->>User: No custom date validation
end
User->>Popup: Type into endingDate input
Popup->>Popup: browser.storage.local.set({ endingDate })
Popup->>Popup: Repeat same validation logic as for startingDate
Class diagram for GitLab data and commit mapping structuresclassDiagram
class GitLabHelper {
- baseUrl
- token
+ fetchUserAndProjectData(username, startDate, endDate)
+ buildGitlabData(users, allProjects, allMergeRequests, allIssues, allCommits)
+ processCachedData(data)
}
class GitlabProject {
+ id
+ name
+ web_url
}
class GitlabCommitRaw {
+ id
+ message
+ title
+ web_url
+ committed_date
}
class GitlabCommitWithProject {
+ id
+ message
+ title
+ web_url
+ committed_date
+ project_id
+ project_name
+ project_url
}
class GitlabData {
+ user
+ projects
+ mergeRequests
+ issues
+ commits
+ comments
}
class ProcessedGitlabData {
+ mergeRequests
+ issues
+ commits
+ comments
+ user
}
class MappedCommitForReport {
+ message
+ html_url
+ sha
+ project
+ author_name
+ author_email
}
class ScrumHelper_allIncluded {
+ githubIssuesData
+ githubPrsReviewData
+ githubCommitsData
+ allIncluded(outputTarget)
+ mapGitLabItem(item, projects, type)
}
class DateValidation {
+ validateDateRange(startDate, endDate)
+ showDateValidationError(message)
}
GitLabHelper "1" --> "*" GitlabProject : uses
GitLabHelper "1" --> "*" GitlabCommitRaw : fetches
GitLabHelper "1" --> GitlabData : builds
GitLabHelper "1" --> ProcessedGitlabData : processes
GitlabCommitRaw <|-- GitlabCommitWithProject
GitlabData --> "*" GitlabCommitWithProject : contains
ProcessedGitlabData --> "*" GitlabCommitWithProject : contains
ScrumHelper_allIncluded --> GitLabHelper : calls
ScrumHelper_allIncluded --> "*" MappedCommitForReport : creates
GitlabCommitWithProject --> MappedCommitForReport : maps to
ScrumHelper_allIncluded --> DateValidation : uses for date checks
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
scrumHelper.js,githubCommitsDatais only populated in the non-cached GitLab path; when data is loaded from cache you only passgitlabCommitsviamappedDataand never assigngithubCommitsData, so the laterwriteGithubIssuesPrs(githubCommitsData)for GitLab will be skipped—consider aligning the cache and non-cache paths so commits are always written consistently. - The real-time date validation in
popup.jstriggers a toast on every invalid keystroke, which may result in repeated, noisy notifications; consider debouncing this feedback or only showing the toast when the user finishes editing (e.g., on blur) or when the range transitions from valid to invalid. - The commit mapping logic for GitLab in
scrumHelper.jsis duplicated in two branches; extracting a small helper (e.g.,mapGitlabCommits(data.commits)) would reduce repetition and make it easier to keep both paths in sync.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `scrumHelper.js`, `githubCommitsData` is only populated in the non-cached GitLab path; when data is loaded from cache you only pass `gitlabCommits` via `mappedData` and never assign `githubCommitsData`, so the later `writeGithubIssuesPrs(githubCommitsData)` for GitLab will be skipped—consider aligning the cache and non-cache paths so commits are always written consistently.
- The real-time date validation in `popup.js` triggers a toast on every invalid keystroke, which may result in repeated, noisy notifications; consider debouncing this feedback or only showing the toast when the user finishes editing (e.g., on blur) or when the range transitions from valid to invalid.
- The commit mapping logic for GitLab in `scrumHelper.js` is duplicated in two branches; extracting a small helper (e.g., `mapGitlabCommits(data.commits)`) would reduce repetition and make it easier to keep both paths in sync.
## Individual Comments
### Comment 1
<location path="src/scripts/gitlabHelper.js" line_range="178" />
<code_context>
+ let allCommits = [];
+ for (const project of allProjects) {
+ try {
+ const projectCommitsUrl = `${this.baseUrl}/projects/${project.id}/repository/commits?author_name=${username}&since=${startDate}T00:00:00Z&until=${endDate}T23:59:59Z&per_page=100&order_by=committed_date&sort=desc`;
+ const projectCommitsRes = await fetch(projectCommitsUrl, { headers });
+ if (projectCommitsRes.ok) {
</code_context>
<issue_to_address>
**issue (bug_risk):** URL-encode query parameters when building the commits URL.
Directly interpolating `username`, `startDate`, and `endDate` into the query can break requests when they contain spaces or special characters. Wrap each in `encodeURIComponent(...)` before building the URL to ensure valid, robust requests.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@SinghCharanjeet11 hey!! Great observation but this issue is already considered earlier, you can check here #573 |
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
Fixes #572
This PR adds date range validation to prevent users from selecting invalid date ranges where the start date is after the end date. Previously, when users entered an invalid date range, the system would silently show "No activity to report" instead of displaying a clear validation error.
Changes Made
validateDateRange()function to check if start date ≤ end dateshowDateValidationError()function to display error messages using Materialize toastinvalidDateRangeErrorfor localization supportTesting
npm run buildRelated Issues
Closes #572
Summary by Sourcery
Add date range validation for custom reports and extend GitLab integration to include commit activity in generated scrum reports.
New Features:
Enhancements:
Documentation: