Skip to content

Commit ba078d9

Browse files
author
Andrea Barbasso
committed
[DSC-2923] fix statistics race condition
1 parent 5029b77 commit ba078d9

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/app/statistics-page/cris-statistics-page/cris-statistics-page.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,14 @@ export class CrisStatisticsPageComponent implements OnInit, OnDestroy {
281281
getReports$(categoryId) {
282282
return this.scope$.pipe(
283283
switchMap((scope) => {
284-
return this.usageReportService.searchStatistics(scope._links.self.href, 0, 50, categoryId, this.parseDate(this.dateFrom), this.parseDate(this.dateTo), true);
284+
// NOTE: do NOT request the points-stripping projection (excludePoints=true) here.
285+
// searchStatistics and loadFullReport()'s findById resolve the SAME usagereports/{uuid}_{type}
286+
// resource, so they share a single object-cache slot (keyed by self href, last-writer-wins).
287+
// A points-less search representation can overwrite the full report loaded by findById
288+
// (e.g. under SSR/TransferState or a re-emitted search), making the table intermittently
289+
// render "No data available" even though the REST response contains points. Keeping the
290+
// full representation here guarantees every cache write for a report includes its points.
291+
return this.usageReportService.searchStatistics(scope._links.self.href, 0, 50, categoryId, this.parseDate(this.dateFrom), this.parseDate(this.dateTo));
285292
}),
286293
);
287294
}

src/app/statistics-page/cris-statistics-page/statistics-chart/statistics-table/statistics-table.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class StatisticsTableComponent extends StatisticsChartDataComponent imple
7979
* Insert table headers
8080
*/
8181
ngOnInit() {
82-
this.hasData = !!this.report && this.report.points.length > 0;
82+
this.hasData = !!this.report && (this.report.points?.length ?? 0) > 0;
8383
if (this.hasData) {
8484
const point = this.report.points[0];
8585
this.headers.push(point.type);

0 commit comments

Comments
 (0)