//public InfoByDate<ICollection<ConfigModelRankInfo>> GetLastRank() => RankSyntheticByDate.OrderBy(i => i.DateTime).LastOrDefault() // ?? new InfoByDate<ICollection<ConfigModelRankInfo>>(default(DateTime), // new ConfigModelRankInfo[] { // new ConfigModelRankInfo(RankFormatEnum.Constructed), // new ConfigModelRankInfo(RankFormatEnum.Limited) // }); //public InfoByDate<Inventory> GetLastInventory() => InventoryByDate.OrderBy(i => i.DateTime).LastOrDefault() // ?? new InfoByDate<Inventory>(default(DateTime), new Inventory()); //public InfoByDate<IList<PlayerQuest>> GetLastPlayerQuests() => PlayerQuestsByDate.OrderBy(i => i.DateTime).LastOrDefault() // ?? new InfoByDate<IList<PlayerQuest>>(default(DateTime), new PlayerQuest[0]); //public InfoByDate<Dictionary<DateTime, CrackBoosterRaw>> GetLastCrackedBoosters() => CrackedBoostersByDate.OrderBy(i => i.DateTime).LastOrDefault() // ?? new InfoByDate<Dictionary<DateTime, CrackBoosterRaw>>(default(DateTime), new Dictionary<DateTime, CrackBoosterRaw>()); //public InfoByDate<IList<DraftMakePickRaw>> GetLastDraftPickProgress() => DraftPickProgressByDate.OrderBy(i => i.DateTime).LastOrDefault() // ?? new InfoByDate<IList<DraftMakePickRaw>>(default(DateTime), new DraftMakePickRaw[0]); //public InfoByDate<Dictionary<DateTime, DraftMakePickRaw>> GetLastDraftPickProgressIntraday() => DraftPickProgressIntradayByDate.OrderBy(i => i.DateTime).LastOrDefault() // ?? new InfoByDate<Dictionary<DateTime, DraftMakePickRaw>>(default(DateTime), new Dictionary<DateTime, DraftMakePickRaw>()); public DateSnapshotInfo GetForDate(DateTime dateFor) { var resultForDate = new DateSnapshotInfo { Date = dateFor, MtgaDecksFound = MtgaDecksFoundByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new HashSet <string>(), Collection = CollectionByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <int, int>(), //Decks = DecksByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new ConfigModelRawDeck[0], Inventory = InventoryByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Inventory(), Matches = MatchesByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new List <MatchResult>(), PlayerQuests = PlayerQuestsByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new List <PlayerQuest>(), CrackedBoosters = CrackedBoostersByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, CrackBoosterRaw>(), RankSynthetic = RankSyntheticByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new List <ConfigModelRankInfo>(), PlayerProgress = PlayerProgressByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <string, PlayerProgress>(), PlayerProgressIntraday = PlayerProgressIntradayByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, GetPlayerProgressRaw>(), InventoryUpdates = InventoryUpdatesByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, InventoryUpdatedRaw>(), PostMatchUpdates = PostMatchUpdatesByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, PostMatchUpdateRaw>(), //DraftPickProgress = DraftPickProgressByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new List<DraftMakePickRaw>(), DraftPickProgressIntraday = DraftPickProgressIntradayByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, DraftMakePickRaw>(), VaultsOpened = VaultsOpenedByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, CompleteVaultRaw>(), CollectionIntraday = CollectionIntradayByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, Dictionary <int, int> >(), InventoryIntraday = InventoryIntradayByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, Inventory>(), RankUpdated = RankUpdatedByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, RankUpdatedRaw>(), CombinedRankInfo = CombinedRankInfoByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, GetCombinedRankInfoRaw>(), EventClaimPrize = EventClaimPriceByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, EventClaimPrizeRaw>(), MythicRatingUpdated = MythicRatingUpdatedByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, MythicRatingUpdatedRaw>(), PayEntry = PayEntryByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new Dictionary <DateTime, PayEntryRaw>(), }; //var diff = DiffByDate.SingleOrDefault(i => i.DateTime.Date == dateFor)?.Info ?? new DateSnapshotDiff(); //return (resultForDate, diff); return(resultForDate); }
public ICollection <DateSnapshotInfo> BuildHistory() { var result = new List <DateSnapshotInfo>(); Func <DateTime, DateSnapshotInfo> CreateOrGetDateSnapshotInfo = (date) => { var dateOnly = date.Date; var info = result.FirstOrDefault(i => i.Date == dateOnly); if (info == null) { info = new DateSnapshotInfo(dateOnly); result.Add(info); } return(info); }; //foreach (var dataType in Data.Keys) //{ // foreach (var data in Data[dataType].GetData()) // CreateOrGetDateSnapshotInfo(data.DateTime). //} foreach (var collection in CollectionByDate.GetData()) { CreateOrGetDateSnapshotInfo(collection.DateTime).Collection = collection.Info; } foreach (var inventory in InventoryByDate.GetData()) { CreateOrGetDateSnapshotInfo(inventory.DateTime).Inventory = inventory.Info; } foreach (var progress in PlayerProgressByDate.GetData()) { CreateOrGetDateSnapshotInfo(progress.DateTime).PlayerProgress = progress.Info; } foreach (var progress in PlayerProgressIntradayByDate.GetData()) { CreateOrGetDateSnapshotInfo(progress.DateTime).PlayerProgressIntraday = progress.Info; } foreach (var matches in MatchesByDate.GetData()) { CreateOrGetDateSnapshotInfo(matches.DateTime).Matches = matches.Info; } foreach (var quests in PlayerQuestsByDate.GetData()) { CreateOrGetDateSnapshotInfo(quests.DateTime).PlayerQuests = quests.Info; } foreach (var boosters in CrackedBoostersByDate.GetData()) { CreateOrGetDateSnapshotInfo(boosters.DateTime).CrackedBoosters = boosters.Info; } foreach (var rankInfo in RankSyntheticByDate.GetData()) { CreateOrGetDateSnapshotInfo(rankInfo.DateTime).RankSynthetic = rankInfo.Info; } foreach (var inventoryUpdate in InventoryUpdatesByDate.GetData()) { CreateOrGetDateSnapshotInfo(inventoryUpdate.DateTime).InventoryUpdates = inventoryUpdate.Info; } foreach (var postMatchUpdate in PostMatchUpdatesByDate.GetData()) { CreateOrGetDateSnapshotInfo(postMatchUpdate.DateTime).PostMatchUpdates = postMatchUpdate.Info; } //foreach (var draftPicks in DraftPickProgressByDate.GetData()) // CreateOrGetDateSnapshotInfo(draftPicks.DateTime).DraftPickProgress = draftPicks.Info; foreach (var draftPicks in DraftPickProgressIntradayByDate.GetData()) { CreateOrGetDateSnapshotInfo(draftPicks.DateTime).DraftPickProgressIntraday = draftPicks.Info; } foreach (var payEntry in PayEntryByDate.GetData()) { CreateOrGetDateSnapshotInfo(payEntry.DateTime).PayEntry = payEntry.Info; } foreach (var mythicRatingUpdated in MythicRatingUpdatedByDate.GetData()) { CreateOrGetDateSnapshotInfo(mythicRatingUpdated.DateTime).MythicRatingUpdated = mythicRatingUpdated.Info; } foreach (var combinedRankInfo in CombinedRankInfoByDate.GetData()) { CreateOrGetDateSnapshotInfo(combinedRankInfo.DateTime).CombinedRankInfo = combinedRankInfo.Info; } foreach (var rankUpdated in RankUpdatedByDate.GetData()) { CreateOrGetDateSnapshotInfo(rankUpdated.DateTime).RankUpdated = rankUpdated.Info; } foreach (var eventClaimPrice in EventClaimPriceByDate.GetData()) { CreateOrGetDateSnapshotInfo(eventClaimPrice.DateTime).EventClaimPrize = eventClaimPrice.Info; } foreach (var mtgaDecksfound in MtgaDecksFoundByDate.GetData()) { CreateOrGetDateSnapshotInfo(mtgaDecksfound.DateTime).MtgaDecksFound = mtgaDecksfound.Info; } foreach (var vaultsOpened in VaultsOpenedByDate.GetData()) { CreateOrGetDateSnapshotInfo(vaultsOpened.DateTime).VaultsOpened = vaultsOpened.Info; } foreach (var collectionIntraday in CollectionIntradayByDate.GetData()) { CreateOrGetDateSnapshotInfo(collectionIntraday.DateTime).CollectionIntraday = collectionIntraday.Info; } foreach (var inventoryIntraday in InventoryIntradayByDate.GetData()) { CreateOrGetDateSnapshotInfo(inventoryIntraday.DateTime).InventoryIntraday = inventoryIntraday.Info; } //foreach (var decks in DecksByDate.GetData()) // CreateOrGetDateSnapshotInfo(decks.DateTime).Decks = decks.Info; //ICollection<ConfigModelRankInfo> previousRank = null; foreach (var s in result) { //s.Wins = s.Matches.Count(i => i.Outcome == GameOutcomeEnum.Victory); //s.Losses = s.Matches.Count(i => i.Outcome == GameOutcomeEnum.Defeat); s.OutcomesByMode = s.Matches .GroupBy(i => i.EventName) .ToDictionary(i => i.Key, i => new Outcomes { Wins = i.Count(x => x.Outcome == GameOutcomeEnum.Victory), Losses = i.Count(x => x.Outcome == GameOutcomeEnum.Defeat), }); //s.ConstructedRank = (s.RankInfo.FirstOrDefault(i => i.Format == ConfigModelRankInfoFormatEnum.Constructed) ?? // previousRank?.FirstOrDefault(i => i.Format == ConfigModelRankInfoFormatEnum.Constructed))?.ToString() ?? "N/A"; //s.LimitedRank = (s.RankInfo.FirstOrDefault(i => i.Format == ConfigModelRankInfoFormatEnum.Limited) ?? // previousRank?.FirstOrDefault(i => i.Format == ConfigModelRankInfoFormatEnum.Limited))?.ToString() ?? "N/A"; //previousRank = s.RankInfo; } return(result); }