From 421c5525926c9a36040aed040d309f3f09e42d7a Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Sun, 29 Sep 2024 10:25:02 -0700 Subject: [PATCH] Attempt to reduce unneeded SQL logging on yahrzeit download --- src/logger.js | 5 +++-- src/yahrzeitCommon.js | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/logger.js b/src/logger.js index 0c115e4..d46426f 100644 --- a/src/logger.js +++ b/src/logger.js @@ -45,8 +45,9 @@ export function makeLogger(logDir) { * @return {Object} */ export function makeLogInfo(ctx) { + const status = ctx.response.status; const info = { - status: ctx.response.status, + status: status, length: ctx.response.length, duration: Date.now() - ctx.state.startTime, ip: getIpAddress(ctx), @@ -104,7 +105,7 @@ export function makeLogInfo(ctx) { } } } - if (ctx.state.mysqlQuery) { + if (ctx.state.mysqlQuery && status !== 200) { info.sql = ctx.state.mysqlQuery; } return info; diff --git a/src/yahrzeitCommon.js b/src/yahrzeitCommon.js index 83e9df5..bf61cce 100644 --- a/src/yahrzeitCommon.js +++ b/src/yahrzeitCommon.js @@ -85,14 +85,18 @@ export async function getYahrzeitDetailsFromDb(ctx, id) { const obj = row.contents; if (!row.downloaded) { const sqlUpdate = 'UPDATE yahrzeit SET downloaded = 1, updated = NOW() WHERE id = ?'; - db.execute2(ctx, {sql: sqlUpdate, values: [id], timeout: 1000}).catch((err) => { - ctx.logger.error(err); - }); + db.execute2(ctx, {sql: sqlUpdate, values: [id], timeout: 1000}) + .then(() => {}) + .catch((err) => { + ctx.logger.error(err); + }); } const sql2 = 'REPLACE INTO yahrzeit_atime (id, ts) VALUES (?, NOW())'; - db.execute2(ctx, {sql: sql2, values: [id], timeout: 1000}).catch((err) => { - ctx.logger.error(err); - }); + db.execute2(ctx, {sql: sql2, values: [id], timeout: 1000}) + .then(() => {}) + .catch((err) => { + ctx.logger.error(err); + }); // convert from 'x' fields back into ymd fields const maxId = getMaxYahrzeitId(obj); for (let i = 1; i <= maxId; i++) {