Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inifinite loop checking comparent #469

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api-node/src/aggregators/indice_atmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ export async function getAtmoIndicatorForDate(
const missingDepartments: Record<Municipality['DEP'], number> = {};
for (const municipality of municipalities) {
let indiceAtmoData = indiceAtmoByMunicipalityInseeCode[municipality.COM];
if (!indiceAtmoData && municipality.COMPARENT) {
if (
!indiceAtmoData &&
municipality.COMPARENT &&
municipality.COMPARENT !== municipality.COM
) {
indiceAtmoData =
indiceAtmoByMunicipalityInseeCode[municipality.COMPARENT];
}
Expand Down
5 changes: 4 additions & 1 deletion api-node/src/getters/bathing_water.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ async function getBathingWaters({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getBathingWaters({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down
10 changes: 8 additions & 2 deletions api-node/src/getters/indice_atmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ async function getIndiceAtmoForJ0({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getIndiceAtmoForJ0({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down Expand Up @@ -296,7 +299,10 @@ async function getIndiceAtmoForJ1({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality?.COMPARENT !== municipality_insee_code
) {
return await getIndiceAtmoForJ1({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down
5 changes: 4 additions & 1 deletion api-node/src/getters/indice_uv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ async function getIndiceUVForJ({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getIndiceUVForJ({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down
10 changes: 8 additions & 2 deletions api-node/src/getters/pollens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ async function getPollensForJ0({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getPollensForJ0({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down Expand Up @@ -251,7 +254,10 @@ async function getPollensForJ1({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getPollensForJ1({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down
10 changes: 8 additions & 2 deletions api-node/src/getters/weather_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ async function getWeatherAlertForJ0({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getWeatherAlertForJ0({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down Expand Up @@ -276,7 +279,10 @@ async function getWeatherAlertForJ1({
const municipality = await prisma.municipality.findUnique({
where: { COM: municipality_insee_code },
});
if (municipality?.COMPARENT) {
if (
municipality?.COMPARENT &&
municipality.COMPARENT !== municipality_insee_code
) {
return await getWeatherAlertForJ1({
municipality_insee_code: municipality.COMPARENT,
date_UTC_ISO,
Expand Down
Loading