Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controllers/reportsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const reportsController = function () {
isoComparisonStartDate,
isoComparisonEndDate,
),
overviewReportHelper.getTotalHoursWorked(),
overviewReportHelper.getTotalHoursWorked(isoStartDate, isoEndDate),
overviewReportHelper.getTasksStats(
isoStartDate,
isoEndDate,
Expand Down
21 changes: 14 additions & 7 deletions src/helpers/overviewReportHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,8 @@
if (weeklyAverage <= 20) return '20';
if (weeklyAverage <= 30) return '30';
if (weeklyAverage <= 40) return '40';
return '40+';
if (weeklyAverage <= 50) return '50';
return '50+';
}

/**
Expand All @@ -1367,7 +1368,7 @@
* - Week is Sunday to Saturday
* - Count week only if 4+ days in range (exception: current week always counts)
* - Round user's average to upper bucket limit
* - Buckets: 10, 20, 30, 40, 40+
* - Buckets: 10, 20, 30, 40, 50, 50+
*/
async function getHoursStats(startDate, endDate, comparisonStartDate, comparisonEndDate) {
// Validate date parameters
Expand Down Expand Up @@ -1473,7 +1474,8 @@
20: 0,
30: 0,
40: 0,
'40+': 0,
50: 0,
'50+': 0,
};

for (const bucket of userBuckets) {
Expand All @@ -1486,7 +1488,8 @@
{ _id: '20', count: bucketCounts['20'] },
{ _id: '30', count: bucketCounts['30'] },
{ _id: '40', count: bucketCounts['40'] },
{ _id: '40+', count: bucketCounts['40+'] },
{ _id: '50', count: bucketCounts['50'] },
{ _id: '50+', count: bucketCounts['50+'] },
];

return hoursStats;
Expand All @@ -1499,9 +1502,13 @@
* - Only active users with weeklycommittedHours >= 1 and role != Mentor
* - Excludes entryType of 'person', 'team', or 'project'
*/
async function getTotalHoursWorked() {
const pdtstart = moment().tz('America/Los_Angeles').startOf('week').format('YYYY-MM-DD');
const pdtend = moment().tz('America/Los_Angeles').endOf('week').format('YYYY-MM-DD');
async function getTotalHoursWorked(startDate, endDate) {

Check warning on line 1505 in src/helpers/overviewReportHelper.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move async function 'getTotalHoursWorked' to the outer scope.

See more on https://sonarcloud.io/project/issues?id=OneCommunityGlobal_HGNRest&issues=AZ9d7FkiPHxFEQyEsxI2&open=AZ9d7FkiPHxFEQyEsxI2&pullRequest=2266
const pdtstart = startDate
? moment(startDate).format('YYYY-MM-DD')
: moment().tz('America/Los_Angeles').startOf('week').format('YYYY-MM-DD');
const pdtend = endDate
? moment(endDate).format('YYYY-MM-DD')
: moment().tz('America/Los_Angeles').endOf('week').format('YYYY-MM-DD');

const data = await UserProfile.aggregate([
{
Expand Down
Loading