8000 Add boundless recurring huddl support by murjax · Pull Request #665 · huddlz-hq/huddlz · GitHub
[go: up one dir, main page]

Skip to content

Add boundless recurring huddl support - #665

Open
murjax wants to merge 15 commits into
huddlz-hq:mainfrom
murjax:rvm_boundless_recurrence_09292026
Open

murjax wants to merge 15 commits into
huddlz-hq:mainfrom
murjax:rvm_boundless_recurrence_09292026

Conversation

@murjax
@murjax murjax commented Sep 30, 2026
Copy link
Copy Markdown
Contributor

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)

  1. Sign in as an organizer and go to the group's Huddlz management tab
    (/organize/{group}/huddlz).
  2. Click + Create huddl (navigates to /groups/{group}/huddlz/new).
  3. Toggle Recurring huddl on.
  4. Confirm the help text under the toggle reads something like "Repeats on a
    schedule until you stop it" (not text implying a required end date).
  5. Pick Frequency: Weekly.
  6. Leave Ends on blank. Confirm its help text reads "Leave blank to repeat
    indefinitely."
  7. Fill in the rest of the required fields and publish the huddl.
  8. Confirm the huddl is published successfully (no validation error demanding
    an end date).
  9. Back on the Huddlz tab (/organize/{group}/huddlz), find the row for
    this huddl. Confirm the series badge shows the cadence (e.g. "Weekly")
    with no "until " suffix, since the series has no end date.
  10. Refresh /organize/{group}/huddlz. Confirm there are 12 upcoming occurrences
    in the series (same title, recurring badge), spaced a week apart.

2. Create a recurring huddl with a chosen end date

  1. From /organize/{group}/huddlz, click + Create huddl
    (/groups/{group}/huddlz/new) and toggle Recurring huddl on.
  2. Pick Frequency: Weekly and set Ends on to a date a few weeks out
    (e.g. 4 weeks from today).
  3. Publish it. Confirm it publishes successfully.
  4. On /organize/{group}/huddlz, confirm the series badge shows the cadence
    and "until ".
  5. Refresh /organize/{group}/huddlz. Confirm the series only has occurrences up
    to 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

  1. Using the boundless weekly series from step 1 (with 12 occurrences
    present), open the 4th upcoming occurrence from
    /organize/{group}/huddlz (this opens /groups/{group}/huddlz/{id}).
  2. Click Cancel huddl, optionally add an explanation, and confirm the
    cancellation.
  3. Confirm the huddl now shows a cancelled state and attendees would be
    notified (per the modal's copy).
  4. Go back to /organize/{group}/huddlz. Confirm the series now shows 11
    upcoming
    occurrences.
  5. Switch to the Cancelled filter (/organize/{group}/huddlz?filter=cancelled)
    and confirm the occurrence you cancelled is listed there, still cancelled.
  6. Refresh /organize/{group}/huddlz.
  7. Confirm the cancelled date is still cancelled (not silently
    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

  1. Using a boundless monthly series that already has its window filled (create
    one per step 1 but with Frequency: Monthly. Then go to /organize/{group}/huddlz
    and click Edit series on that huddl's row (navigates to
    /groups/{group}/huddlz/{id}/edit?edit_type=all, opened on the Whole
    series
    scope).
  2. Change Frequency from Monthly to Weekly and save.
  3. Confirm the edit succeeds and the confirmation banner reads "Editing every
    upcoming date" before you save (and the edit completes without error).
  4. Go to /organize/{group}/huddlz. Confirm the series still has exactly
    12 upcoming occurrences — the ed 10000 it didn't create any new ones.
  5. Confirm the occurrences are now spaced about a week apart rather than a
    month apart.
  6. If any attendee had RSVPed to one of the original monthly dates, confirm
    their RSVP followed to the re-dated occurrence rather than disappearing.

5. Extending an end date waits for the next scheduled run

  1. Create a weekly recurring huddl (/groups/{group}/huddlz/new) with Ends
    on
    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).
  2. Confirm /organize/{group}/huddlz shows 3 upcoming occurrences.
  3. Click Edit series on that huddl's row
    (/groups/{group}/huddlz/{id}/edit?edit_type=all) and change Ends on
    to about 3 months out (or clear it entirely to make it boundless).
  4. Save the edit. Confirm /organize/{group}/huddlz still shows only 3
    upcoming occurrences
    immediately after saving — extending the end date
    does not create anything on its own.
  5. Refresh /organize/{group}/huddlz. Confirm the series now shows 12 upcoming
    occurrences
    (the next scheduled run is what fills the new room).

6. Editing "just this occurrence" is unaffected

  1. Open a single occurrence from a recurring series
    (/groups/{group}/huddlz/{id}) and click Edit huddl
    (/groups/{group}/huddlz/{id}/edit, opened on the Just this huddl
    scope by default).
  2. Change something occurrence-specific (e.g. the description) and save.
  3. Confirm only that occurrence changed — other occurrences in the series and
    the series' upcoming-occurrence count (/organize/{group}/huddlz) are
    unaffected.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0