Skip to content

Commit

Permalink
Clean, results_bdd unused (#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlvernay authored Dec 18, 2024
1 parent 03fa60f commit a2a7413
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
19 changes: 1 addition & 18 deletions erp/provider/acceslibre.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def _not_duplicate(erp, other):


def parse_etablissements(qs, other_sources):
results = []
for erp in qs.iterator(chunk_size=200):
erp_as_dict = model_to_dict(erp)
erp_as_dict.pop("source")
Expand All @@ -19,20 +18,4 @@ def parse_etablissements(qs, other_sources):
erp_as_dict["icon"] = erp.get_activite_vector_icon()
erp_as_dict["activite"] = erp.activite
other_sources = [other_erp for other_erp in other_sources if _not_duplicate(erp_as_dict, other_erp)]
results.append(
dict(
exists={
"get_absolute_url": erp_as_dict["get_absolute_url"],
"slug": erp.slug,
"user": erp.user_id,
"published": erp_as_dict["published"],
"icon": erp_as_dict["icon"],
"activite": erp_as_dict["activite"],
},
source="acceslibre",
coordonnees=erp_as_dict["geom"],
naf=None,
**erp_as_dict
)
)
return results, other_sources
return other_sources
6 changes: 1 addition & 5 deletions erp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ def contrib_start(request):
def contrib_global_search(request):
results = error = None
commune = ""
results_bdd = []
results = []

need_external_api_search = True
Expand All @@ -482,7 +481,6 @@ def contrib_global_search(request):
if request.GET.get("activity_slug"):
activite = Activite.objects.filter(slug=request.GET.get("activity_slug")).first()

nb_results_bdd = 0
pagination_size = 6

if request.GET.get("what"):
Expand All @@ -504,9 +502,8 @@ def contrib_global_search(request):
qs_results_bdd = qs_results_bdd.filter(activite=activite)

commune, qs_results_bdd = _search_commune_code_postal(qs_results_bdd, request.GET.get("code"))
nb_results_bdd = qs_results_bdd.count()
qs_results_bdd = qs_results_bdd[:pagination_size]
results_bdd, results = acceslibre.parse_etablissements(qs_results_bdd, results)
results = acceslibre.parse_etablissements(qs_results_bdd, results)

city, _ = clean_address(request.GET.get("where"))

Expand All @@ -518,7 +515,6 @@ def contrib_global_search(request):
"commune_search": commune,
"step": 1,
"next_step_title": schema.SECTION_TRANSPORT,
"has_more_results_bdd": nb_results_bdd > pagination_size,
"results": results[:pagination_size],
"error": error,
"api_key": _get_or_create_api_key(),
Expand Down
2 changes: 1 addition & 1 deletion tests/erp/test_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_contrib_start_global_search_with_existing(
user=user,
)

with django_assert_num_queries(7):
with django_assert_num_queries(6):
response = client.get(
reverse("contrib_global_search"),
data={
Expand Down

0 comments on commit a2a7413

Please sign in to comment.