mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 01:44:11 +08:00
Cleaning up what @Lillinator was working on over here: https://github.com/discourse/discourse/pull/39917 Description: Context / Bug: Currently, when an admin sets a monthly recurring automation, the script attempts to calculate the "Nth Weekday" (e.g., "The 3rd Tuesday") using BYDAY instead of the actual calendar date. This causes two major issues for administrators: 1. Shifting Dates: Users expect a monthly report to run on the exact same calendar date (e.g., the 15th). Instead, the date shifts back and forth depending on when the "3rd Tuesday" or "2nd Friday" falls in the following month. 2. Silent Failures: If an admin sets a start date on the 30th or 31st of a month (e.g., the 5th Tuesday), the automation generates a rule like BYDAY=5TU. Months that only have 4 Tuesdays will completely fail to find a valid execution date and silently skip the entire month. Changes: * Replaced the BYDAY string calculation with BYMONTHDAY=#{start_date.day}. Monthly schedules will now reliably trigger on the exact calendar date matching user expectations. * Removed the now-unused count while-loop that was calculating the weekday occurrence. * Minor cleanup: Swapped Time.now for Time.zone.now in the RRule bounds check for standard Rails timezone consistency. Test Updates: * Updated two existing assertions in recurring_spec.rb. The original tests were explicitly (and incorrectly) expecting the buggy Nth-weekday drift. I corrected the assertion dates to expect the proper exact calendar day. Files Touched: * plugins/discourse-automation/lib/discourse_automation/triggers/recurring.rb * plugins/discourse-automation/spec/lib/discourse_automation/triggers/recurring_spec.rb |
||
|---|---|---|
| .. | ||
| fabricators | ||
| integration | ||
| jobs | ||
| lib | ||
| models | ||
| requests | ||
| scripts | ||
| serializers | ||
| services | ||
| system | ||
| triggers | ||
| plugin_helper.rb | ||