Skip to content

Commit

Permalink
feat(scripts): add script to unstage all data
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jun 6, 2024
1 parent ee31929 commit 0e26499
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
"tacrolimus",
"tramadol",
"unscrollable",
"unstage",
"unstaged",
"userdata",
"voriconazole"
]
Expand Down
8 changes: 8 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ by deleting the history data and published data.
Run `python reset.py <PATH_TO_BACKUP>.base64` to receive
`<PATH_TO_BACKUP>_reset_<TIMESTAMP>.base64`.

## Unstage data

This is probably a use case only relevant once, we want to unstage all data and
do a second review.

Run `python unstage.py <PATH_TO_BACKUP>.base64` to receive
`<PATH_TO_BACKUP>_reset_<TIMESTAMP>.base64`.

## Migrate data

Run `pyhthon migrate.py <PATH_TO_BACKUP>[.json|.base64]` to receive
Expand Down
1 change: 1 addition & 0 deletions scripts/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'encode': '_encoded',
'correct': '_corrected',
'reset': '_reset',
'unstage': '_unstaged',
}

DRUG_COLLECTION_NAME = 'Drug'
Expand Down
11 changes: 0 additions & 11 deletions scripts/reset.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import copy

from common.get_data import get_data
from common.get_data import get_information_key
from common.get_data import get_guidelines_by_ids
from common.get_data import get_phenotype_value_lengths
from common.get_data import get_phenotype_value
from common.get_data import get_phenotype_key
from common.write_data import write_data
from common.constants import DRUG_COLLECTION_NAME
from common.constants import GUIDELINE_COLLECTION_NAME
from common.constants import SCRIPT_POSTFIXES
from common.cpic_data import get_phenotype_map
from common.remove_history import remove_history
from common.mongo import get_object_id

# Migrate data
def reset_data():
Expand Down
14 changes: 14 additions & 0 deletions scripts/unstage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from common.get_data import get_data
from common.write_data import write_data
from common.constants import SCRIPT_POSTFIXES

def unstage_data():
data = get_data()
for table_name in data.keys():
for item in data[table_name]:
if 'isStaged' in item.keys():
item['isStaged'] = False
write_data(data, postfix=SCRIPT_POSTFIXES['unstage'])

if __name__ == '__main__':
unstage_data()

0 comments on commit 0e26499

Please sign in to comment.