Skip to content

Commit

Permalink
#48 delete unused log
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcellino-Palerme committed Jun 24, 2024
1 parent 25d0e1c commit 7bb2bdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
18 changes: 6 additions & 12 deletions server/api/AddSerie.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ export default defineEventHandler(async (event) => {
VALUES ('${body.nameSerie}', NOW(), -1)
RETURNING id`); // -1 is the default value for id_machine
})
.then((respQuery) => {
.then((respQuery:{rows:any[]}) => {
if (respQuery.rows.length === 0) {
throw new Error("Serie not create");
}
idSerie = respQuery.rows[0].id;
console.log(`Serie ${idSerie} created`);
const lPromises = [];
// save each metabolite by daughter solution
console.log("body.daughterGroup", body.daughterGroup);

// save each metabolite by daughter solution
for (const idFile of Object.keys(body.daughterGroup)){
console.log("idFile", idFile);
console.log("body.daughterGroup[idFile]", body.daughterGroup[idFile]);
for(const metabo of body.daughterGroup[idFile]){
lPromises.push(
client.query(`
Expand All @@ -53,9 +48,9 @@ export default defineEventHandler(async (event) => {
// calculate the ratio for each metabolite
return calculateRatioSerie(idSerie);
})
.then((metaRatio) => {
.then((metaRatio:{[key:string]:number}) => {
const lPromises = [];
// save the ratio in the database
// save the ratio in the database
for(const key in metaRatio){
lPromises.push(
client.query(`
Expand All @@ -66,9 +61,8 @@ export default defineEventHandler(async (event) => {
}
return Promise.allSettled(lPromises);
})
.catch((err) => {
console.error("Add serie fail : ", body.name, err);
throw new Error("Add serie fail");
.catch((err:Error) => {
return new Error("Add serie fail", err);
})
.finally(() => {
// close the connection
Expand Down
7 changes: 1 addition & 6 deletions server/api/function/RegSerie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ export async function calculateRatioSerie(idSerie:string):Promise<number | {[key
.then((res) => {
// create array area/expected for each metabolite
const metaAreaExpected: {[key:string]:[number,number][]} = {}
console.log("rows", res);

for(const row of res.rows){
console.log(row);

// if the metabolite is not in the array, create it
if(metaAreaExpected[row.id_mol]===undefined){
// initialize first element to position 0,0
Expand All @@ -36,14 +33,12 @@ export async function calculateRatioSerie(idSerie:string):Promise<number | {[key
}
metaAreaExpected[row.id_mol].push([row.area,row.expected]);
}
console.log(metaAreaExpected);

// caclulate director coefficient of each metabolite
const metaRatio: {[key:string]:number}= {}
for(const key in metaAreaExpected){
// calculate the linear regression
const {m, b} = linearRegression(metaAreaExpected[key]);
console.log(`Metabolite ${key} : m=${m} b=${b}`);
const {m} = linearRegression(metaAreaExpected[key]);
metaRatio[key] = m;
}
return metaRatio
Expand Down

0 comments on commit 7bb2bdb

Please sign in to comment.