Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import API and/or web source url for bill #235

Merged
merged 2 commits into from
Feb 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions councilmatic_core/management/commands/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i'm reading this correctly, if there is both an api source and a web source, this code will prefer the api source. I think we want the opposite behavior, don't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I was thinking we'd want the API source, but actually we should return the web url, since that gets rendered in some of Councilmatic display logic. Okee.

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']:
Expand Down Expand Up @@ -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,
Expand Down