-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DO NOT REVIEW] SIAE/Job search: simplify handling of departments
The departments were computed by iterating over the list of objects, forcing to fetch them all to memory. For Paris, with 100 kms radius, that’s almost 2.5K job offers. That’s a lot of work, where a basic adjacency list is likely sufficient for users. Also, the departments field had to be reloaded when the search distance changed. That would lead to a pretty annoying UI with the upcoming changes to [Dropdown filters](https://zeroheight.com/85c89893b/p/207551-buttons): when a department is selected, the department field is reloaded (with HTMX), closing the dropdown filter. Hence, a user wanting to select multiple departments need to open the dropdown, click a department. The results load, they can then open the dropdown, click a department, and so on. Instead, use an adjacency list. Users can of course ask for an impossible combination of filters, such as SIAE 5 kms from Limoges and in Corrèze. They’ll just get no results, and pick more sensible filters. The assertNumQueries were outdated, and were updated to better reflect the actual queries.
- Loading branch information
1 parent
f3ea743
commit f67056e
Showing
7 changed files
with
201 additions
and
113 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
141 changes: 70 additions & 71 deletions
141
itou/templates/search/includes/siaes_search_filters_departments.html
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 |
---|---|---|
@@ -1,79 +1,78 @@ | ||
{% load django_bootstrap5 %} | ||
<div id="department-fields"{% if request.htmx %} hx-swap-oob="true"{% endif %}> | ||
{% if form.departments %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.departments.name }}" | ||
role="button" | ||
aria-expanded="{% if form.departments.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.departments.name }}"> | ||
{{ form.departments.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.departments.value %} show{% endif %}" id="collapse_{{ form.departments.name }}"> | ||
{{ form.departments }} | ||
</div> | ||
|
||
{% if form.departments %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.departments.name }}" | ||
role="button" | ||
aria-expanded="{% if form.departments.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.departments.name }}"> | ||
{{ form.departments.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.departments.value %} show{% endif %}" id="collapse_{{ form.departments.name }}"> | ||
{{ form.departments }} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
|
||
{# getattr and list still painful in Django template #} | ||
{% if form.districts_13 %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.districts_13.name }}" | ||
role="button" | ||
aria-expanded="{% if form.districts_13.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.districts_13.name }}"> | ||
{{ form.districts_13.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.districts_13.value %} show{% endif %}" id="collapse_{{ form.districts_13.name }}"> | ||
{{ form.districts_13 }} | ||
</div> | ||
{# getattr and list still painful in Django template #} | ||
{% if form.districts_13 %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.districts_13.name }}" | ||
role="button" | ||
aria-expanded="{% if form.districts_13.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.districts_13.name }}"> | ||
{{ form.districts_13.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.districts_13.value %} show{% endif %}" id="collapse_{{ form.districts_13.name }}"> | ||
{{ form.districts_13 }} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
|
||
{% if form.districts_69 %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.districts_69.name }}" | ||
role="button" | ||
aria-expanded="{% if form.districts_69.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.districts_69.name }}"> | ||
{{ form.districts_69.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.districts_69.value %} show{% endif %}" id="collapse_{{ form.districts_69.name }}"> | ||
{{ form.districts_69 }} | ||
</div> | ||
{% if form.districts_69 %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.districts_69.name }}" | ||
role="button" | ||
aria-expanded="{% if form.districts_69.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.districts_69.name }}"> | ||
{{ form.districts_69.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.districts_69.value %} show{% endif %}" id="collapse_{{ form.districts_69.name }}"> | ||
{{ form.districts_69 }} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
|
||
{% if form.districts_75 %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.districts_75.name }}" | ||
role="button" | ||
aria-expanded="{% if form.districts_75.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.districts_75.name }}"> | ||
{{ form.districts_75.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.districts_75.value %} show{% endif %}" id="collapse_{{ form.districts_75.name }}"> | ||
{{ form.districts_75 }} | ||
</div> | ||
{% if form.districts_75 %} | ||
<hr> | ||
<fieldset> | ||
<div class="form-group mb-0"> | ||
<legend class="has-collapse-caret mb-0" | ||
data-bs-toggle="collapse" | ||
href="#collapse_{{ form.districts_75.name }}" | ||
role="button" | ||
aria-expanded="{% if form.districts_75.value %}true{% else %}false{% endif %}" | ||
aria-controls="collapse_{{ form.districts_75.name }}"> | ||
{{ form.districts_75.label | capfirst }} | ||
</legend> | ||
<div class="collapse mt-3{% if form.districts_75.value %} show{% endif %}" id="collapse_{{ form.districts_75.name }}"> | ||
{{ form.districts_75 }} | ||
</div> | ||
</fieldset> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</fieldset> | ||
{% endif %} |
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
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
Oops, something went wrong.