Skip to content
Snippets Groups Projects
Commit 88047377 authored by Roberto Junior's avatar Roberto Junior
Browse files

Ajustes nas rotas das telas collaborationscheme e offergoalenrollmentfulltime

parent 1cc5a8a8
No related branches found
No related tags found
1 merge request!1v1
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { map, switchMap } from 'rxjs/operators';
import * as _ from 'lodash';
import { Functionality } from '../../../../shared/entities/functionality/functionality';
......@@ -35,6 +35,8 @@ export class CollaborationSchemeService implements NavigableComponentService {
collaborationScheme.totalCurrentPublicEnrollment = 0;
collaborationScheme.totalProposalPublicEnrollment = 0;
return this.getEnrollmentT4().pipe(
switchMap(enrollmentT4 => {
return this.utilitiesService.getStages().pipe(
map(stages => {
collaborationSchemesByStage = stages.map(stage => new CollaborationSchemesByStage({
......@@ -47,26 +49,27 @@ export class CollaborationSchemeService implements NavigableComponentService {
municipalPercentage: 0
}));
const resultForEnrollmentProjection: EnrollmentProjection = this.sessionService.getItem<EnrollmentProjection>(Functionality.enrollmentProjection.key);
const enrollmentOfferYear: number = this.currentYearService.getEnrollmentCurrentYear();
collaborationScheme.yearCurrentPublicEnrollment = enrollmentOfferYear;
collaborationScheme.yearProposalPublicEnrollment = enrollmentOfferYear + 1;
const resultForEnrollmentProjection: EnrollmentProjection = this.sessionService.getItem<EnrollmentProjection>(Functionality.enrollmentProjection.key);
const resultForViewEnrollmentProjection: ViewEnrollmentByStageSeries =
this.sessionService.getItem<ViewEnrollmentByStageSeries>(Functionality.viewEnrollmentByStageAndSeries.key);
const resultForSelectLocation: SelectLocation = this.sessionService.getItem<SelectLocation>(Functionality.selectLocation.key);
for (const stage of stages) {
const collaboration: CollaborationSchemesByStage = _.find(collaborationSchemesByStage, c => c.id === stage.id);
const stagesAdmDependencyLocationEnrollments = _.filter(enrollmentT4, s => s.education_level_short_id === stage.id);
const enrollmentsByAdmDependencyFederal = _.find(stagesAdmDependencyLocationEnrollments, t => t.adm_dependency_id === AdmDependency.Federal);
const enrollmentsByAdmDependencyState = _.find(stagesAdmDependencyLocationEnrollments, t => t.adm_dependency_id === AdmDependency.State);
const enrollmentsByAdmDependencyMunicipal = _.find(stagesAdmDependencyLocationEnrollments, t => t.adm_dependency_id === AdmDependency.Municipal);
const stagesAdmDependencyLocationEnrollments = _.find(resultForViewEnrollmentProjection.stagesAdmDependencyLocationEnrollments, s => s.id === stage.id);
const totalEnrollmentsByAdmDependencyFederal = enrollmentsByAdmDependencyFederal ? enrollmentsByAdmDependencyFederal.total : 0;
const totalEnrollmentsByAdmDependencyState = enrollmentsByAdmDependencyState ? enrollmentsByAdmDependencyState.total : 0;
const totalEnrollmentsByAdmDependencyMunicipal = enrollmentsByAdmDependencyMunicipal ? enrollmentsByAdmDependencyMunicipal.total : 0;
const totalEnrollmentsByAdmDependencyFederal = _.find(stagesAdmDependencyLocationEnrollments.totalEnrollmentsByAdmDependency, t => t.id === AdmDependency.Federal);
const totalEnrollmentsByAdmDependencyState = _.find(stagesAdmDependencyLocationEnrollments.totalEnrollmentsByAdmDependency, t => t.id === AdmDependency.State);
const totalEnrollmentsByAdmDependencyMunicipal = _.find(stagesAdmDependencyLocationEnrollments.totalEnrollmentsByAdmDependency, t => t.id === AdmDependency.Municipal);
const totalCurrentPublicEnrollment = (totalEnrollmentsByAdmDependencyFederal.quantity + totalEnrollmentsByAdmDependencyState.quantity + totalEnrollmentsByAdmDependencyMunicipal.quantity);
const totalCurrentPublicEnrollment =
(totalEnrollmentsByAdmDependencyFederal + totalEnrollmentsByAdmDependencyState + totalEnrollmentsByAdmDependencyMunicipal);
if (collaboration) {
const enrollmentProjectionByLocation: EnrollmentProjectionByLocation = _.head(resultForEnrollmentProjection.enrollmentsProjectionsByLocations);
......@@ -74,15 +77,15 @@ export class CollaborationSchemeService implements NavigableComponentService {
const stageEnrollment = _.find(enrollmentProjectionByLocation.stagesEnrollments, r => r.id === stage.id);
if (stageEnrollment) {
collaboration.numberCurrentPublicEnrollment = stageEnrollment.totalCurrentOffers;
collaboration.numberCurrentPublicEnrollment = totalCurrentPublicEnrollment;
const stagesEnrollmentsProposal = _.find(enrollmentProjectionByLocation.stagesEnrollments, r => r.id === stage.id);
collaboration.numberProposalPublicEnrollment =
_.find(stagesEnrollmentsProposal.totalEnrollments, s => s.year === collaborationScheme.yearProposalPublicEnrollment).quantity;
collaboration.federalPercentage = ((totalEnrollmentsByAdmDependencyFederal.quantity / totalCurrentPublicEnrollment) * 100);
collaboration.statePercentage = ((totalEnrollmentsByAdmDependencyState.quantity / totalCurrentPublicEnrollment) * 100);
collaboration.municipalPercentage = ((totalEnrollmentsByAdmDependencyMunicipal.quantity / totalCurrentPublicEnrollment) * 100);
collaboration.federalPercentage = ((totalEnrollmentsByAdmDependencyFederal / totalCurrentPublicEnrollment) * 100);
collaboration.statePercentage = ((totalEnrollmentsByAdmDependencyState / totalCurrentPublicEnrollment) * 100);
collaboration.municipalPercentage = ((totalEnrollmentsByAdmDependencyMunicipal / totalCurrentPublicEnrollment) * 100);
}
}
......@@ -95,6 +98,7 @@ export class CollaborationSchemeService implements NavigableComponentService {
return collaborationScheme;
}));
}));
}
getSourceInformations(): Array<Footnote> {
......@@ -111,4 +115,27 @@ export class CollaborationSchemeService implements NavigableComponentService {
}));
return footNotes;
}
getEnrollmentT4(): Observable<any> {
const url: string = `${this.httpService.apiEndpointV1}/enrollment?dims=education_level_short,adm_dependency`;
let filtersLocation: Array<string> = new Array<string>();
const enrollmentCurrentYear: number = this.currentYearService.getEnrollmentCurrentYear();
filtersLocation = this.utilitiesService.getSelectLocationFilter();
let filters: Array<string> = new Array<string>(
`min_year:"${enrollmentCurrentYear}"`,
`max_year:"${enrollmentCurrentYear}"`,
`adm_dependency:["1","2","3"]`
);
filters = filters.concat(filtersLocation);
const options: any = this.httpService.getRequestOptionsWithSearchParams(new Map<string, string>([['filter', filters.join(',')]]));
return this.httpService.get<Array<any>>(`${url}`, options).pipe(
map(diagnosticT4 => diagnosticT4));
}
}
......@@ -57,7 +57,7 @@ export class OfferGoalEnrollmentFullTimeService implements NavigableComponentSer
for (let i = 0; i < diagnostic.length; i++) {
for (let j = 0; j < fullTimes.length; j++) {
if (fullTimes[j].id === diagnostic[i].education_level_short_id) {
const enrollmentStage = _.find(enrollmentT4, rEP => rEP.education_level_mod_name === fullTimes[j].stageDescription);
const enrollmentStage = _.find(enrollmentT4, rEP => rEP.education_level_short_id === fullTimes[j].id);
fullTimes[j].diagnostic = enrollmentStage.total > 0 ?
((diagnostic[i].total / enrollmentStage.total) * 100) : undefined;
}
......@@ -97,7 +97,7 @@ export class OfferGoalEnrollmentFullTimeService implements NavigableComponentSer
getEnrollmentT4(): Observable<any> {
const url: string = `${this.httpService.apiEndpointV1}/enrollment?dims=education_level_mod`;
const url: string = `${this.httpService.apiEndpointV1}/enrollment?dims=education_level_short`;
let filtersLocation: Array<string> = new Array<string>();
const enrollmentCurrentYear: number = this.currentYearService.getEnrollmentCurrentYear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment