WPB-24076: Add meeting cleaner job in background-worker#5207
WPB-24076: Add meeting cleaner job in background-worker#5207blackheaven wants to merge 7 commits intodevelopfrom
background-worker#5207Conversation
1af1c4f to
1df93ce
Compare
| cleanupOldMeetingsImpl :: | ||
| ( Member Store.MeetingsStore r, | ||
| Member ConvStore.ConversationStore r | ||
| ) => | ||
| UTCTime -> | ||
| Int -> | ||
| Sem r Int64 | ||
| cleanupOldMeetingsImpl cutoffTime batchSize = do | ||
| -- 1. Fetch old meetings | ||
| oldMeetings <- Store.getOldMeetings cutoffTime batchSize | ||
|
|
||
| if null oldMeetings | ||
| then pure 0 | ||
| else do | ||
| -- 2. Extract meeting IDs and conversation IDs | ||
| let meetingIds = map (\Store.StoredMeeting {id = mid} -> mid) oldMeetings | ||
| convIds = map (\Store.StoredMeeting {conversationId = cid} -> cid) oldMeetings | ||
|
|
||
| -- 3. Delete meetings from database | ||
| deletedCount <- Store.deleteMeetingBatch meetingIds | ||
|
|
||
| -- 4. Delete associated conversations if they are meeting conversations | ||
| -- We need to check if conversation has GroupConvType = MeetingConversation | ||
| for_ (zip oldMeetings convIds) $ \(meeting, convId) -> do | ||
| maybeConv <- ConvStore.getConversation convId | ||
| case maybeConv of | ||
| Just conv | ||
| | conv.metadata.cnvmGroupConvType == Just MeetingConversation, | ||
| conv.id_ == convId, | ||
| meeting.conversationId == convId -> | ||
| ConvStore.deleteConversation convId | ||
| _ -> pure () | ||
|
|
||
| pure deletedCount |
There was a problem hiding this comment.
I would say it would be better to use the MeetingSubsystem to delete a meeting because that will take care of proper conversation deletion as well via the ConversationSubsystem.
There was a problem hiding this comment.
I guess the reason to have it's own logic here is the batch deletion on a DB level. But we should properly remove all conversation related data, so using the MeetingSubsystem is the price we have to pay, IMO.
1df93ce to
525b82e
Compare
692ecf7 to
ce1b6b8
Compare
|
|
||
| backgroundWorker: | ||
| host: backgroundWorker.{{ .Release.Namespace }}.svc.cluster.local | ||
| host: background-worker.{{ .Release.Namespace }}.svc.cluster.local |
| Just conv | ||
| | conv.metadata.cnvmGroupConvType == Just MeetingConversation, | ||
| conv.id_ == meeting.conversationId -> | ||
| ConvStore.deleteConversation meeting.conversationId |
There was a problem hiding this comment.
I still think that we should use the MeetingSubsystem to delete the meeting because that properly cleans up the conversation data. Here AFAICT we only delete the conversation via the ConversationStore but instead we should use the handler from the ConversationSubsystem because that takes care of deleting all the other stuff that is related to a conversation.
There was a problem hiding this comment.
We have to pair program on this tomorrow because regular meeting deletion requires a Qualified UserId and a ConnId
https://wearezeta.atlassian.net/browse/WPB-24076
Checklist
changelog.d