Skip to content

Commit

Permalink
Merge pull request #16 from fermyon/bacongobbler/good-ol-string-repla…
Browse files Browse the repository at this point in the history
…cement

use some good ol' string replacement
  • Loading branch information
kate-goldenring authored Nov 8, 2024
2 parents 3e6cacb + d9dce4b commit 0242b0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions api/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ const getSubsetByDay = (dayString: string, res: ResponseBuilder) => {
res.send()
return;
}
let conn = Sqlite.openDefault();
let result = conn.execute(sqlSelectSubsetByDay, [d]);
let items = result.rows.map(row => { return asNoiseLogItem(row) });
sendJson(res, items)
try {
let conn = Sqlite.openDefault();
let result = conn.execute(sqlSelectSubsetByDay.replace('$1', '\'' + d + '\''), []);
let items = result.rows.map(row => { return asNoiseLogItem(row) });
sendJson(res, items)
} catch (e: any) {
console.log(e);
console.log(e.payload);
}

}
const getSubsetByRelativeTime = (relativeTimeExpression: string, res: ResponseBuilder) => {
Expand Down Expand Up @@ -65,4 +70,4 @@ export {
getAll,
getSubsetByRelativeTime,
getSubsetByDay
}
}
2 changes: 1 addition & 1 deletion mqtt-message-persister/migration.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ CREATE TABLE IF NOT EXISTS noise_log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
source TEXT NOT NULL,
volume INTEGER NOT NULL,
timestamp TEXT NOT NULL
timestamp TIMESTAMP NOT NULL
);

0 comments on commit 0242b0f

Please sign in to comment.