platform icon indicating copy to clipboard operation
platform copied to clipboard

fix(love): use addCollection/createTxCollectionCUD for MeetingMinutes creation

Open spatialy opened this issue 9 months ago • 2 comments

Summary

Fixes #10526. Also related to #8785 and #7303.

After a meeting ends the Room detail view always showed "No meeting minutes" even when MeetingMinutes documents existed in the database. The MeetingMinutesSection.svelte component gates rendering on meetings > 0, but that counter was never incremented because MeetingMinutes were created with createDoc/createTxCreateDoc instead of addCollection/createTxCollectionCUD.

The collection counter trigger in server/middleware/triggers.ts (processCollection) only fires when attachedTo, attachedToClass, and collection are top-level transaction properties — which only TxCollectionCUD provides. createDoc / createTxCreateDoc puts those fields inside attributes (the document data), so the trigger never fires and the Room counter stays at 0.

Changes

  • models/love/src/index.ts — change @Model parent from core.class.Doc → core.class.AttachedDoc so hierarchy.isDerived(love.class.MeetingMinutes, core.class.AttachedDoc) returns true
  • plugins/love-resources/src/meetings.ts — replace client.createDoc(...) with client.addCollection(...) for client-side MeetingMinutes creation
  • server-plugins/love-resources/src/index.ts — wrap the createTxCreateDoc in a createTxCollectionCUD so the server-side trigger correctly increments the Room's meetings counter

Test plan

  • [ ] Start a meeting in a Room, enable transcription, speak for 30+ seconds, then end the meeting
  • [ ] Room detail page → "Meeting minutes" section shows the meeting (not "No meeting minutes")
  • [ ] meetings counter on the Room document increments correctly after each meeting
  • [ ] Existing MeetingMinutes documents and transcription data are unaffected
  • [ ] Office rooms still create MeetingMinutes correctly
  • [ ] Collaborators are still attached to newly created MeetingMinutes

Workaround for existing deployments

For self-hosted CockroachDB deployments where the counter is already stuck at 0, run:

UPDATE love
SET data = jsonb_set(COALESCE(data, '{}'::jsonb), '{meetings}', (
    SELECT COALESCE(to_jsonb(count(*)), '0'::jsonb)
    FROM meeting_minutes
    WHERE "attachedTo" = love._id
    AND "workspaceId" = love."workspaceId"
)::jsonb)
WHERE _class IN ('love:class:Room', 'love:class:Office');

spatialy avatar Feb 18 '26 17:02 spatialy

Connected to Huly®: UBERF-15586

huly-github-staging avatar Feb 18 '26 17:02 huly-github-staging

I think the counter is less of a problem. All meeting minutes documents have to be converted to AttachedDoc with proper attachedTo and attachedToClass properties set. We usually do this via migrations.

https://github.com/hcengineering/platform/blob/develop/models/love/src/migration.ts

aonnikov avatar Feb 27 '26 05:02 aonnikov