Skip to content

bug(events): assignment sheet says 'Première fois' for a member who did the part before #248

Description

@mindsers

Reproduction

  1. Open the assign-part sheet on an event whose template has a recurring history (e.g. a weekend or midweek meeting).
  2. Pick a member the user knows has been assigned to the same slot before.
  3. The CadencePanel shows the "Première fois pour cette partie" (publisher_info_first_time) message instead of the past assignment dots and dates.

Where the logic lives

  • Message rendered by app/features/events/ui/CadencePanel.tsx when computeCadenceWarnings returns firstTime = emptyWindow && !hasHistory (app/features/events/ui/compute-cadence-warnings.ts:29).

  • hasHistory is produced by app/features/events/server/list-user-cadence.server.ts:106-108. It queries:

    db.eventPart.findMany({
      where: {
        event: { templateId: event.templateId, congregationId, startDate: { lt: event.startDate } },
        ...(slot === 'assignee' ? { assigneeId: userId } : { assistantId: userId }),
      },
      select: { name: true, section: true },
    })

    then filters in JS by normalize(name) === normalize(partName) && normalize(section) === normalize(partSection).

  • normalize (app/features/events/server/cadence-shared.server.ts:21) does stripDiacritics(input).trim()not .toLowerCase() (the docstring above it claims "tolerant of case" but the implementation isn't).

Candidate root causes

The DB query above can silently return an empty history in four ways:

  1. templateId mismatch. History only crosses the same Event.templateId. If the template was recreated / re-imported / re-parented (the Programme → Event/Template rename feat(events): rename Programme* models to Event*/Template* #267 landed 5 days before this ticket), historical events may point at a different templateId and get dropped.
  2. Slot mismatch. The user was assignee (speaker) in the past but the sheet is currently on the assistant (reader) slot — or vice versa. The query only checks the same slot.
  3. Case drift on name / section. normalize doesn't lowercase, so "Lecture de la Bible" and "lecture de la bible" count as different parts. Similarly for section rename.
  4. Freeform short-circuit. event.templateId == null returns hasHistory: false unconditionally (list-user-cadence.server.ts:40). Only relevant if the current event is freeform.

Next step

Need to know from the reporter, for the specific reproduction:

  • Was the current event a recurring template or freeform?
  • Same slot as the historical assignments (speaker vs. reader)?
  • Exact part name + section as it appeared on the past events vs. now (case-sensitive)?
  • Did the template get renamed / re-imported recently?

Answers narrow the fix to one of the four hypotheses above. Most likely — given the recent rename and the missing .toLowerCase() — the fix is either backfilling templateId for historical events, or making normalize case-insensitive as its docstring already claims.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: eventsEvents, programmes, assignmentsstatus: needs-infoWaiting for more informationtype: bugSomething is broken

    Type

    No type

    Projects

    Status
    Short Term

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions