# 每月触发的重复自动化未按预期运行

**URL:** <https://meta.discourse.org/t/monthly-triggered-recurring-automation-is-not-running-as-expected/402664>\
**Category:** Bug\
**Tags:** data-explorer, automation, fixed\
**Created:** [2026年五月11日 15:03 UTC](https://meta.discourse.org/t/monthly-triggered-recurring-automation-is-not-running-as-expected/402664 "2026-05-11T15:03:11Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2026年八月9日 10:18 UTC](https://meta.discourse.org/t/monthly-triggered-recurring-automation-is-not-running-as-expected/402664/23 "2026-08-09T10:18:12Z")

</div>

修复方案已在一段时间前合并

> <https://github.com/discourse/discourse/pull/40747>
>
> Cleaning up what @Lillinator was working on over here: https://github.com/discou…rse/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

现在对你来说是否有效？

---

_[View the full topic](https://meta.discourse.org/t/monthly-triggered-recurring-automation-is-not-running-as-expected/402664)._
