-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search - Extend Filter Fields (#3440)
* Getting search started. * Direct funding search. Rewrite form cleaning. Collapse filters by default. * Linting! * Search on major program. * Linting is for winners * Major program to Y/N field. * Linted! * Minor tests, new field defaults * Linting! * If there aren't eight linting commits, did anything happen? * Adds "Any findings" to the list. The performance of the big OR does not seem to be a problem, but it would be nice to do differently. Not today's blocker, though. * Cleanup, linting, comment removal. * Fiend -> Friend. Not the same! Plus a comment. * Whitespace is not okay, I guess * map -> zip * ALL -> all_findings * apply distinct only to relevant cols --------- Co-authored-by: Matt Jadud <[email protected]> Co-authored-by: Tim Ballard <[email protected]>
- Loading branch information
1 parent
91aeb9b
commit bb35a92
Showing
14 changed files
with
464 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.db.models import Q | ||
import time | ||
from .search_general import report_timing | ||
|
||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def search_direct_funding(general_results, params): | ||
t0 = time.time() | ||
q = Q() | ||
direct_funding_fields = params.get("direct_funding", []) | ||
|
||
for field in direct_funding_fields: | ||
match field: | ||
case "direct_funding": | ||
q |= Q(federalaward__is_direct="Y") | ||
case "passthrough_funding": | ||
q |= Q(federalaward__is_direct="N") | ||
case _: | ||
pass | ||
|
||
filtered_general_results = general_results.filter(q) | ||
|
||
t1 = time.time() | ||
report_timing("search_direct_funding", params, t0, t1) | ||
return filtered_general_results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from django.db.models import Q | ||
import time | ||
from .search_general import report_timing | ||
|
||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def search_findings(general_results, params): | ||
t0 = time.time() | ||
q = Q() | ||
findings_fields = params.get("findings", []) | ||
|
||
for field in findings_fields: | ||
match field: | ||
case "all_findings": | ||
# This can be achieved via federalaward__findings_count__gt=0, | ||
# But, it's faster to chain ORs in the Finding table than it is to walk the FederalAward table. | ||
q |= Q(finding__is_modified_opinion="Y") | ||
q |= Q(finding__is_other_findings="Y") | ||
q |= Q(finding__is_material_weakness="Y") | ||
q |= Q(finding__is_significant_deficiency="Y") | ||
q |= Q(finding__is_other_matters="Y") | ||
q |= Q(finding__is_questioned_costs="Y") | ||
q |= Q(finding__is_repeat_finding="Y") | ||
case "is_modified_opinion": | ||
q |= Q(finding__is_modified_opinion="Y") | ||
case "is_other_findings": | ||
q |= Q(finding__is_other_findings="Y") | ||
case "is_material_weakness": | ||
q |= Q(finding__is_material_weakness="Y") | ||
case "is_significant_deficiency": | ||
q |= Q(finding__is_significant_deficiency="Y") | ||
case "is_other_matters": | ||
q |= Q(finding__is_other_matters="Y") | ||
case "is_questioned_costs": | ||
q |= Q(finding__is_questioned_costs="Y") | ||
case "is_repeat_finding": | ||
q |= Q(finding__is_repeat_finding="Y") | ||
case _: | ||
pass | ||
filtered_general_results = general_results.filter(q) | ||
|
||
t1 = time.time() | ||
report_timing("search_findings", params, t0, t1) | ||
return filtered_general_results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.db.models import Q | ||
import time | ||
from .search_general import report_timing | ||
|
||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def search_major_program(general_results, params): | ||
""" | ||
Searches on FederalAward columns 'is_major'. Comes in as True/False, to search on Y/N. | ||
""" | ||
t0 = time.time() | ||
q = Q() | ||
major_program_fields = params.get("major_program", []) | ||
|
||
if True in major_program_fields: | ||
q |= Q(federalaward__is_major="Y") | ||
elif False in major_program_fields: | ||
q |= Q(federalaward__is_major="N") | ||
|
||
filtered_general_results = general_results.filter(q).distinct() | ||
|
||
t1 = time.time() | ||
report_timing("search_major_program", params, t0, t1) | ||
return filtered_general_results |
Oops, something went wrong.