ppazos / cabolabs-ehrserver

Open platform to manage and share standardized clinical data, designed by @ppazos at CaboLabs Health Informatics.
https://cabolabs.com
Apache License 2.0
179 stars 110 forks source link

SYNC - create sync jobs #968

Closed ppazos closed 6 years ago

ppazos commented 6 years ago

One job per type of resource (wont work because sync has a precedence order following the hierarchy): account should be synced first, then orgs, users and roles, then ehrs (for orgs), folders *for ehrs), contributions (for ehrs), queries (for org), opt (for org)

  1. For all the SyncClusterConfig
  2. Get the resources that are master
  3. And that don't have a SyncLog for the SyncClusterConfig
  4. Do JSON marshalling
  5. And send using the Sync API Client (need to add this to the groovy client)
  6. Get the OK and generate the SyncLog
ppazos commented 6 years ago

Sync Accounts

  1. An account syncs orgs, users and roles
  2. When a new org or user is added to the account, or a role changes, sync for that account is needed
  3. As a first approach we can mark the account as dirty when changes happen after a sync and do the complete sync (remote should process and calculate only the diff to sync)
  4. We can add a sync_dirty flag to account for this
  5. A finner approach would be to sync just the resource that was updated, but also needs fine grained services and that will take more time to implement

This applies to other items that can be edited, like queries, or updated, like OPTs.

ppazos commented 6 years ago

Instead of using a sync_dirty flag we can save the lastUpdated date of the resource in the syncLog.

The issue is updating a User won't change the lastUpdated of an Account, so the Account won't be updated. We need more services to be able to sync just individual entities when modifications happen, and use aggregated syncs only for the first sync.

This is for all but Contribution since contribs can't be updated.

This is for another issue.

ppazos commented 6 years ago

MIGRATIONS: