cron tracks month
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
const db = require(`../config/dbMysqlConn`)
|
||||
const MysqlHelpers = require(`../library/LibMysqlHelper`)
|
||||
const moment = require(`moment`)
|
||||
|
||||
class GpsTracksModels {
|
||||
static DEFAULT_COUNTRY_ID = 1
|
||||
@ -186,6 +187,21 @@ class GpsTracksModels {
|
||||
)
|
||||
}
|
||||
|
||||
if (logs.action == "location") {
|
||||
const date = logs.crt_d
|
||||
const mm = moment.unix(date).format("MM")
|
||||
const yy = moment.unix(date).format("YY")
|
||||
logs.id = resLogs.insertId
|
||||
await MysqlHelpers.queryTrx(
|
||||
conn,
|
||||
`
|
||||
INSERT INTO tracks_${yy}${mm}
|
||||
SET ?
|
||||
`,
|
||||
[logs]
|
||||
)
|
||||
}
|
||||
|
||||
await MysqlHelpers.commit(conn)
|
||||
resolve({
|
||||
type: "success",
|
||||
|
||||
Reference in New Issue
Block a user