From 9a57e800a91c78f18b9f42c36eb154ea414884af Mon Sep 17 00:00:00 2001 From: reginafcompton Date: Mon, 11 Feb 2019 16:25:45 -0500 Subject: [PATCH 1/2] Import API and/or web source url for bill --- .../management/commands/import_data.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/councilmatic_core/management/commands/import_data.py b/councilmatic_core/management/commands/import_data.py index f3cf5225..961b0816 100644 --- a/councilmatic_core/management/commands/import_data.py +++ b/councilmatic_core/management/commands/import_data.py @@ -964,10 +964,19 @@ def insert_raw_bills(self, delete=False): with open(os.path.join(self.bills_folder, bill_json)) as f: bill_info = json.loads(f.read()) + + # Add the API source, if available, which allows for easier debugging + # Otherwise, assume that the 'web' source is available source_url = None + source_note = None for source in bill_info['sources']: - if source['note'] == 'web': + if source['note'] == 'api': + source_url = source['url'] + source_note = source['note'] + break + else: source_url = source['url'] + source_note = source['note'] full_text = None if 'rtf_text' in bill_info['extras']: @@ -1008,7 +1017,7 @@ def insert_raw_bills(self, delete=False): 'identifier': bill_info['identifier'], 'classification': bill_info['classification'][0], 'source_url': source_url, - 'source_note': bill_info['sources'][0]['note'], + 'source_note': source_note, 'from_organization_id': bill_info['from_organization']['id'], 'full_text': full_text, 'ocr_full_text': ocr_full_text, From c98c6f9968f453a7061acd8a35e8f8f40ee6eedb Mon Sep 17 00:00:00 2001 From: reginafcompton Date: Mon, 11 Feb 2019 16:41:32 -0500 Subject: [PATCH 2/2] Add web, not api --- councilmatic_core/management/commands/import_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/councilmatic_core/management/commands/import_data.py b/councilmatic_core/management/commands/import_data.py index 961b0816..01c62cde 100644 --- a/councilmatic_core/management/commands/import_data.py +++ b/councilmatic_core/management/commands/import_data.py @@ -965,12 +965,12 @@ def insert_raw_bills(self, delete=False): bill_info = json.loads(f.read()) - # Add the API source, if available, which allows for easier debugging - # Otherwise, assume that the 'web' source is available + # Add the web source, if available. + # Otherwise, assume that the 'api' source is available and add that. source_url = None source_note = None for source in bill_info['sources']: - if source['note'] == 'api': + if source['note'] == 'web': source_url = source['url'] source_note = source['note'] break