Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 05471e8

Browse files
fix dates in updatePhase
1 parent 3c2f6dc commit 05471e8

File tree

4 files changed

+26
-157
lines changed

4 files changed

+26
-157
lines changed

config/default.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,7 @@ module.exports = {
8282

8383
// V5 Term UUID
8484
SYNC_V5_TERM_UUID: process.env.SYNC_V5_TERM_UUID || '317cd8f9-d66c-4f2a-8774-63c612d99cd4',
85-
SYNC_V5_WRITE_ENABLED: process.env.SYNC_V5_WRITE_ENABLED === 'true' || false
85+
SYNC_V5_WRITE_ENABLED: process.env.SYNC_V5_WRITE_ENABLED === 'true' || false,
86+
87+
TIMEZONE: process.env.TIMEZONE || 'America/New_York'
8688
}

package-lock.json

Lines changed: 11 additions & 155 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"http-json-response": "^1.0.1",
3434
"ifxnjs": "^10.0.5",
3535
"lodash": "^4.17.19",
36+
"moment-timezone": "^0.5.32",
3637
"no-kafka": "^3.4.3",
3738
"q": "^1.5.1",
3839
"showdown": "^1.9.1",

src/services/timelineService.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55
const logger = require('../common/logger')
66
const util = require('util')
7+
const config = require('config')
8+
const momentTZ = require('moment-timezone')
79
const helper = require('../common/helper')
810

911
const QUERY_GET_PHASE_TYPES = 'SELECT phase_type_id, name FROM phase_type_lu'
@@ -13,6 +15,14 @@ const QUERY_GET_TIMELINE_NOTIFICATION_SETTINGS = 'SELECT value FROM project_info
1315
const QUERY_CREATE_TIMELINE_NOTIFICATIONS = 'INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (?, "11", "On", ?, CURRENT, ?, CURRENT)'
1416
const QUERY_UPDATE_TIMELINE_NOTIFICATIONS = 'UPDATE project_info SET value = "On", modify_user = ?, modify_date = CURRENT WHERE project_info_type_id = "11" AND project_id = ?'
1517

18+
/**
19+
* Formats a date into a format supported by ifx
20+
* @param {String} dateStr the date in string format
21+
*/
22+
function formatDate (dateStr) {
23+
return momentTZ.tz(dateStr, config.TIMEZONE).format('YYYY-MM-DD HH:mm:ss')
24+
}
25+
1626
/**
1727
* Prepare Informix statement
1828
* @param {Object} connection the Informix connection
@@ -75,7 +85,7 @@ async function updatePhase (phaseId, challengeLegacyId, startTime, endTime, dura
7585
try {
7686
// await connection.beginTransactionAsync()
7787
const query = await prepare(connection, util.format(QUERY_UPDATE_CHALLENGE_PHASE, phaseId, challengeLegacyId))
78-
result = await query.executeAsync([startTime, endTime, duration, statusTypeId])
88+
result = await query.executeAsync([formatDate(startTime), formatDate(endTime), duration, statusTypeId])
7989
// await connection.commitTransactionAsync()
8090
} catch (e) {
8191
logger.error(`Error in 'updatePhase' ${e}, rolling back transaction`)

0 commit comments

Comments
 (0)