Skip to content

Commit

Permalink
Fixed bugs: two stats, one event; running interval
Browse files Browse the repository at this point in the history
  • Loading branch information
JsteReubsSoftware committed Oct 24, 2023
1 parent cb83755 commit 92b5387
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,14 @@ export class ComparePageComponent implements OnInit {
attendance_over_time_data: response.attendance_over_time_data!,
};

this.eventStats.push(stats);
// check if event is not already in the stats array
const eventIndex = this.eventStats.findIndex((item) => {
return item.id === stats.id;
});

if (eventIndex === -1) {
this.eventStats.push(stats);
}
this.renderCharts();
} else {
this.eventsSelected--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
import { IEvent, IImage, IPosition } from '@event-participation-trends/api/event/util';
import { AppApiService } from '@event-participation-trends/app/api';
import { NgIconsModule, provideIcons } from '@ng-icons/core';
import { Router, NavigationStart } from '@angular/router';

import { matSearch, matFilterCenterFocus, matZoomIn, matZoomOut, matRedo } from "@ng-icons/material-icons/baseline";
import { matWarningAmberRound, matErrorOutlineRound } from "@ng-icons/material-icons/round";
Expand Down Expand Up @@ -75,8 +76,17 @@ export class HeatmapContainerComponent implements OnInit{

floorlayoutImages: IImage[] = [];
STALL_IMAGE_URL = 'assets/stall-icon.png';

constructor(private readonly appApiService: AppApiService) {}
flowInterval: any;

constructor(private readonly appApiService: AppApiService, private readonly router: Router) {
router.events.subscribe(event => {
if (event instanceof NavigationStart) {
// This event is triggered when a new route navigation begins.
// You can unsubscribe from your interval here.
clearInterval(this.flowInterval);
}
});
}

async ngOnInit() {
// check if the event has device positions
Expand Down Expand Up @@ -705,17 +715,17 @@ export class HeatmapContainerComponent implements OnInit{
this.changingTimeRange = false;

// increase or decrease the value of the range element by 5 seconds on an interval until the end time is reached
const interval = setInterval(() => {
this.flowInterval = setInterval(() => {
if (this.changingTimeRange) {
clearInterval(interval);
clearInterval(this.flowInterval);
return;
}

if (parseInt(rangeElement.value) < this.totalSeconds) {
this.addFiveSeconds(true);
} else {
this.overTimeRange = true;
clearInterval(interval);
clearInterval(this.flowInterval);
}
}, 500);
}
Expand Down

0 comments on commit 92b5387

Please sign in to comment.