Skip to content

Reduce number of CosmosDB write #371

@daphnecys

Description

@daphnecys

Issue
The current GitHub action will call the Update Data every 10 minutes. The code in lockdown/backend/src/loaders/lockdown/lockdown.js batchGetTerritoriesEntryData() is called in "Update Data" action.

This code parses the Data Set Entry GSheet, recreate the JSONs and reinsert them into CosmosDB (MongoDB), clearing the DB first. This generates a huge amount of unnecessary inserts. We want to do the clear DB and entire parse only once each half hour, and every 10 minutes, just the updates.

The entire parse is necessary to ensure that the bug fix by this code change 2590e30 remains fixed, i.e. delete country entries where entries are blank.

Possible solution
Two methods are possible:

  1. Create 2 GitHub action, each half hour run the function with parameter to clear data in DB and regenerate JSONs. every 10 mins in the half hour, just the updates (function with no parameter).

  2. Keep an environment variable storing is the timestamp of the last clear all run. If more than half hour, clear data in DB and regenerate JSONs, otherwise just update without clear.

(Daphne's ref: June 25 convo with Mark)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions