public async Task PreloadCache() { var tasks = new List <Task>(); tasks.Add(_client.getFootballers()); tasks.Add(_client.getBootstrapStatic()); await Task.WhenAll(tasks); }
public async Task Init() { _bootstrap = await _client.getBootstrapStatic(); _live = await _client.getLiveData(_gameweek); _fixtures = await _client.GetFixtures(_gameweek); }
private async Task <Event> getCurrentEvent() { var boot = await _client.getBootstrapStatic(); int currentEvent = boot.currentEvent; foreach (Event ev in boot.events) { if (ev.id == currentEvent) { return(ev); } } _log.Error("Unable to find current event. Defaulting to 1"); return(boot.events.First()); }
public async Task Process() { var bs = await _client.getBootstrapStatic(); var currEvent = bs.events.FirstOrDefault(ev => ev.is_current); var gw = currEvent.id; var currentLive = await _client.getLiveData(gw); var previousTimeline = await ReadPreviousTimeline(gw); var newTimeline = new GameweekTimeline(previousTimeline, currentLive.elements.Select(el => new TimelineLiveElement(el)).ToList()); // Find and log differences between previous timeline and current live var diffs = FindAllPlayerDifferences(previousTimeline, currentLive); var timestamp = DateTime.Now; var prediction = new List <TimelineLiveElement>(); var predictor = new TimelinePredictor(gw, _client); await predictor.Init(); foreach (var element in bs.elements) { var liveElementBase = currentLive.elements.FirstOrDefault(e => e.id == element.id); var liveElement = liveElementBase != null ? new TimelineLiveElement(liveElementBase) : new TimelineLiveElement() { id = element.id }; prediction.Add(await predictor.Predict(liveElement)); } newTimeline.prediction = prediction; var predictionDiff = FindAllPlayerPredictionDifferences(previousTimeline != null ? previousTimeline.prediction : new List <TimelineLiveElement>(), newTimeline.prediction); Console.WriteLine($"Diffs: {diffs.Count}"); Console.WriteLine($"PredictionDiffs: {predictionDiff.Count}"); if (diffs.Count > 0 || predictionDiff.Count > 0) { newTimeline.timeline.Add(new GameweekTimelineEntry() { timestamp = timestamp, diff = diffs, predictionDiff = predictionDiff }); await WriteTimeline(gw, newTimeline); } }
public async Task <Event> GetEvent(int gameweek) { var boot = await _client.getBootstrapStatic(); return(boot.events.Where(e => e.id == gameweek).First()); }