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

@@ -48,9 +48,18 @@ export class SummaryComponent implements OnInit {
this.dsNbJumpByYear = new MatTableDataSource(data);
this.countDatasLoaded++;
});
statsResult.statsForLastYear.subscribe(data => {
this.dsNbJumpByYear = new MatTableDataSource(data);
this.countDatasLoaded++;
});
statsResult.statsForLastMonth.subscribe(data => {
this.dsNbJumpByYear = new MatTableDataSource(data);
this.countDatasLoaded++;
});
}
public allDatasLoaded(): boolean {
return this.countDatasLoaded === 5;
return this.countDatasLoaded === 7;
}
}

View File

@@ -6,6 +6,9 @@ export class StatsResp {
public statsByGear: Observable<Array<StatsByGearResp>>;
public statsByJumpType: Observable<Array<StatsByJumpTypeResp>>;
public statsByYear: Observable<Array<StatsByYearResp>>;
public statsForLastYear: Observable<StatsForLastYearResp>;
public statsForLastMonth: Observable<StatsForLastMonthResp>;
}
export class StatsByDzResp {
@@ -48,3 +51,23 @@ export class StatsByYearResp {
public label: string;
public nb: number;
}
export class StatsForLastYearResp {
constructor(data: any) {
Object.assign(this, data);
}
public byDz: Array<StatsByDzResp>;
public byJumpType: Array<StatsByJumpTypeResp>;
}
export class StatsForLastMonthResp {
constructor(data: any) {
Object.assign(this, data);
}
public byDz: Array<StatsByDzResp>;
public byJumpType: Array<StatsByJumpTypeResp>;
}

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;
})
);
}
}