From 6e94ebfd1febe53cabc3bdad8a9006050a8dd005 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Tue, 12 Sep 2023 15:05:08 -0700 Subject: [PATCH] Revised docreviewer backend getdocuments to consume bcgovcode to gather divisons for recrods based on bcgovcode from foi-flow backend. More efficient call than gathering all divs. Ticket completed --- api/reviewer_api/resources/document.py | 3 ++- api/reviewer_api/services/documentservice.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/reviewer_api/resources/document.py b/api/reviewer_api/resources/document.py index 6963a20a8..5bb003df4 100644 --- a/api/reviewer_api/resources/document.py +++ b/api/reviewer_api/resources/document.py @@ -95,7 +95,8 @@ def get(requestid): timeout=float(requestapitimeout) ) response.raise_for_status() - result = documentservice().getdocuments(requestid) + bcgovcode = response.json()['bcgovcode'] + result = documentservice().getdocuments(requestid,bcgovcode) return json.dumps(result), 200 except KeyError as err: return {'status': False, 'message':err.messages}, 400 diff --git a/api/reviewer_api/services/documentservice.py b/api/reviewer_api/services/documentservice.py index a197d53a1..b6618c354 100644 --- a/api/reviewer_api/services/documentservice.py +++ b/api/reviewer_api/services/documentservice.py @@ -291,13 +291,13 @@ def updatedocumentattributes(self, payload, userid): return DocumentAttributes.update(newRows, oldRows) - def getdocuments(self, requestid): + def getdocuments(self, requestid,bcgovcode): divisions_data = requests.request( method='GET', - url=requestapiurl + "/api/foiflow/divisions", + url=requestapiurl + "/api/foiflow/divisions/{0}".format(bcgovcode), headers={'Authorization': AuthHelper.getauthtoken(), 'Content-Type': 'application/json'} ).json() - divisions = {div['divisionid']: div for div in divisions_data} + divisions = {div['divisionid']: div for div in divisions_data['divisions']} documents = {document['documentmasterid']: document for document in self.getdedupestatus(requestid)} attachments = []