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

Add ADRs and AFs to API #3365

Merged
merged 12 commits into from
Sep 12, 2018
Merged

Add ADRs and AFs to API #3365

merged 12 commits into from
Sep 12, 2018

Conversation

lbeaufort
Copy link
Member

@lbeaufort lbeaufort commented Sep 6, 2018

Summary (required)

Resolves #3359

Remaining dev work

  • Figure out if existing query parameters work properly
  • Reuse query parameters: Add ADRs and AFs to API #3365 (review). Don't get rid of existing mur_ query fields or we'll break the front end, but build generic ones as for MUR/ADR/AF. Put in an issue to refactor front end to use generic filters for MURs.
  • check codecov and add tests if needed

How to test the changes locally

  • Test migration with invoke create_sample_db
  • In webservices/legal/current_cases.py, change fecmur.cases_with_parsed_case_serial_numbers_vw to fecmur.cases_with_parsed_case_serial_numbers_lb_tmp
  • Test MUR reload celery task
  • Re-create the indexes and load ADR/AF/MUR:
./manage.py initialize_current_legal_docs
./manage.py load_adrs -s 820
./manage.py load_adrs
./manage.py load_admin_fines -s 820
./manage.py load_admin_fines
./manage.py load_current_murs
./manage.py load_current_murs -s 7000
./manage.py load_current_legal_docs

Impacted areas of the application

List general components of the application that this PR will affect:

  • Legal API

@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch from 9964dc7 to aed34d5 Compare September 6, 2018 22:37
@lbeaufort lbeaufort changed the title Feature/add adr af to legal 2 [WIP] Add ADRs and AFs to API Sep 6, 2018
@codecov-io
Copy link

codecov-io commented Sep 6, 2018

Codecov Report

Merging #3365 into develop will decrease coverage by 0.28%.
The diff coverage is 70.39%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3365      +/-   ##
===========================================
- Coverage    88.75%   88.47%   -0.29%     
===========================================
  Files           75       75              
  Lines         6199     6314     +115     
===========================================
+ Hits          5502     5586      +84     
- Misses         697      728      +31
Impacted Files Coverage Δ
webservices/tasks/__init__.py 68% <ø> (ø) ⬆️
webservices/args.py 97.52% <ø> (ø) ⬆️
webservices/tasks/legal_docs.py 0% <0%> (ø) ⬆️
webservices/legal_docs/index_management.py 36.61% <100%> (+4.8%) ⬆️
webservices/legal_docs/__init__.py 59.25% <33.33%> (-4.75%) ⬇️
webservices/resources/legal.py 70.21% <63.33%> (-2.98%) ⬇️
webservices/legal_docs/current_cases.py 87.39% <81.18%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 842d5bc...52fcbeb. Read the comment docs.

@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch 3 times, most recently from 85c04e3 to 4809fe2 Compare September 7, 2018 00:33
@@ -145,7 +154,12 @@ def mur_query_builder(q, type_, from_hit, hits_returned, **kwargs):
.index('docs_search') \
.sort("sort1", "sort2")

return apply_mur_specific_query_params(query, **kwargs)
if type_ == 'murs':
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having distinctly named query parameters for every document type, we may want to consider combining them and having common parameters like document_no, respondents, dispositions, min_date, etc.

@lbeaufort lbeaufort mentioned this pull request Sep 7, 2018
10 tasks
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch from 9de7bda to 0906c2c Compare September 11, 2018 14:43
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch 2 times, most recently from 97f0617 to ac0d5d7 Compare September 11, 2018 21:26
@lbeaufort lbeaufort changed the base branch from develop to release/public-20180911 September 11, 2018 21:27
@lbeaufort lbeaufort changed the base branch from release/public-20180911 to develop September 11, 2018 21:27
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch from ac0d5d7 to 3c4c7d8 Compare September 11, 2018 21:41
@lbeaufort lbeaufort changed the title [WIP] Add ADRs and AFs to API Add ADRs and AFs to API Sep 11, 2018
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch from c079002 to 66944f1 Compare September 11, 2018 23:53
@lbeaufort lbeaufort changed the base branch from develop to release/public-20180911 September 11, 2018 23:54
@lbeaufort lbeaufort changed the base branch from release/public-20180911 to develop September 11, 2018 23:54
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch from 66944f1 to 4ac25f7 Compare September 12, 2018 00:02
@lbeaufort lbeaufort requested a review from qqss88 September 12, 2018 01:39
Copy link
Contributor

@vrajmohan vrajmohan left a comment

Choose a reason for hiding this comment

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

Nice work! Made some minor comments.

SET search_path = fecmur, pg_catalog;

CREATE OR REPLACE VIEW cases_with_parsed_case_serial_numbers AS
CREATE OR REPLACE VIEW cases_with_parsed_case_serial_numbers_vw AS
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we dropping the old view cases_with_parsed_case_serial_numbers somewhere?

locustfile.py Outdated
@@ -200,6 +200,20 @@ def get_mur(self, term=None):
}
self.client.get('legal/docs/murs/7074', name='legal_get_mur', params=params)

@locust.task
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be pre-existing - the term parameter is unused.

locustfile.py Outdated
params = {
'api_key': API_KEY,
}
self.client.get('legal/docs/adrs/668', name='legal_get_adr', params=params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again pre-existing - we may want to select a random document from a list of known document numbers. Also, applies to AOs, AFs and MURs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, I'll put in a new commit.

Copy link
Contributor

@qqss88 qqss88 left a comment

Choose a reason for hiding this comment

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

2 WHERE keywords in the query
RECENTLY_MODIFIED_MURS = """
SELECT case_no, pg_date
FROM fecmur.cases_with_parsed_case_serial_numbers
WHERE pg_date >= NOW() - '8 hour'::INTERVAL
WHERE case_type = 'MUR'
ORDER BY case_serial
"""

Copy link
Contributor

@qqss88 qqss88 left a comment

Choose a reason for hiding this comment

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

doc strings need to be updated too - like Mur --> case -

  • to avoid confusion.

in the mapping file, 'url' mapping could be discussed a little more.

Copy link
Contributor

@qqss88 qqss88 left a comment

Choose a reason for hiding this comment

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

in current_murs.py:
def load_current_murs(mur_no=None):
load_cases(mur_no, 'MUR') load_cases(mur_no, 'MUR')

to be unified with adrs and AF, better to change mur_no --> case_no

Copy link
Contributor

@qqss88 qqss88 left a comment

Choose a reason for hiding this comment

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

I see different string formatting patterns in the code:

       if case_type == 'MUR':
        return mur	                case['mur_type'] = 'current'
            case['url'] = '/legal/matter-under-review/%s/' % row['case_no']
        else:
            case['url'] = '/legal/{0}/{1}'.format(case_type.lower(), 

not a big issue, but better to be unified.

Copy link
Contributor

@qqss88 qqss88 left a comment

Choose a reason for hiding this comment

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

later on, we can move hard-coded 'MUR', 'AF', 'ADR' to a case config file or something like that.

@lbeaufort
Copy link
Member Author

Thanks for your feedback, @qqss88! Re: #3365 (review), I unify them in this commit: cc6e4d8 sorry if that doesn't address your comment.

@qqss88
Copy link
Contributor

qqss88 commented Sep 12, 2018

Great job!!! Ignore my comments for those pre-existing stuff. We can discuss how to improve the code the base in a general discussion. Thx.

@lbeaufort lbeaufort changed the title Add ADRs and AFs to API [WIP] Add ADRs and AFs to API Sep 12, 2018
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch from eb1855f to bd6cb12 Compare September 12, 2018 18:16
@lbeaufort lbeaufort force-pushed the feature/add-adr-af-to-legal-2 branch 2 times, most recently from c2f6def to a50986a Compare September 12, 2018 18:51
@lbeaufort lbeaufort changed the title [WIP] Add ADRs and AFs to API Add ADRs and AFs to API Sep 12, 2018
GRANT SELECT ON TABLE cases_with_parsed_case_serial_numbers_vw TO fec_read;
GRANT SELECT ON TABLE cases_with_parsed_case_serial_numbers_vw TO openfec_read;

DROP VIEW cases_with_parsed_case_serial_numbers
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semicolon?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you! I'm surprised the migrations run - probably because it's at the end.

@lbeaufort
Copy link
Member Author

@vrajmohan @qqss88 I've made your suggested changes and split the celery task for automatic reloading of ADR/AF to a new PR: #3374

@vrajmohan vrajmohan merged commit d06d283 into develop Sep 12, 2018
@vrajmohan vrajmohan deleted the feature/add-adr-af-to-legal-2 branch September 12, 2018 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ADR and AF to API
4 participants