-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove no longer used method match_location_to_perimeter
- Loading branch information
1 parent
0e0db44
commit 9b18216
Showing
1 changed file
with
0 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
from lemarche.perimeters.models import Perimeter | ||
from lemarche.siaes.models import Siae | ||
|
||
|
||
def calculate_etablissement_count(siae: Siae): | ||
if siae.siren: | ||
return Siae.objects.filter(is_active=True, siret__startswith=siae.siren).count() | ||
return 0 | ||
|
||
|
||
def match_location_to_perimeter(siae: Siae): | ||
""" | ||
Find the Siae's location based on the post_code (and city) | ||
- first do a post_code search | ||
- if multiple perimeters returned, try to match with the city | ||
- if still multiple results returned, return None | ||
""" | ||
if siae.post_code: | ||
location_results_from_siae_post_code = Perimeter.objects.post_code_search( | ||
siae.post_code, include_insee_code=True | ||
) | ||
|
||
if not location_results_from_siae_post_code.exists(): | ||
print(f"No location found for {siae} (with post_code {siae.post_code})") | ||
return None | ||
elif location_results_from_siae_post_code.count() == 1: | ||
return location_results_from_siae_post_code.first() | ||
else: | ||
# found multiple locations with the post_code, try to match with the city | ||
if siae.city: | ||
location_results_from_siae_city = Perimeter.objects.name_search(siae.city) | ||
if location_results_from_siae_city.count(): | ||
if location_results_from_siae_post_code.first() == location_results_from_siae_post_code.first(): | ||
return location_results_from_siae_post_code.first() | ||
else: | ||
print(f"Multiple locations found for {siae} (with post_code {siae.post_code})") | ||
return None |