-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from MTES-MCT/feat-ocsge-gironde
Ajout de l'OCS GE pour le département Gironde (33)
- Loading branch information
Showing
4 changed files
with
257 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
__all__ = [ | ||
"CalculateCommuneArtificialAreas", | ||
"CalculateCommuneDiff", | ||
"CalculateCommuneTotalArtif", | ||
"CalculateCommuneUsageEtCouvertureRepartition", | ||
] | ||
|
||
from .CalculateCommuneArtificialAreas import CalculateCommuneArtificialAreas | ||
from .CalculateCommuneDiff import CalculateCommuneDiff | ||
from .CalculateCommuneTotalArtif import CalculateCommuneTotalArtif | ||
from .CalculateCommuneUsageEtCouvertureRepartition import ( | ||
CalculateCommuneUsageEtCouvertureRepartition, | ||
) |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
|
||
import celery | ||
from django.core.management import call_command | ||
from django.core.management.base import BaseCommand | ||
|
||
from public_data.models import Commune, DataSource, Departement | ||
from public_data.tasks import calculate_data_for_commune | ||
|
||
logger = logging.getLogger("management.commands") | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Dedicated to load data for 5.2 deployment" | ||
|
||
def load_departement(self, departement: Departement): | ||
call_command( | ||
command_name="load_shapefile", | ||
dataset=DataSource.DatasetChoices.OCSGE, | ||
land_id=departement.source_id, | ||
) | ||
call_command( | ||
command_name="update_project_ocsge", | ||
departements=[departement.source_id], | ||
) | ||
|
||
def handle(self, *args, **options): | ||
logger.info("Start mep_71") | ||
|
||
call_command("maintenance", on=True) | ||
|
||
logger.info("Initialize data sources") | ||
DataSource.objects.all().delete() | ||
call_command("loaddata", "public_data/models/data_source_fixture.json") | ||
|
||
logger.info("Load new OCS GE") | ||
call_command("setup_departements") | ||
|
||
departements_source_ids = ["33"] | ||
|
||
celery_tasks = [] | ||
|
||
for source_id in departements_source_ids: | ||
departement = Departement.objects.get(source_id=source_id) | ||
self.load_departement(departement) | ||
|
||
for commune in Commune.objects.filter(departement=departement): | ||
celery_tasks.append(calculate_data_for_commune.si(commune.insee)) | ||
|
||
celery.group(*celery_tasks).apply_async(queue="long") | ||
|
||
call_command("maintenance", off=True) | ||
logger.info("End mep_71") |
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