1e étape pour la récupération des stats

la saison en cours
This commit is contained in:
Sébastien André
2020-02-14 16:47:51 +01:00
parent a1adc417bb
commit b8a1115d6a
3 changed files with 67 additions and 2 deletions

View File

@@ -9,7 +9,9 @@ import {
StatsByAircraftResp,
StatsByJumpTypeResp,
StatsByGearResp,
StatsByYearResp
StatsByYearResp,
StatsForLastMonthResp,
StatsForLastYearResp
} from '../models/stats';
@Injectable()
@@ -30,6 +32,9 @@ export class StatsService {
resultats.statsByGear = this.getStatsByGear();
resultats.statsByYear = this.getStatsByYear();
resultats.statsForLastYear = this.getStatsOfLastYear();
resultats.statsForLastMonth = this.getStatsOfLastMonth();
return resultats;
}
@@ -97,4 +102,32 @@ export class StatsService {
})
);
}
private getStatsOfLastYear(): Observable<StatsForLastYearResp> {
return this.http.get<StatsForLastYearResp>(
`${environment.urlApi}/api/Stats/ForLastYear`,
{ headers: this.headers }
)
.pipe(
map(response => {
const stats = response.map(data => new StatsByDzResp(data));
return stats;
})
);
}
private getStatsOfLastMonth(): Observable<StatsForLastMonthResp> {
return this.http.get<StatsForLastYearResp>(
`${environment.urlApi}/api/Stats/ForLastMonth`,
{ headers: this.headers }
)
.pipe(
map(response => {
const stats = response.map(data => new StatsByDzResp(data));
return stats;
})
);
}
}