Skip to content

Commit

Permalink
Fixing for Oracle timestamps and boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
datajohnson committed Jun 3, 2024
1 parent 2140d73 commit a8d22eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
24 changes: 8 additions & 16 deletions api/src/routes/report-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import express, { Request, Response } from "express";
import { ReportService } from "../services";
import { DateTime } from "luxon";
import { db as knex } from "../data";
import { DB_CLIENT } from "../config";

export const reportRouter = express.Router();
const db = new ReportService();
Expand All @@ -16,24 +17,15 @@ reportRouter.post("/", async (req: Request, res: Response) => {
req.body.email = req.user.email;
req.body.status = "Initial Report";

let { createDate } = req.body;
let { createDate, date } = req.body;

//console.log("CREATEDATE", createDate);
let cVal = DateTime.fromISO(createDate);
let dVal = DateTime.fromISO(date);

let dVal = DateTime.fromISO(createDate);

//let formatted = dVal.toFormat("YYYY-MM-DD hh");
console.log("FORMAT", dVal.toFormat("yyyy-MM-dd HH:mm:ss"));

//TIMESTAMP 'YYYY-MM-DD HH24:MI:SS.FF'

//console.log(dVal);
//console.log("ISO", dVal.toISO());
//console.log("SQL", dVal.toSQL());
//req.body.date = dVal.toISO();

req.body.createDate = knex.raw(`TO_TIMESTAMP('${dVal.toFormat("yyyy-MM-dd HH:mm:ss")}', 'YYYY-MM-DD HH24:MI:SS')`);
delete req.body.date;
if (DB_CLIENT == "oracledb") {
req.body.createDate = knex.raw(`TO_TIMESTAMP('${cVal.toFormat("yyyy-MM-dd HH:mm:ss")}', 'YYYY-MM-DD HH24:MI:SS')`);
req.body.date = knex.raw(`TO_TIMESTAMP('${dVal.toFormat("yyyy-MM-dd HH:mm:ss")}', 'YYYY-MM-DD HH24:MI:SS')`);
}

console.log("INSERTING REPORT", req.body);

Expand Down
4 changes: 2 additions & 2 deletions web/src/components/incident/CreatePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
<v-label> Was Supervisor notified of this event?</v-label>

<v-radio-group inline v-model="report.supervisorNotified" hide-details>
<v-radio value="Yes" label="Yes" class="mr-5" hide-details />
<v-radio value="No" label="No" hide-details />
<v-radio value="1" label="Yes" class="mr-5" hide-details />
<v-radio value="0" label="No" hide-details />
</v-radio-group>

<div class="d-flex">
Expand Down

0 comments on commit a8d22eb

Please sign in to comment.