community-platform icon indicating copy to clipboard operation
community-platform copied to clipboard

[Cloud function]: Daily sync of research meta-data

Open benfurber opened this issue 8 months ago • 3 comments

Due to the move to discussion documents holding the comments for each research update and changing comments from being deleted from the DB to be updated to _deleted, it's much more common and noticiable that the comment count stored for each research articles (totalCommentCount) gets out of sync with the reality.

Solution: Accept that certain changes in data will be fallible and have a cloud function that runs daily for research that:

  1. Identifies all the currently not _deleted and published research articles.
  2. Identifies all the published and not _deleted updates for each article.
  3. Identifies discussion document for each research update (found through the _id of an update being the sourceId of the discussion).
  4. Count the not _deleted comments for the discussion.

That should then give a total that can be set as the totalCommentCount for the research.

benfurber avatar Jun 11 '24 12:06 benfurber