Correction import bureau de vote

This commit is contained in:
Emmy D'Anello 2024-07-02 21:54:02 +02:00
parent 47641924df
commit 313b161a06
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 4 additions and 5 deletions

View File

@ -15,7 +15,7 @@ def importer_resultats_bv(engine: Engine, verbose: bool = False) -> None:
with Session(engine) as session: with Session(engine) as session:
candidats = {(candidat.circonscription_id, candidat.numero): candidat candidats = {(candidat.circonscription_id, candidat.numero): candidat
for candidat in session.execute(select(CandidatLegislatives2024)).scalars().all()} for candidat in session.execute(select(CandidatLegislatives2024)).scalars().all()}
bv_ids = {(bv.commune_code, bv.code_bureau): bv.id bv_ids = {(bv.commune_code, bv.code_bureau): bv
for bv in session.execute(select(BureauVote)).scalars().all()} for bv in session.execute(select(BureauVote)).scalars().all()}
for tour, file_url in tours: for tour, file_url in tours:
@ -49,10 +49,9 @@ def importer_resultats_bv(engine: Engine, verbose: bool = False) -> None:
if (com_code, bv_code) not in bv_ids: if (com_code, bv_code) not in bv_ids:
print(f"Bureau de vote {com_code}_{bv_code} non trouvé") print(f"Bureau de vote {com_code}_{bv_code} non trouvé")
continue continue
bv_id = bv_ids[(com_code, bv_code)] bv = bv_ids[(com_code, bv_code)]
bv_id = bv.id
circo_code = row['Code circonscription législative'][-2:] circo_id = bv.circo_code
circo_id = f"{dpt_code.zfill(2)}-{circo_code.zfill(2)}"
resultats_bv = session.execute(select(ResultatsBureauVoteLegislatives2024) resultats_bv = session.execute(select(ResultatsBureauVoteLegislatives2024)
.filter_by(bv_id=bv_id)).scalar_one_or_none() .filter_by(bv_id=bv_id)).scalar_one_or_none()