Correction clés étrangères
This commit is contained in:
		@@ -42,9 +42,9 @@ function ResultatsTable({blocs, nuances, listes, resultats, siegesParListe}) {
 | 
			
		||||
            <TableRow key={liste.numero}>
 | 
			
		||||
              <TableCell>{liste.numero}</TableCell>
 | 
			
		||||
              <TableCell>{liste.nom}</TableCell>
 | 
			
		||||
              <TableCell bgColor={nuances.filter(nuance => nuance.code === liste.nuance)[0].couleur} sx={{padding: "0.2em"}}></TableCell>
 | 
			
		||||
              <TableCell sx={{backgroundColor: nuances.filter(nuance => nuance.code === liste.nuance)[0].couleur, padding: "0.2em"}}></TableCell>
 | 
			
		||||
              <TableCell>{liste.nuance}</TableCell>
 | 
			
		||||
              <TableCell bgColor={blocs.filter(bloc => bloc.nom === liste.bloc)[0].couleur} sx={{padding: "0.2em"}}></TableCell>
 | 
			
		||||
              <TableCell sx={{backgroundColor: blocs.filter(bloc => bloc.nom === liste.bloc)[0].couleur, padding: "0.2em"}}></TableCell>
 | 
			
		||||
              <TableCell>{liste.bloc}</TableCell>
 | 
			
		||||
              <TableCell>{voix_listes[liste.numero] || 0}</TableCell>
 | 
			
		||||
              <TableCell>{(100 * (voix_listes[liste.numero] || 0) / resultats.inscrits).toFixed(2)} %</TableCell>
 | 
			
		||||
 
 | 
			
		||||
@@ -143,7 +143,7 @@ def importer_resultats_departements(engine: Engine, debug: bool = False) -> None
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            if resultats_departement := session.execute(
 | 
			
		||||
                    select(ResultatsDepartement).filter_by(dpt_id=dpt_code)).scalar_one_or_none():
 | 
			
		||||
                    select(ResultatsDepartement).filter_by(dpt_id=dpt.code_insee)).scalar_one_or_none():
 | 
			
		||||
                resultats_departement.inscrits = resultats["inscrits"]
 | 
			
		||||
                resultats_departement.abstentions = resultats["abstentions"]
 | 
			
		||||
                resultats_departement.votants = resultats["votants"]
 | 
			
		||||
@@ -151,11 +151,11 @@ def importer_resultats_departements(engine: Engine, debug: bool = False) -> None
 | 
			
		||||
                resultats_departement.nuls = resultats["nuls"]
 | 
			
		||||
                resultats_departement.exprimes = resultats["exprimes"]
 | 
			
		||||
            else:
 | 
			
		||||
                resultats_region = session.execute(select(ResultatsRegion).filter_by(region_id=reg_code)) \
 | 
			
		||||
                resultats_region = session.execute(select(ResultatsRegion).filter_by(region_id=dpt.region_code)) \
 | 
			
		||||
                    .scalar_one_or_none()
 | 
			
		||||
 | 
			
		||||
                resultats_departement = ResultatsDepartement(
 | 
			
		||||
                    dpt_id=dpt_code,
 | 
			
		||||
                    dpt_id=dpt.code_insee,
 | 
			
		||||
                    resultats_region_id=resultats_region.id if resultats_region else None,
 | 
			
		||||
                    inscrits=resultats["inscrits"],
 | 
			
		||||
                    abstentions=resultats["abstentions"],
 | 
			
		||||
@@ -231,8 +231,11 @@ def importer_resultats_communes(engine: Engine, debug: bool = False) -> None:
 | 
			
		||||
                resultats_commune.nuls = resultats["nuls"]
 | 
			
		||||
                resultats_commune.exprimes = resultats["exprimes"]
 | 
			
		||||
            else:
 | 
			
		||||
                resultats_departement = session.execute(select(ResultatsDepartement).filter_by(dpt_id=dpt_code)) \
 | 
			
		||||
                    .scalar_one_or_none()
 | 
			
		||||
                resultats_commune = ResultatsCommune(
 | 
			
		||||
                    commune_id=com_code,
 | 
			
		||||
                    resultats_dpt_id=resultats_departement.id if resultats_departement else None,
 | 
			
		||||
                    inscrits=resultats["inscrits"],
 | 
			
		||||
                    abstentions=resultats["abstentions"],
 | 
			
		||||
                    votants=resultats["votants"],
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user