This commit is contained in:
bakhirev 2024-11-20 23:47:56 +03:00
parent bd050b0149
commit 500c7a38fc
4 changed files with 23 additions and 13 deletions

File diff suppressed because one or more lines are too long

View file

@ -12,20 +12,20 @@ import { STATUS, WORK_DAYS } from '../contstants';
import { increment } from 'ts/helpers/Math';
function getStatusChart(rows: any[]) {
const order = Object.values(STATUS);
const options = getOptions({ order, limit: 1 });
const details = rows.reduce((acc: any, row: any) => {
if (row.isStaff) increment(acc, STATUS.STAFF);
else if (row.isDismissed) increment(acc, STATUS.DISMISSED);
else increment(acc, STATUS.WORK);
return acc;
}, {});
const order = Object
.values(STATUS)
.filter((key: string) => details[key]);
const options = getOptions({ order, limit: 1 });
return [options, details];
}
function getDaysChart(rows: any[]) {
const order = Object.values(WORK_DAYS);
const options = getOptions({ order, limit: 1, suffix: 'page.team.author.daysChart.item' });
const details = rows.reduce((acc: any, row: any) => {
if (row.daysAll < 183) increment(acc, WORK_DAYS.HALF);
else if (row.daysAll < 365) increment(acc, WORK_DAYS.ONE);
@ -34,6 +34,10 @@ function getDaysChart(rows: any[]) {
else increment(acc, WORK_DAYS.MORE);
return acc;
}, {});
const order = Object
.values(WORK_DAYS)
.filter((key: string) => details[key]);
const options = getOptions({ order, limit: 1, suffix: 'page.team.author.daysChart.item' });
return [options, details];
}

View file

@ -22,8 +22,6 @@ function getStatusChart(rows: any[]) {
}
function getDaysChart(rows: any[]) {
const order = Object.values(WORK_DAYS);
const options = getOptions({ order, limit: 1, suffix: 'page.team.company.daysChart.item' });
const details = rows.reduce((acc: any, row: any) => {
if (row.totalDays < 183) increment(acc, WORK_DAYS.HALF);
else if (row.totalDays < 365) increment(acc, WORK_DAYS.ONE);
@ -32,6 +30,10 @@ function getDaysChart(rows: any[]) {
else increment(acc, WORK_DAYS.MORE);
return acc;
}, {});
const order = Object
.values(WORK_DAYS)
.filter((key: string) => details[key]);
const options = getOptions({ order, limit: 1, suffix: 'page.team.company.daysChart.item' });
return [options, details];
}

View file

@ -13,8 +13,6 @@ import { WORK_DAYS } from '../../Author/contstants';
import { EMPLOYMENTS } from '../contstants';
function getEmploymentsChart(rows: any[]) {
const order = Object.values(EMPLOYMENTS);
const options = getOptions({ order, limit: 1, suffix: 'page.team.department.employments.item' });
const details = rows.reduce((acc: any, row: any) => {
if (!row.isActive) return acc;
if (row.totalWorked <= 1) increment(acc, EMPLOYMENTS.LESS1);
@ -27,12 +25,14 @@ function getEmploymentsChart(rows: any[]) {
else increment(acc, EMPLOYMENTS.MORE);
return acc;
}, {});
const order = Object
.values(EMPLOYMENTS)
.filter((key: string) => details[key]);
const options = getOptions({ order, limit: 1, suffix: 'page.team.department.employments.item' });
return [options, details];
}
function getDaysChart(rows: any[]) {
const order = Object.values(WORK_DAYS);
const options = getOptions({ order, limit: 1, suffix: 'page.team.department.daysChart.item' });
const details = rows.reduce((acc: any, row: any) => {
if (row.totalDays < 183) increment(acc, WORK_DAYS.HALF);
else if (row.totalDays < 365) increment(acc, WORK_DAYS.ONE);
@ -41,6 +41,10 @@ function getDaysChart(rows: any[]) {
else increment(acc, WORK_DAYS.MORE);
return acc;
}, {});
const order = Object
.values(WORK_DAYS)
.filter((key: string) => details[key]);
const options = getOptions({ order, limit: 1, suffix: 'page.team.department.daysChart.item' });
return [options, details];
}