Skip to content

Commit

Permalink
Fixed bad filtering in admin views
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejcorey committed Oct 24, 2024
1 parent c17f3cf commit 861adbd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/deed/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SearchHitReportAdmin(admin.ModelAdmin):
@admin.register(DeedPage)
class DeedPageAdmin(admin.ModelAdmin):
show_full_result_count = False
list_filter = ['workflow', 'bool_match', 'bool_exception', 'matched_terms__term', ('doc_date', DateRangeFilter),]
list_filter = ['workflow', 'workflow__workflow_name', 'bool_match', 'bool_exception', 'matched_terms__term', ('doc_date', DateRangeFilter),]
list_display = ['doc_num', 'bool_match', 'bool_exception', 'get_matched_terms', 'book_id', 'page_num', 'split_page_num', 's3_lookup', 'zooniverse_subject']
list_select_related = ['workflow']
search_fields = ['doc_num', 's3_lookup', 'book_id']
Expand Down
9 changes: 6 additions & 3 deletions apps/deed/management/commands/run_term_search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ def get_test_deedpages(self, workflow=None, n=100, bool_hits_only=False):
if bool_hits_only:
kwargs['bool_match'] = True

out_values = ['workflow__slug', 's3_lookup', 'page_ocr_json', 'page_ocr_text', 'page_image_web', 'page_stats', 'public_uuid', 'bool_match']

if len(kwargs) > 0:
random_deedpages = DeedPage.objects.filter(**kwargs).order_by('?').values('workflow__slug', 's3_lookup', 'page_ocr_json', 'page_ocr_text', 'page_image_web', 'page_stats', 'public_uuid')[:n]
random_deedpages = DeedPage.objects.filter(**kwargs).order_by('?').values(*out_values)[:n]
else:
random_deedpages = DeedPage.objects.all().order_by('?').values('workflow__slug', 's3_lookup', 'page_ocr_json', 'page_ocr_text', 'page_image_web', 'page_stats', 'public_uuid')[:n]
random_deedpages = DeedPage.objects.all().order_by('?').values(*out_values)[:n]

return random_deedpages

Expand All @@ -75,6 +77,7 @@ def process_lambda_response(self, deedpage_obj, response):
'workflow': deedpage_obj['workflow__slug'],
's3_lookup': deedpage_obj['s3_lookup'],
'page_ocr_text': deedpage_obj['page_ocr_text'],
'bool_basic_match': str(deedpage_obj['bool_match']),
'bool_fuzzy_match': bool_fuzzy_match,
'fuzzy_match_json': fuzzy_match_json,
'test_status': test_status,
Expand Down Expand Up @@ -186,7 +189,7 @@ def handle(self, *args, **kwargs):
settings.BASE_DIR, 'data', 'main_exports', f"{workflow_slug}_fuzzy_term_search_test{hit_str}_{now}.csv")

with open(self.term_test_result_path, 'w') as done_manifest:
done_manifest.write("workflow,s3_lookup,page_ocr_text,bool_fuzzy_match,fuzzy_match_json,test_status,match_context\n")
done_manifest.write("workflow,s3_lookup,page_ocr_text,bool_basic_match,bool_fuzzy_match,fuzzy_match_json,test_status,match_context\n")

# Get random set of DeedPage objects to test against
random_deedpages = self.get_test_deedpages(workflow, num_results, bool_hits_only)
Expand Down
3 changes: 2 additions & 1 deletion racial_covenants_processor/templates/workflow_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ <h3>Admin links</h3>
<ul>
<li><a href="/admin/zoon/zooniversesubject/?workflow__workflow_name={{workflow.workflow_name}}">Zooniverse subjects</a></li>
<li><a href="/admin/zoon/manualcovenant/?workflow__workflow_name={{workflow.workflow_name}}">Manual covenants</a></li>
<li><a href="/admin/deed/deedpage/?workflow__workflow_name={{workflow.workflow_name}}">Deed pages</a></li>
<li><a href="/admin/deed/deedpage/?workflow__id__exact={{workflow.id}}">Deed pages</a></li>
<li><a href="/admin/parcel/parcel/?workflow__id__exact={{workflow.id}}">Parcels</a></li>
</ul>

<h3>Download in-progress shapefiles</h3>
Expand Down

0 comments on commit 861adbd

Please sign in to comment.