Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add database archiving #1060

Merged
merged 6 commits into from
Dec 13, 2020
Merged

Add database archiving #1060

merged 6 commits into from
Dec 13, 2020

Conversation

chrismclarke
Copy link
Member

PR Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR Checklist

  • - Latest master branch merged
  • - PR title descriptive (can be used in release notes)
  • - Passes Tests

Description

Deleting documents from the database is not a trivial issue due to the way docs are cached. If a document is deleted from the server there is no way for a user to know it doesn't exist unless they fetch updates for that specific doc on the server (which might happen when opening a howto for example, but not for the full list on first load as this is inefficient - the full docs would need to be retrieved as there is no way to just query the list of ids that exist within firestore)

Currently the database deletes documents by removing the content and simply marking a deleted field and updating the timestamp. This is good in that it will prompt all users to receive the update to that document, however there are still 2 problems with this approach:

  1. If we ever want to restore a deleted document we can't as the data is wiped
  2. The database can quickly get cluttered with document stubs which then need to be filtered out on every query

This update adds a new system, whereby deleted docs are moved from their existing collection (solving 2), and populated in an _archived collection with both metadata stubs and full data stored separately (solving 1). An additional query is added for users to receive updates from the collection, and delete their own cached documents accordingly (keeping solution to initial problem). Additional bindings are made for the 3 existing database systems (firestore, firebase realtime and dexie) to process the deletes.

Git Issues

Closes #531

Screenshots/Videos

If useful, provide screenshot or capture to highlight main changes

@chrismclarke chrismclarke requested a review from BenGamma October 21, 2020 18:14
@chrismclarke
Copy link
Member Author

Note, run failing due to legacy package.json version bug

@cypress
Copy link

cypress bot commented Oct 21, 2020



Test summary

60 0 0 0


Run details

Project onearmy-community-platform
Status Passed
Commit d51cf6f ℹ️
Started Oct 31, 2020 11:58 AM
Ended Oct 31, 2020 12:08 PM
Duration 09:17 💡
OS Linux Ubuntu Linux - 16.04
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@BenGamma BenGamma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrismclarke, yes this approach is better than the current and will help to better handle the deletion/archiving of content 💪

Maybe as we discussed it could be good to have an other issue for further improvements regarding the deletion/archiving of content. Improvements that comes to my mind are :

  • Allow to restore a specific version of a document (like the previous version of an how-to, since we keep an history of modifications)
  • give the ability to an admin to delete a user/ map pin / content, by adding a delete button to them. This cases happend a lot and are not conviniently handled right now.

@chrismclarke chrismclarke merged commit d653772 into master Dec 13, 2020
@chrismclarke chrismclarke deleted the feat/db-delete branch December 13, 2020 04:41
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.

[discussion] - Providing better options for deleting data from the database
2 participants