Repository navigation
Conversation
Generated recurring occurrences need a local time that always resolves. A boundless series would otherwise die permanently the first time one of its dates landed in the hour a zone skips. resolve_local/2 is unchanged: a time a person typed into a form does not exist and they should still be told so.
A boundless series has no last occurrence, so walking it forward from index 1 gets slower forever and eventually finds nothing. SeriesWindow computes the index of the first occurrence after a cutoff directly and takes a fixed count from there, at the same cost whatever the series' age. Shifts are still measured from the anchor, so a monthly series keeps its selected day through short months. Occurrences in a daylight saving gap resolve forward instead of failing the series. Nothing calls this yet.
…T span The comment above first_index_after/2 claimed the weekly estimate is exact. It isn't: both estimates floor, so whenever the cutoff is at or after the anchor the true index is always one past the estimate, never equal to it. Left uncorrected, that false claim invites a future maintainer to drop the correction step and silently return dates a week early. Also documents why correct/3's downward branch stays even though it is unreachable today. Also pins the spring-forward test's gapped occurrence to a thirty-minute span (03:00-03:30): only the start falls in the gap and resolves forward, so the end stays put. That compression is the intended wall-clock behavior, not an oversight, and the assertion plus comment now say so.
A nil repeat_until means the series is boundless. source_huddl_id records the huddl whose details generated occurrences copy, so a scheduled top-up has somewhere to read them from without guessing which occurrence speaks for the series; existing series are backfilled from their earliest one. due_for_maintenance lists the series a daily sweep should maintain: still generating, and in a group that has not been archived. A cadence is still required, and an end date before the first huddl is still rejected. Existing series keep their end dates.
exists(huddlz, is_nil(group.archived_at)) traversed has_many :huddlz, which resolves to Huddl's primary :read and applies FilterByVisibility. Run with no actor, that preparation silently drops every private group's series, so a private series would never be picked up by the sweep and would stop extending forever. Narrow the filter to the end-date condition alone; the archived-group guard belongs in MaintainRecurringSeries, the single path through which occurrences are actually created, not in this listing.
fill_window/2 creates the dates missing from a series' next twelve,
matching on calendar date across every lifecycle state. A cancelled week
stays cancelled, a gap from a partial failure is repaired, and a retried
or overlapping run creates nothing twice. Details are copied from the
template's source huddl, falling back to the latest occurrence when that
pointer has been nilified by a hard delete. This replaces the old
index-walk generator and its 104-instance cap, which no longer exist.
MaintainRecurringSeries replaces RegenerateRecurringSeries as the single
create path, rekeyed from a huddl to a template since the template is now
the unit of work. An Oban uniqueness window keeps a cron run overlapping a
create from enqueueing the same series twice. It also skips a series whose
group has been archived, reached through the source huddl's visibility-free
:get_for_recurrence read so a private group's series isn't silently missed.
reconcile_future_instances/4 ("edit all") now sources its desired dates
from SeriesWindow instead of the same removed walk.
…ce/1 MaintainRecurringSeries checked HuddlTemplate.source_huddl_id directly and returned false whenever it was nil, never looking the group up. That is exactly the case where RecurrenceHelper.fill_window/2 falls back to the series' latest occurrence and keeps generating: a hard-deleted source plus an archived group could still grow the series through the one path the guard didn't check. Promote RecurrenceHelper.series_source/1 to public and have the guard resolve through it instead of duplicating its fallback, so the two can't drift apart again. The guard now derives the group from whatever huddl series_source/1 returns, via the same visibility-free :get_for_recurrence read plus a :group load.
…ates A generated occurrence's lifecycle used to be a direct copy of the source huddl's lifecycle_state. The source drifts through :completed (once its own date passes) and :cancelled (if that single week is called off) while the series itself stays alive, but the :create action only accepts :draft or :published. About a week after an organizer started a boundless weekly series, its source huddl would complete, the next daily maintenance run would try to copy :completed into a create, Ash would reject it, the job would exhaust its retries, and the series would stop generating for good. Derive the generated lifecycle from the series instead: :draft only when the source itself is still a draft, :published otherwise. :completed and :cancelled describe the outcome of one date, not whether the series' future dates should be live.
Re-derives the eligible series every run rather than chaining per-series jobs: a dropped link in a chain stops a series forever with nothing to notice it, while a missed sweep costs a day. Series past their end date are excluded by the read action. Series in archived groups are still enqueued here; MaintainRecurringSeries already guards against extending them, and duplicating that guard in the read action's filter would mean traversing huddlz, whose default visibility filter would silently drop every private group's series.
Reconciliation asks for exactly as many dates as the series already has, so changing a monthly series to weekly re-spaces its occurrences into the next twelve weeks and adds nothing. Rows are updated in place, so RSVPs move with their date. A boundless series makes nil ambiguous on the repeat_until argument: the form always submits the field and means boundless, while an API caller changing only the title omits it and means nothing at all. Branch on the argument's presence so an omitted end date never un-bounds a series. An edit all also records its occurrence as the series' new source.
Rename the field to "Ends on" and say what blank means. "Repeat until" read as required and said nothing about the option to omit it. A blank end date means the series repeats until someone stops it, and the daily sweep keeps its next twelve dates materialized. Also fix a crash on the organize page: it read a boundless series' repeat_until with DateTime.to_date/1, which raises on nil. A series with no end date now renders its cadence alone, with no "until" clause.
…edit fill_window/2 asked for twelve grid slots measured from the template's anchor, and an "edit all" moves that anchor to the occurrence it was made from. Every still-upcoming occurrence earlier than the anchor therefore fell outside the grid, occupied no slot, and the next scheduled run built twelve more on top of it. A weekly series with twelve upcoming occurrences, given a title-only whole series edit from its sixth date, reached seventeen after the next run — and it ratcheted, adding roughly another eleven per subsequent edit. Those are published huddlz that members see and can RSVP to. Every test missed it because they all edit from the earliest upcoming occurrence, while the edit form offers "Whole series" from any of them. Cap creations at the horizon minus the occurrences the series already has after the cutoff, counted in any lifecycle state so a cancelled date still holds its place. Correct the design's claim that editing from the last occurrence makes the next sweep generate a fresh twelve at the new spacing: that is the same padding, and the series' count should not move. An edit from the last occurrence has nothing after it to re-date, so the new cadence materializes as the window advances past the anchor. Also unify the generation-failure notification onto series_source/1, so a series whose source huddl was hard-deleted still reaches its organizer, and bound latest_occurrence/1 to one row rather than reading the whole series. Add the coverage whose absence hid this: a series whose anchor is not its earliest upcoming occurrence, and a worker run against a two-year-old anchor.
siblings_in_series used to run only when a huddl was created or a series edited. The rolling window queries it at least once per series per day, so without an index on huddl_template_id that is a sequential scan of huddlz per series per day. Index huddl_template_id with starts_at, and index huddl_templates source_huddl_id, which every huddl hard-delete scans to nilify.
The recurring frequency/end-date row bottom-aligns its two columns. Adding help text under only "Ends on" made that column taller, which pushed "Frequency" down to match instead of lining up with it. Move the help text into the input's own `help` slot (matching the existing date-field pattern) and top-align the row instead, so a help line under one field no longer drags the other field with it.
An aged template anchor plus already-materialized occurrences let the cutoff-relative grid arithmetic land on a date earlier than the series' own source huddl: congruent with the cadence, but never actually reached, since everything up to the source was already resolved. Flooring SeriesWindow.next_occurrences/3's search at the source's starts_at keeps a long-lived series from manufacturing an occurrence earlier than the one it currently generates from.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Currently, recurring huddlz require a "Repeat Until" date. This determines how many huddl instances will be created in the system. This ensures infinite huddlz aren't created in the system. It's easy for the user to forget about though. The user is forced to regenerate huddl series after the repeat until date has passed. The user could setup the repeat until to the distant future, but the system would then generate a large number of huddlz that may not occur.
This change effectively makes the "Repeat Until" date optional. The label has been renamed to "Ends On" for clarity. Instead of generating all instances up front, the system now generates the next 12 records. A daily Oban job regularly checks for recurring huddlz and keeps the upcoming batch fresh.
Testing Steps
1. Create a recurring huddl with no end date (boundless)
(
/organize/{group}/huddlz)./groups/{group}/huddlz/new).schedule until you stop it" (not text implying a required end date).
indefinitely."
an end date).
/organize/{group}/huddlz), find the row forthis huddl. Confirm the series badge shows the cadence (e.g. "Weekly")
with no "until " suffix, since the series has no end date.
/organize/{group}/huddlz. Confirm there are 12 upcoming occurrencesin the series (same title, recurring badge), spaced a week apart.
2. Create a recurring huddl with a chosen end date
/organize/{group}/huddlz, click + Create huddl(
/groups/{group}/huddlz/new) and toggle Recurring huddl on.(e.g. 4 weeks from today).
/organize/{group}/huddlz, confirm the series badge shows the cadenceand "until ".
/organize/{group}/huddlz. Confirm the series only has occurrences upto the chosen end date (fewer than 12, since 4 weekly occurrences is less
than the 12-occurrence horizon).
3. Cancelling an occurrence doesn't get regenerated
present), open the 4th upcoming occurrence from
/organize/{group}/huddlz(this opens/groups/{group}/huddlz/{id}).cancellation.
notified (per the modal's copy).
/organize/{group}/huddlz. Confirm the series now shows 11upcoming occurrences.
/organize/{group}/huddlz?filter=cancelled)and confirm the occurrence you cancelled is listed there, still cancelled.
/organize/{group}/huddlz.regenerated, still only under the Cancelled filter) and the series
still shows 11 upcoming occurrences — the sweep does not "fill the
hole" left by a cancellation.
4. Editing the whole series re-spaces occurrences without adding new ones
one per step 1 but with Frequency: Monthly. Then go to
/organize/{group}/huddlzand click Edit series on that huddl's row (navigates to
/groups/{group}/huddlz/{id}/edit?edit_type=all, opened on the Wholeseries scope).
upcoming date" before you save (and the edit completes without error).
/organize/{group}/huddlz. Confirm the series still has exactly12 upcoming occurrences — the ed 10000 it didn't create any new ones.
month apart.
their RSVP followed to the re-dated occurrence rather than disappearing.
5. Extending an end date waits for the next scheduled run
/groups/{group}/huddlz/new) with Endson set to 3 weeks from today. Publish it so it fills in
(should show 3 upcoming occurrences, since that's all that
fits before the end date).
/organize/{group}/huddlzshows 3 upcoming occurrences.(
/groups/{group}/huddlz/{id}/edit?edit_type=all) and change Ends onto about 3 months out (or clear it entirely to make it boundless).
/organize/{group}/huddlzstill shows only 3upcoming occurrences immediately after saving — extending the end date
does not create anything on its own.
/organize/{group}/huddlz. Confirm the series now shows 12 upcomingoccurrences (the next scheduled run is what fills the new room).
6. Editing "just this occurrence" is unaffected
(
/groups/{group}/huddlz/{id}) and click Edit huddl(
/groups/{group}/huddlz/{id}/edit, opened on the Just this huddlscope by default).
the series' upcoming-occurrence count (
/organize/{group}/huddlz) areunaffected.