-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial LogMsg Database Model #1327
Conversation
Initial commit towards making a database to store logs.
Almost finished LogMsg database model
forgot to include these in push
added header file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to @ianLewis8 for working on this issue. This is a draft so I did a less through review but tried to look at everything. I've made some comments. Some might be able to address now and some are likely for later. I also note that the DB changes need a migration at some point.
log_type, log_message, log_time | ||
FROM logmsg | ||
WHERE log_type = ${logType} | ||
AND log_time >= COALESCE(${startDate}, '-infinity'::TIMESTAMP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that we need to think about allowing long time ranges and defaulting to infinity. This, indirectly, applies to getting them all and some others too.
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
-- Gets logs in table by date range. This is then ordered by time ascending. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is off.
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
-- Gets logs in table by date range. This is then ordered by time ascending. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also limits the type.
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const database = require('./database'); | ||
const { mapToObject, threeDHoleAlgorithm } = require('../util'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several imports are not used. Is it planned?
const sqlFile = database.sqlFile; | ||
|
||
class LogMsg { | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDoc should describe each param. Other ones too.
*/ | ||
async insert(conn) { | ||
const logMsg = this; | ||
await conn.none(sqlFile('logmsg/insert_new_log.sql'), logMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that during testing it needs to be tested if the moment object correctly goes into DB value (and also comes out okay in the other functions to get).
|
||
/** | ||
* Returns a promise to get all of the logs in between two dates. | ||
* If no startDate is specified, all logs before the endDate are returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the SQL may be inclusive not exclusive for the start/end dates.
Noting that @nmqng is working on extending this work. |
PR #1390 incorporates this work and completes the overall access to log messages. Thus, this PR is being closed. |
Description
The current commits I have done include the backbone for a database model that store the Log Messages generated by OED. These can then be queried and displayed to an admin user.
Partly Addresses #712
Type of change
Checklist
Limitations
I am still working on the route for this database but there is also much more to be done. It needs to be only accessible by admins, the actual table could use indexing for faster lookup speed, etc.