Skip to content

Commit

Permalink
fix for organisation search returning missing results with multiple o…
Browse files Browse the repository at this point in the history
…rgtypes

Add explanation of download
  • Loading branch information
drkane committed Apr 15, 2024
1 parent 2ee0e7e commit ae0af3e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
36 changes: 36 additions & 0 deletions ftc/jinja2/components/about_this_download.html.j2
@@ -0,0 +1,36 @@
<details class="mb3">
<summary class="blue link underline-hover f7 pointer tr">About this download</summary>
<div class="f6 measure pl3 bl bw2 b--gray mt1 pv1">
<p class="pa0 mt0 mb1">
This link allows you to download all organisations in the search results in a CSV format.
</p>
<p class="pa0 mt0 mb2">
The number of organisations may not exactly match the search results returned. This is because
the search results merge organisations where they are recorded as being registered with more
than
one regulator. The CSV download records these as separate organisations.
</p>
<p class="pa0 mt0 mb2">
The fields included in the CSV are:
</p>
<ul class="">
<li class="pa0 mt0 mb"><code>id</code></li>
<li class="pa0 mt0 mb"><code>name</code></li>
<li class="pa0 mt0 mb"><code>charityNumber</code></li>
<li class="pa0 mt0 mb"><code>companyNumber</code></li>
<li class="pa0 mt0 mb"><code>postalCode</code></li>
<li class="pa0 mt0 mb"><code>url</code></li>
<li class="pa0 mt0 mb"><code>latestIncome</code></li>
<li class="pa0 mt0 mb"><code>latestIncomeDate</code></li>
<li class="pa0 mt0 mb"><code>dateRegistered</code></li>
<li class="pa0 mt0 mb"><code>dateRemoved</code></li>
<li class="pa0 mt0 mb"><code>active</code></li>
<li class="pa0 mt0 mb"><code>dateModified</code></li>
<li class="pa0 mt0 mb"><code>orgIDs</code></li>
<li class="pa0 mt0 mb"><code>linked_orgs</code></li>
<li class="pa0 mt0 mb"><code>organisationType</code></li>
<li class="pa0 mt0 mb"><code>organisationTypePrimary</code></li>
<li class="pa0 mt0 mb"><code>source</code></li>
</ul>
</div>
</details>
18 changes: 9 additions & 9 deletions ftc/jinja2/orgtype.html.j2
Expand Up @@ -6,20 +6,17 @@
base_query.title,
) if base_query else 'Search Results' %}
{% if res.has_other_pages() %}
{% set subtitle = "Showing organisation {:,.0f} to {:,.0f} out of {:,.0f}".format(
{% set subtitle = "Showing organisation {:,.0f} to {:,.0f} out of {:,.0f}".format(
res.start_index(),
res.end_index(),
res.paginator.count
) %}
{% else %}
{% set subtitle = "Showing all {:,.0f} organisations".format(res.paginator.count) %}
{% set subtitle = "Showing all {:,.0f} organisations".format(res.paginator.count) %}
{% endif %}

{% block headscripts %}
<link
rel="stylesheet"
href="{{ static('lib/choices/choices.min.css') }}"
/>
<link rel="stylesheet" href="{{ static('lib/choices/choices.min.css') }}" />
<script src="{{ static('lib/choices/choices.min.js') }}"></script>
{{ super() }}
{% endblock headscripts %}
Expand All @@ -31,7 +28,8 @@

{% macro filter_tag(key, value) %}
<li class="b--dark-gray bn mr2 mb2 dib f6">
<span class="bg-near-black yellow pv1 ph2 br-pill br--left dib b">{{ key }}</span><span class="bg-moon-gray pv1 ph2 br-pill br--right dib">{{ value }}</span>
<span class="bg-near-black yellow pv1 ph2 br-pill br--left dib b">{{ key }}</span><span
class="bg-moon-gray pv1 ph2 br-pill br--right dib">{{ value }}</span>
</li>
{% endmacro %}

Expand Down Expand Up @@ -60,7 +58,8 @@
{% endfor %}
{% endif %}
</ul>
<a href="{{ url_remove(request, ['orgtype', 'source', 'location']) }}" class="f6 link blue underline">Clear filters</a>
<a href="{{ url_remove(request, ['orgtype', 'source', 'location']) }}"
class="f6 link blue underline">Clear filters</a>
</div>
{% endif %}
<div class="mt4">
Expand All @@ -69,7 +68,8 @@
</div>
<div class="fl w-100 w-30-l pa2">
{% if download_url %}
<a class="mb3 tr w-100 db b link dark-blue underline-hover" href="{{ download_url }}">Download as CSV</a>
<a class="mb1 tr w-100 db b link dark-blue underline-hover" href="{{ download_url }}">Download as CSV</a>
{% include 'components/about_this_download.html.j2' %}
{% endif %}
{% include 'components/search_facets.html.j2' %}
</div>
Expand Down
4 changes: 2 additions & 2 deletions ftc/query.py
Expand Up @@ -269,9 +269,9 @@ def run_es(self, with_pagination=False, with_aggregation=False):
def run_db(self, with_pagination=False, with_aggregation=False):
db_filter = []
if self.base_orgtype:
db_filter.append(Q(organisationType__contains=self.base_orgtype))
db_filter.append(Q(organisationType__overlap=self.base_orgtype))
if self.other_orgtypes:
db_filter.append(Q(organisationType__contains=self.other_orgtypes))
db_filter.append(Q(organisationType__overlap=self.other_orgtypes))
if self.source:
db_filter.append(Q(source__id__in=self.source))
if self.term:
Expand Down

0 comments on commit ae0af3e

Please sign in to comment.