-
Notifications
You must be signed in to change notification settings - Fork 338
Open
Labels
P0High priorityHigh priorityTeam SIssues for Squad 1Issues for Squad 1Type: BugSomething isn't workingSomething isn't working
Description
Feature Description
Originally rasied in bug bashing here: https://app.asana.com/1/8468971550303/project/1213555065417186/task/1213762140906173
Since early development, monthly frequency was called monthly but "rounded" to a 30 day report period in
| Email_Reporting_Settings::FREQUENCY_MONTHLY => 30, |
I noticed that we use copy "28 days" in the frequency selector, which would also make sense as it reflect periods we offer on dashboard. We should probably fix this in the code to set period to 28.
As Ben suggested in the comment bellow, best would be to compute numbers of previous month and use that number.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Monthly email-report reference dates are no longer based on a fixed 30-day window.
- For monthly runs, the report window should be the number of days in the previous calendar month in the site's timezone.
- Eg. A "Last month" report sent in February should use the number of days in January (31); a report sent in May should use the number of days in April (30).
- The text used for Monthly period (eg. "Last 28 days" or "Last 30 days") should be changed to "Last month".
Note: sendDate is the last day of the previous month; startDate is the first day of that same month.
Implementation Brief
- Update
includes/Core/Email_Reporting/Initiator_Task.php:- In
build_reference_dates(), replace hardcoded monthly30with a computed value derived from the monthly send date:- Keep existing
scheduled_dateandsend_datelogic. - For monthly frequency, set
period_days = (int) $send_date->format( 't' ). - Keep weekly (
7) and quarterly (90) as-is.
- Keep existing
- In
- Update
assets/js/components/email-reporting/FrequencySelector.js:- Replace monthly period copy (Last 28 days) with non-fixed wording (e.g. Last month) to align with variable month length and avoid misleading static text.
Test Coverage
- Update
tests/phpunit/integration/Core/Email_Reporting/Initiator_TaskTest.php:- Add/adjust monthly cases to verify computed period length for different months (28, 29, 30, 31-day outcomes—eg. account for leap years, etc.).
- Assert monthly
startDate/sendDatemap to first/last day of previous month for a month-boundary scheduled timestamp. - Keep weekly/quarterly assertions unchanged.
- Update any failing snapshots.
QA Brief
Changelog entry
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P0High priorityHigh priorityTeam SIssues for Squad 1Issues for Squad 1Type: BugSomething isn't workingSomething isn't working