From 1932d60027ba26f8e998dfc01e45f3d06419b96b Mon Sep 17 00:00:00 2001 From: Jack Gibson Date: Sun, 9 Jun 2024 10:53:14 -0500 Subject: [PATCH 1/3] default to empty string --- civiclens/nlp/pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/civiclens/nlp/pipeline.py b/civiclens/nlp/pipeline.py index 1f12cb5..2104151 100644 --- a/civiclens/nlp/pipeline.py +++ b/civiclens/nlp/pipeline.py @@ -128,7 +128,7 @@ def docs_have_titles(): comment_data = RepComments(document_id=doc_id) comment_data.summary = titles.get_doc_summary(id=doc_id)[0, "summary"] - current_title = doc_titles.get(doc_id, None) + current_title = doc_titles.get(doc_id, "") if (not current_title or args.refresh) and comment_data.summary: comment_data.doc_plain_english_title = title_creator.invoke( From 9ddae7e3d8510a5922f25599bafca5305426059f Mon Sep 17 00:00:00 2001 From: Jack Gibson Date: Sat, 17 Aug 2024 15:49:58 -0500 Subject: [PATCH 2/3] add date filter --- civiclens/regulations/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/civiclens/regulations/views.py b/civiclens/regulations/views.py index cc6657c..4805d52 100644 --- a/civiclens/regulations/views.py +++ b/civiclens/regulations/views.py @@ -82,7 +82,8 @@ def search_page(request): # join docs with comments, only on the docs open for comment joined_table = ( - Document.objects.all() + Document.objects.filter(comment_end_date__gt=today) + .all() .select_related("comment_counts") .filter(id__in=[item["document_id"] for item in comment_counts]) ) From dd17554c053cf7d4bf017a76c481da1f77444f05 Mon Sep 17 00:00:00 2001 From: Jack Gibson Date: Sat, 17 Aug 2024 15:56:13 -0500 Subject: [PATCH 3/3] linting tests --- civiclens/tests/test_views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/civiclens/tests/test_views.py b/civiclens/tests/test_views.py index 22f2f29..2283ce8 100644 --- a/civiclens/tests/test_views.py +++ b/civiclens/tests/test_views.py @@ -7,7 +7,7 @@ def test_active_docs(client): """Make sure document count is correct""" resp = client.get(reverse("search")) doc_facts = resp.context["doc_cmt_facts"] - assert doc_facts["active_documents_count"] == 2 + assert doc_facts["active_documents_count"] == 1 @pytest.mark.django_db @@ -50,5 +50,5 @@ def test_render_graph(client): def test_render_no_graph(client): """Assert no graph renders for pages w/o NLP""" no_graph_resp = client.get("/docs/BIS-2024-0003-0001").context - nlp_object = no_graph_resp["document_info"]["nlp"] - assert not nlp_object.id + # nlp_object = no_graph_resp["document_info"]["nlp"] + assert "document_info" not in no_graph_resp