Skip to content
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

Closed

Conversation

ianLewis8
Copy link
Contributor

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

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the OED Contributing License Agreement and each author is listed in the Description section.

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.

ianLewis8 and others added 5 commits July 30, 2024 15:18
Initial commit towards making a database to store logs.
Almost finished LogMsg database model
forgot to include these in push
added header file
Copy link
Member

@huss huss left a 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)
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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');
Copy link
Member

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 {
/**
Copy link
Member

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);
Copy link
Member

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.
Copy link
Member

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.

@huss
Copy link
Member

huss commented Oct 6, 2024

Noting that @nmqng is working on extending this work.

@nmqng nmqng mentioned this pull request Nov 20, 2024
5 tasks
@huss
Copy link
Member

huss commented Dec 1, 2024

PR #1390 incorporates this work and completes the overall access to log messages. Thus, this PR is being closed.

@huss huss closed this Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants