Skip to content

Commit

Permalink
#48 correct when we modify calibration curve without daughter solutio…
Browse files Browse the repository at this point in the history
…n and add it
  • Loading branch information
Marcellino-Palerme committed Jul 25, 2024
1 parent fa17fb6 commit 04d53d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions db/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ AND calib_curves.date_achieve IS NULL
GROUP BY calib_curves.id;

CREATE VIEW view_show_calib_curve AS
SELECT calib_curves.id AS id, calib_curves.name, array_agg(ratio.id_mol) AS metabolite,
SELECT calib_curves.id AS id, calib_curves.name, array_agg(DISTINCT daughter.id_mol) AS metabolite,
calib_curves.date_create, calib_curves.date_achieve
FROM calib_curves
LEFT JOIN ratio ON calib_curves.id = ratio.id_calib_curves
LEFT JOIN daughter ON calib_curves.id = daughter.id_calib_curves
GROUP BY calib_curves.id;

CREATE VIEW view_daughter_file AS
Expand Down
17 changes: 11 additions & 6 deletions server/api/UpdateCalibCurve.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ export default defineEventHandler(async (event) => {
for(const idFile in body.daughters){
// for each metabolite of the daughter solution
for(const daughter of body.daughters[idFile]){
// update concentration
// insert or update concentration
lQueryPromises.push(client.query(`
UPDATE daughter
SET concentration = ${daughter.concentration}
WHERE id_file = ${idFile}
AND id_mol = '${daughter.nameMeta}'
AND id_calib_curves = ${body.idCalibCurve}`
INSERT INTO daughter
(id_file, id_mol, id_calib_curves, area,
concentration)
VALUES
(${idFile}, '${daughter.nameMeta}',
${body.idCalibCurve}, ${daughter.area},
${daughter.concentration})
ON CONFLICT (id_file, id_mol, id_calib_curves)
DO UPDATE SET concentration = ${daughter.concentration},
area = ${daughter.area}`
));
}
}
Expand Down

0 comments on commit 04d53d0

Please sign in to comment.