public async Task OnGet() { newStamp = DateTime.Now.ToUniversalTime(); // Geting new data List <Contention> addOn = await FetchDataService.getData <Contention>(oldStamp, newStamp); foreach (Contention c in addOn) { // When there is start event, create a new Client_Contention object and add it to contentionTracker if (c.type.Equals("Start")) { Client_Contention clientC = new Client_Contention(c); contentionTracker[c.id] = clientC; contentions.Add(clientC); } // When there is a stop event, remove associated contention (by looking at id) from contentionTracker, // update the Client_Contention to include stop event and update contentions list else if (c.type.Equals("Stop")) { Client_Contention clientC = contentionTracker[c.id]; contentions.Remove(clientC); clientC.updateEndTimestamp(c.timestamp); contentions.Add(clientC); } } contentions.OrderBy(c => c.StartTimestamp).ToList(); // Updating contentions so that is sorted by time contentions.Reverse(); // Updating contentions so that the most current contentions are shown first totalContentions = contentions.Count; updateAvg(); }
public async Task OnGet() { newStamp = DateTime.Now.ToUniversalTime(); List <Contention> addOn = await FetchDataService.getUpdatedData <Contention>(oldStamp, newStamp); foreach (Contention c in addOn) { if (c.type.Equals("Start")) { Client_Contention clientC = new Client_Contention(c); contentionTracker[c.id] = clientC; contentions.Add(clientC); } else if (c.type.Equals("Stop")) { Client_Contention clientC = contentionTracker[c.id]; contentions.Remove(clientC); clientC.updateEndTimestamp(c.timestamp); contentions.Add(clientC); } } contentions.OrderBy(c => c.StartTimestamp).ToList(); // updating http so that is sorted by time contentions.Reverse(); // updating http so that the most current http requests are shown first totalContentions = contentions.Count; updateAvg(); }