1e étape pour la récupération des stats
la saison en cours
This commit is contained in:
@@ -48,9 +48,18 @@ export class SummaryComponent implements OnInit {
|
|||||||
this.dsNbJumpByYear = new MatTableDataSource(data);
|
this.dsNbJumpByYear = new MatTableDataSource(data);
|
||||||
this.countDatasLoaded++;
|
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 {
|
public allDatasLoaded(): boolean {
|
||||||
return this.countDatasLoaded === 5;
|
return this.countDatasLoaded === 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ export class StatsResp {
|
|||||||
public statsByGear: Observable<Array<StatsByGearResp>>;
|
public statsByGear: Observable<Array<StatsByGearResp>>;
|
||||||
public statsByJumpType: Observable<Array<StatsByJumpTypeResp>>;
|
public statsByJumpType: Observable<Array<StatsByJumpTypeResp>>;
|
||||||
public statsByYear: Observable<Array<StatsByYearResp>>;
|
public statsByYear: Observable<Array<StatsByYearResp>>;
|
||||||
|
|
||||||
|
public statsForLastYear: Observable<StatsForLastYearResp>;
|
||||||
|
public statsForLastMonth: Observable<StatsForLastMonthResp>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StatsByDzResp {
|
export class StatsByDzResp {
|
||||||
@@ -48,3 +51,23 @@ export class StatsByYearResp {
|
|||||||
public label: string;
|
public label: string;
|
||||||
public nb: number;
|
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>;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import {
|
|||||||
StatsByAircraftResp,
|
StatsByAircraftResp,
|
||||||
StatsByJumpTypeResp,
|
StatsByJumpTypeResp,
|
||||||
StatsByGearResp,
|
StatsByGearResp,
|
||||||
StatsByYearResp
|
StatsByYearResp,
|
||||||
|
StatsForLastMonthResp,
|
||||||
|
StatsForLastYearResp
|
||||||
} from '../models/stats';
|
} from '../models/stats';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -30,6 +32,9 @@ export class StatsService {
|
|||||||
resultats.statsByGear = this.getStatsByGear();
|
resultats.statsByGear = this.getStatsByGear();
|
||||||
resultats.statsByYear = this.getStatsByYear();
|
resultats.statsByYear = this.getStatsByYear();
|
||||||
|
|
||||||
|
resultats.statsForLastYear = this.getStatsOfLastYear();
|
||||||
|
resultats.statsForLastMonth = this.getStatsOfLastMonth();
|
||||||
|
|
||||||
return resultats;
|
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;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user