-
Notifications
You must be signed in to change notification settings - Fork 406
Allow option to exclude specific weekdays from total time #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
1403262 to
524c3cd
Compare
| let elapsedMillis = to.getTime() - from.getTime(); | ||
| if (excludeWeekdays.length > 0) { | ||
| const startOfNextDayFrom = startOfDay(new Date(from.getTime() + DAY)); | ||
| const startOfDayTo = startOfDay(to); | ||
| if (excludeWeekdays.includes(from.getDay())) { | ||
| elapsedMillis -= startOfNextDayFrom.getTime() - from.getTime(); | ||
| } | ||
| if (excludeWeekdays.includes(to.getDay())) { | ||
| elapsedMillis -= to.getTime() - startOfDayTo.getTime(); | ||
| } | ||
| const excludeWeekdaysCount = countWeekdaysBetweenDates(startOfNextDayFrom, startOfDayTo, excludeWeekdays); | ||
| elapsedMillis -= excludeWeekdaysCount * DAY; | ||
| } | ||
| return elapsedMillis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't use options, the existing implementation is used, so even if there are bugs, the impact is minimal. A simple O(N) calculation logic is used. While an O(1) logic could also be possible, it would be a bit more complex.
Fixed actions#564 Add support for excluding specific weekdays when calculating elapsed days for stale issues and PRs. This is particularly useful for organizations that want to consider only business days. - Add new `exclude-weekdays` option to specify which days to exclude (0-6, where 0 is Sunday) - Implement weekday exclusion logic in elapsed days calculation - Add tests to verify business days calculation ```yaml - uses: actions/stale@v9 with: days-before-stale: 5 days-before-close: 2 exclude-weekdays: '0,6' # Exclude weekends ```
524c3cd to
38a8a46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for excluding specific weekdays when calculating elapsed days for stale issues and PRs, enabling organizations to consider only business days in their stale policies.
Key Changes:
- Added
exclude-weekdaysconfiguration option accepting comma-separated day numbers (0-6) - Implemented weekday exclusion logic that accurately handles partial days and week-spanning periods
- Added comprehensive test coverage for the new functionality
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| action.yml | Added new exclude-weekdays input parameter with description |
| src/main.ts | Added parsing and validation logic for the exclude-weekdays option |
| src/interfaces/issues-processor-options.ts | Extended interface to include excludeWeekdays property |
| src/functions/elapsed-millis-excluding-days.ts | Implemented core calculation logic for excluding weekdays from elapsed time |
| src/functions/elapsed-millis-excluding-days.spec.ts | Added comprehensive unit tests for weekday exclusion logic |
| src/classes/issues-processor.ts | Integrated weekday exclusion into stale and close date calculations |
| src/classes/issue.spec.ts | Updated test fixtures to include excludeWeekdays property |
| tests/constants/default-processor-options.ts | Added excludeWeekdays to default options |
| tests/main.spec.ts | Added integration test verifying weekday exclusion behavior |
| README.md | Added documentation for the new exclude-weekdays option |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description:
Add support for excluding specific weekdays when calculating elapsed days for stale issues and PRs. This is particularly useful for organizations that want to consider only business days.
exclude-weekdaysoption to specify which days to exclude (0-6, where 0 is Sunday)Related issue:
Fixed #564
Check list: