fix: correct date format for DAU calculation in StatsResources worker#11870
fix: correct date format for DAU calculation in StatsResources worker#11870yogeshwaran-c wants to merge 1 commit intoappwrite:1.9.xfrom
Conversation
The DAU (Daily Active Users) threshold was using format 'Y-m-d h:m:00' which has two bugs: 'h' gives 12-hour time instead of 24-hour (should be 'H'), and 'm' gives month number instead of minutes (should be 'i'). This caused the DAU query to use an incorrect threshold, producing inaccurate active user counts.
Greptile SummaryThis PR fixes a bug in Confidence Score: 5/5Safe to merge — the fix is minimal, correct, and directly addresses the documented bug with no side effects. The change is a one-line correction of two wrong PHP date format specifiers. The fix matches PHP's DateTime::format() spec exactly, the surrounding MAU/WAU calculations are untouched, and there are no logic, security, or style issues introduced. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: correct date format for DAU calcula..." | Re-trigger Greptile |
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
The DAU (Daily Active Users) threshold in the
StatsResourcesworker uses the PHP date format string'Y-m-d h:m:00', which contains two incorrect format specifiers:hproduces 12-hour time (01–12) instead of 24-hour time. For example, 14:00 becomes02instead of14.mproduces the month number (01–12) where minutes should be. For example, at 14:30 in April, the minutes position outputs04(the month) instead of30(the actual minutes).Combined, this means at 14:30 on April 12 the computed threshold becomes
2026-04-11 02:04:00instead of the intended2026-04-11 14:30:00. This causes the DAU count query to use an incorrect time boundary, producing inaccurate active user metrics.The neighboring MAU and WAU calculations use
'Y-m-d 00:00:00'(zeroed time), so they are not affected. Only the DAU path, which needs hour-and-minute precision, has this bug.What is the new behavior?
Changed the format string to
'Y-m-d H:i:00':H— 24-hour format hours (00–23)i— minutes (00–59)This matches PHP's
DateTime::format()specification and produces the correct threshold for the DAU query.Additional context
Single-line change in
src/Appwrite/Platform/Workers/StatsResources.phpline 124.