Skip to content

Conversation

MattiJarvinen
Copy link

@MattiJarvinen MattiJarvinen commented Sep 20, 2021

Use Math.floor to have timestamp (full second) values.
Use Date.now() to get milliseconds elapsed since the UNIX epoch.

parseInt has string parameter and calculation gives a number also most of the time creation of new Date object is unnecessary.

Use Math.floor to have timestamp (full second) values.
Use Date.now() to get milliseconds elapsed since the UNIX epoch.
*/
const postLocation = (akey, locationObj, callback) => {
const now = parseInt(new Date() / 1000);
const now = Math.floor(Date.now() / 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

*/
const postExtended = (akey, extendedObj, callback) => {
const now = parseInt(new Date() / 1000);
const now = Math.floor(Date.now() / 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

*/
const postSoC = (akey, socObj, callback) => {
const now = parseInt(new Date() / 1000);
const now = Math.floor(Date.now() / 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

// last activity track
app.use((req, res, next) => {
if (req.body.akey) db.query('UPDATE accounts SET lastactivity=? WHERE akey=?', [parseInt(new Date() / 1000), req.body.akey], () => next());
if (req.body.akey) db.query('UPDATE accounts SET lastactivity=? WHERE akey=?', [Math.floor(Date.now() / 1000), req.body.akey], () => next());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

], (err, dbRes) => {
let data;
const now = parseInt(new Date() / 1000);
const now = Math.floor(Date.now() / 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

// validate token
if (userObj.token === req.body.token) {
const now = parseInt(new Date() / 1000);
const now = Math.floor(Date.now() / 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


if (!err && dbRes && (dbObj = dbRes[0])) {
const now = parseInt(new Date() / 1000);
const now = Math.floor(Date.now() / 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

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.

1 participant