|
|
@@ -1,12 +1,12 @@
|
|
|
const request = require('request-promise');
|
|
|
const humanizeDuration = require('humanize-duration');
|
|
|
|
|
|
-function getTimesheetSummaryTotalsRequest(config, username, password, date) {
|
|
|
+function getTimesheetSummaryTotalsRequest(config, username, date) {
|
|
|
const options = {
|
|
|
uri: `${config.synergist.apiUrl}jsonapi/timesheets.json`,
|
|
|
qs: {
|
|
|
username,
|
|
|
- password,
|
|
|
+ password: config.synergist.password,
|
|
|
date,
|
|
|
user: config.synergist.superuser,
|
|
|
version: config.synergist.version,
|
|
|
@@ -19,9 +19,9 @@ function getTimesheetSummaryTotalsRequest(config, username, password, date) {
|
|
|
}
|
|
|
|
|
|
function makeGetTimesheetCompleted(config, logger, date) {
|
|
|
- return async (shortName, password) => {
|
|
|
+ return async shortName => {
|
|
|
try {
|
|
|
- const response = await getTimesheetSummaryTotalsRequest(config, shortName, password, date);
|
|
|
+ const response = await getTimesheetSummaryTotalsRequest(config, shortName, date);
|
|
|
|
|
|
try {
|
|
|
const data = JSON.parse(response);
|
|
|
@@ -55,10 +55,12 @@ async function getUsersWithMissingTimesheets(config, logger, range, users) {
|
|
|
logger.debug('[SYNERGIST] Getting employee timesheet information...');
|
|
|
const t0 = Date.now();
|
|
|
|
|
|
- const getTimesheetCompleted = makeGetTimesheetCompleted(config, logger, range.start);
|
|
|
+ const startDate = range.start.format('DD/MM/YYYY');
|
|
|
+
|
|
|
+ const getTimesheetCompleted = makeGetTimesheetCompleted(config, logger, startDate);
|
|
|
|
|
|
const results = await Promise.all(users.map(user =>
|
|
|
- getTimesheetCompleted(user.shortName, config.synergist.password)
|
|
|
+ getTimesheetCompleted(user.shortName)
|
|
|
));
|
|
|
|
|
|
const t1 = Date.now();
|