From 6ee2d4f0198e0edf554951a44381c356c3a3cd85 Mon Sep 17 00:00:00 2001 From: Dan Funk Date: Wed, 23 Sep 2020 15:24:09 -0400 Subject: [PATCH] Don't load samples from firebase (they will be added via direct calls to the api) Provide a mechanism to clear out all the samples - should remove this or protect it at some point. --- communicator/api.yml | 8 ++++++++ communicator/api/admin.py | 12 +++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/communicator/api.yml b/communicator/api.yml index d80c275..86066aa 100644 --- a/communicator/api.yml +++ b/communicator/api.yml @@ -63,6 +63,14 @@ paths: type: array items: $ref: "#/components/schemas/Sample" + delete: + operationId: communicator.api.admin.clear_samples + summary: Removes the given samples completely. + tags: + - Studies + responses: + '204': + description: All Samples removed. components: schemas: Status: diff --git a/communicator/api/admin.py b/communicator/api/admin.py index a2028f9..1015a7a 100644 --- a/communicator/api/admin.py +++ b/communicator/api/admin.py @@ -20,14 +20,16 @@ def add_sample(body): db.session.add(sample) db.session.commit() +def clear_samples(): + db.session.query(Sample).delete() + db.session.commit() + def update_data(): - """Updates the database based on local files placed by IVY and records - read in from the firecloud database.""" - fb_service = FirebaseService() + """Updates the database based on local files placed by IVY. No longer attempts + to pull files from the Firebase service.""" ivy_service = IvyService() - samples = fb_service.get_samples() - samples.extend(ivy_service.load_directory()) + samples = ivy_service.load_directory() SampleService().add_or_update_records(samples) db.session.commit()