Allow option to exclude specific weekdays from total time#1219
Open
alpaca-tc wants to merge 1 commit intoactions:mainfrom
Open
Allow option to exclude specific weekdays from total time#1219alpaca-tc wants to merge 1 commit intoactions:mainfrom
alpaca-tc wants to merge 1 commit intoactions:mainfrom
Conversation
1403262 to
524c3cd
Compare
alpaca-tc
commented
Mar 10, 2025
Comment on lines
+2375
to
+2407
| 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; |
Author
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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.
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:
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: