fecgov / openFEC

The first RESTful API for the Federal Election Commission. We're aiming to make campaign finance more accessible for journalists, academics, developers, and other transparency seekers.
https://api.open.fec.gov/developers
Other
483 stars 106 forks source link

Add Mur disposition category filter #5988

Closed fec-jli closed 1 month ago

fec-jli commented 2 months ago

Summary

Add filter by mur_disposition_category_id in the /legal/search/ endpoint. Here is the list of Mur dispostion category list

Required reviewers

2 devs

Impacted areas of the application

/legal/search/

Completion criteria

How to test

1)Checkout branch 2)Setup local ES 3Upload legal doc on local ES. These commands for reference: python cli.py create_index case_index python cli.py delete_index case_index python cli.py load_adrs python cli.py load_admin_fines python cli.py load_current_murs you can terminate(Ctr+C) in the middle of loading.

4)pytest and flask run

5)Test urls http://127.0.0.1:5000/v1/legal/search/?type=murs&mur_disposition_category_id=12 http://127.0.0.1:5000/v1/legal/search/?type=murs&mur_disposition_category_id=7

http://127.0.0.1:5000/v1/legal/search/?type=murs&mur_disposition_category_id=12&mur_disposition_category_id=7

on dev: https://fec-dev-api.app.cloud.gov/v1/legal/search?api_key=DEMO_KEY&type=murs&mur_disposition_category_id=1

multi-filter: https://fec-dev-api.app.cloud.gov/v1/legal/search?api_key=DEMO_KEY&type=murs&mur_disposition_category_id=1&mur_disposition_category_id=12

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 88.61789% with 14 lines in your changes missing coverage. Please review.

Project coverage is 86.73%. Comparing base (83e299e) to head (fee2946). Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
webservices/legal_docs/current_cases.py 93.39% 7 Missing :warning:
webservices/resources/legal.py 56.25% 7 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #5988 +/- ## =========================================== + Coverage 86.70% 86.73% +0.02% =========================================== Files 82 82 Lines 8975 8979 +4 =========================================== + Hits 7782 7788 +6 + Misses 1193 1191 -2 ``` | [Flag](https://app.codecov.io/gh/fecgov/openFEC/pull/5988/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fecgov) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/fecgov/openFEC/pull/5988/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fecgov) | `86.73% <88.61%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fecgov#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fec-jli commented 1 month ago

query to get MUR_ADR disposition category list: with q as (SELECT DISTINCT fecmur.event.event_name AS event_name FROM fecmur.calendar INNER JOIN fecmur.event USING (event_id) INNER JOIN fecmur.entity USING (entity_id) LEFT JOIN (SELECT detail_key AS entity_id, master_key AS settlement_id FROM fecmur.relatedobjects INNER JOIN fecmur.settlement ON fecmur.relatedobjects.master_key = fecmur.settlement.settlement_id WHERE relation_id = 1 ) AS relatedobjects ON relatedobjects.entity_id = fecmur.calendar.entity_id LEFT JOIN fecmur.settlement USING (settlement_id) LEFT JOIN (SELECT * FROM fecmur.violations WHERE stage = 'Closed' ) AS violations ON violations.entity_id = fecmur.calendar.entity_id WHERE event_name NOT IN ('Complaint/Referral', 'Disposition') ORDER BY fecmur.event.event_name ASC ) SELECT row_number() OVER () AS idx,event_name FROM q WHERE event_name NOT IN ('Complaint/Referral', 'Disposition') ORDER BY event_name ASC

mur_disposition_category_list.csv