Skip to content

Commit

Permalink
fix: index
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudambro committed Apr 1, 2024
1 parent 12a4e6d commit 05599dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- CreateIndex
CREATE INDEX "drinking_water_udi_last_prelevement_code" ON "DrinkingWater"("udi", "last_prelevement_code");
1 change: 1 addition & 0 deletions api-node/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ model DrinkingWater {
all_tests_results Json?
@@index([udi, diffusion_date, validity_start], name: "drinking_water_udi_diffusion_date_validity_start")
@@index([udi, last_prelevement_code], name: "drinking_water_udi_last_prelevement_code")
}

model CronJob {
Expand Down
30 changes: 1 addition & 29 deletions api-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dotenv/config';
import prisma from '~/prisma';
import '~/prisma';

import * as Sentry from '@sentry/node';
import express from 'express';
Expand All @@ -21,35 +21,7 @@ import feedbackRouter from './controllers/feedback.ts';
import notificationRouter from './controllers/notification.ts';
import udiRouter from './controllers/udi.ts';

console.log(
(async () => {
const udis = await prisma.udis.findMany({
select: {
code_udi: true,
},
});
for (const [index, { code_udi }] of Object.entries(udis)) {
if (Number(index) < 15427) continue;
console.log(
'index',
index,
' of all ',
udis.length,
' code_udi',
code_udi,
);
const result = await getDrinkingWaterFromUdi({
date_UTC_ISO: '2022-03-01T00:00:00.000Z',
municipality_insee_code: '12345',
udi: code_udi,
});
console.log('result', result?.j0.summary?.recommendations?.[0]);
}
})(),
);

import packageJson from '../package.json';
import { getDrinkingWaterFromUdi } from './getters/drinking_water.ts';

// Put together a schema
const app = express();
Expand Down

0 comments on commit 05599dd

Please sign in to comment.