Skip to content

Commit

Permalink
Merge pull request #2061 from NMDSdevopsServiceAdm/bugfix/regTimeLive
Browse files Browse the repository at this point in the history
Set reg timings live
  • Loading branch information
aaron-russell authored Mar 31, 2020
2 parents 6ba4131 + 195d6b8 commit e3eacd7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"jszip": "^3.2.2",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"moment-timezone": "^0.5.28",
"morgan": "^1.9.1",
"ngx-moment": "^3.4.0",
"notifications-node-client": "^4.6.0",
Expand Down
7 changes: 6 additions & 1 deletion server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,12 @@ const config = convict({
format: String,
default: 'SensitiveSessions'
}
}
},
timezone: {
doc: 'What timezone is the service running in?',
format: String,
default: 'Europe/London'
}
});

// Load environment dependent configuration
Expand Down
13 changes: 8 additions & 5 deletions server/routes/admin/registrations/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// default route for admin/registrations
const express = require('express');
const router = express.Router();
const moment = require('moment-timezone');

const models = require('../../../models');
const moment = require('moment');
const config = require('../../../config/config');

const router = express.Router();

router.route('/').get(async (req, res) => {
try {
Expand Down Expand Up @@ -117,7 +120,7 @@ router.route('/').get(async (req, res) => {
});

for(let i = 0; i < arrToReturn.length; i++){
arrToReturn[i].created = moment(arrToReturn[i].created).format('D/M/YYYY h:mma');
arrToReturn[i].created = moment.utc(arrToReturn[i].created).tz(config.get('timezone')).format('D/M/YYYY h:mma');
//get parent establishment details
if(!arrToReturn[i].email){
let fetchQuery = {
Expand All @@ -134,12 +137,12 @@ router.route('/').get(async (req, res) => {
res.status(200).send(arrToReturn);
}else if(loginReturnArr && !workplaceReturnArr){
loginReturnArr.map(registration => {
registration.created = moment(registration.created).format('D/M/YYYY h:mma');
registration.created = moment.utc(registration.created).tz(config.get('timezone')).format('D/M/YYYY h:mma');
});
res.status(200).send(loginReturnArr);
}else if(!loginReturnArr && workplaceReturnArr){
workplaceReturnArr.map(registration => {
registration.created = moment(registration.created).format('D/M/YYYY h:mma');
registration.created = moment.utc(registration.created).tz(config.get('timezone')).format('D/M/YYYY h:mma');
});
res.status(200).send(workplaceReturnArr);
}else{
Expand Down

0 comments on commit e3eacd7

Please sign in to comment.