Skip to content

Commit

Permalink
fix: frozen stats
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn authored Mar 5, 2024
1 parent eaed700 commit 4ccc77e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export abstract class RunningTrackAnalytics {
}

createSample() {
if (this.tempStats.length === 0) {
return;
}

this.samples.push(this.collateSample());
this.tempStats.length = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export class PublishStatsAnalytics extends BaseStatsAnalytics {
});
});

// delete track analytics if track is not present in store and no samples are present
this.trackAnalytics.forEach(trackAnalytic => {
if (!this.store.hasTrack(trackAnalytic.track) && !(trackAnalytic.samples.length > 0)) {
this.trackAnalytics.delete(trackAnalytic.track_id);
}
});

if (shouldCreateSample) {
this.trackAnalytics.forEach(trackAnalytic => {
trackAnalytic.createSample();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ export class SubscribeStatsAnalytics extends BaseStatsAnalytics {
}
});

// delete track analytics if track is not present in store and no samples are present
this.trackAnalytics.forEach(trackAnalytic => {
if (!this.store.hasTrack(trackAnalytic.track) && !(trackAnalytic.samples.length > 0)) {
this.trackAnalytics.delete(trackAnalytic.track_id);
}
});

if (shouldCreateSample) {
this.trackAnalytics.forEach(trackAnalytic => {
trackAnalytic.createSample();
Expand Down

0 comments on commit 4ccc77e

Please sign in to comment.