import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { IAggregatedEmployeeStatistic , IAggregatedEmployeeStatisticFindInput , IEmployeeStatistics , IEmployeeStatisticsFindInput , IMonthAggregatedEmployeeStatisticsFindInput , IMonthAggregatedEmployeeStatistics , IEmployeeStatisticsHistoryFindInput , IEmployeeStatisticsHistory } from '@gauzy/contracts' ; import { Subject } from 'rxjs' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( { providedIn : 'root' } ) export class EmployeeStatisticsService { constructor ( private http ) { } avarageBonus$ = new Subject < number > ( ) ; /**
     * Gets the aggregated statistics for all employees of the organization from the start of time till now.
     * If date is provided in findInput it will return only for the month selected.
     */ getAggregateStatisticsByOrganizationId ( findInput ? ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < IAggregatedEmployeeStatistic > ( `${ API_PREFIX }/employee-statistics/aggregate` , { params : { data } } ) ) ; } param employeeId param findInput returns getStatisticsByEmployeeId ( employeeId , findInput ? ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < IEmployeeStatistics > ( `${ API_PREFIX }/employee-statistics/months/${ employeeId }` , { params : { data } } ) ) ; } param findInput returns getAggregatedStatisticsByEmployeeId ( findInput ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < IMonthAggregatedEmployeeStatistics [ ] > ( `${ API_PREFIX }/employee-statistics/months` , { params : { data } } ) ) ; } param findInput returns getEmployeeStatisticsHistory ( findInput ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < IEmployeeStatisticsHistory [ ] > ( `${ API_PREFIX }/employee-statistics/history` , { params : { data } } ) ) ; } }