-
Notifications
You must be signed in to change notification settings - Fork 106
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 AO status to legal AO endpoint #2738
Conversation
Codecov Report
@@ Coverage Diff @@
## release/public-20171109 #2738 +/- ##
===========================================================
- Coverage 89.35% 89.32% -0.03%
===========================================================
Files 68 68
Lines 5533 5546 +13
===========================================================
+ Hits 4944 4954 +10
- Misses 589 592 +3
Continue to review full report at Codecov.
|
ao_parsed.summary, | ||
ao_parsed.req_date, | ||
ao_parsed.issue_date, | ||
CASE ao.stage WHEN 0 THEN TRUE ELSE FALSE END AS is_pending, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to just retrieve ao.stage
in the SQL query and do the ao_status
and ao_is_pending
evaluations in python
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the logic would be simpler to understand in Python, and we could also keep this evaluation and the function ao_status_to_stage
in the same Python file, so that they could be edited together (if there were future changes to be made, or future special cases to be handled like 2009-05).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vrajmohan works for me! Will do.
I made just one comment - it is a suggestion and I'll be happy to merge without it. Everything else looks great! Nice work, @lbeaufort! |
ao_parsed.summary, | ||
ao_parsed.req_date, | ||
ao_parsed.issue_date, | ||
CASE ao.stage WHEN 2 THEN 'Withdrawn' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vrajmohan I removed the is_pending logic here, added the function on line 85, and added the is_pending logic on line 117.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great! Sorry, I wasn't clear but CASE ao.stage WHEN 2 THEN 'Withdrawn' --Hard-code one withdrawn AO that has improperly been marked Final WHEN 1 THEN CASE ao.ao_no WHEN '2009-05' THEN 'Withdrawn' ELSE 'Final' END ELSE 'Pending' END AS stage
would also be more clear in python
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To elaborate, the function would be:
def ao_stage_to_status(ao_no, stage):
AOS_WITH_INCORRECT_STAGE = ['2009-05']
if stage == 2:
return "Withdrawn"
elif stage == 1:
if ao_no in AOS_WITH_INCORRECT_STAGE:
return "Withdrawn:
else:
return "Final"
else:
return "Pending"
This would make it easier to add more special cases.
else: | ||
is_pending = False | ||
|
||
return is_pending |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In idiomatic python
, the entire body of this function would be:
return stage == 'Pending'
@vrajmohan thanks for your suggestions! I tweaked it slightly to make |
Along with https://github.com/18F/fec-cms/pull/1456, this resolves https://github.com/18F/fec-cms/issues/1390
Originally intended to replace
is_pending
withstatus
but that required a lot of front-end refactoring. Instead, I'm addingstatus
.-Verified that
ao.stage
data maps to AO status (0 = pending, 2 = withdrawn, 1 = final)-add
status
display field andao_status
search parameter with values "Pending," "Withdrawn," and "Final."-Slightly refactor SQL query - left join no longer needed, now need inner join to
aouser.ao
to pull instage
-Verified searches still work in API where
ao_category=W
= this is based off document categories-Tested AO search with
status
parameter - should be able to search for either-Hard-coded withdrawn AO 2009-05 that has improperly been marked Final in internal database