Skip to content

Conversation

@alpaca-tc
Copy link

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.

  • 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
- uses: actions/stale@v9
  with:
    days-before-stale: 5
    days-before-close: 2
    exclude-weekdays: '0,6'  # Exclude weekends

Related issue:

Fixed #564

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

@alpaca-tc alpaca-tc requested a review from a team as a code owner March 7, 2025 10:58
@alpaca-tc alpaca-tc force-pushed the add-exclude-weekdays branch from 1403262 to 524c3cd Compare March 7, 2025 13:41
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;
Copy link
Author

@alpaca-tc alpaca-tc Mar 10, 2025

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
```
Copilot AI review requested due to automatic review settings December 15, 2025 09:11
@alpaca-tc alpaca-tc force-pushed the add-exclude-weekdays branch from 524c3cd to 38a8a46 Compare December 15, 2025 09:11
Copy link
Contributor

Copilot AI left a 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-weekdays configuration 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow option to exclude weekends from total time

1 participant