예제 #1
0
        public Result <StandardRecord> QueryAndTransform()
        {
            Logger.LogInformation($"Running Query and transform.");
            Query.TargetDate = TargetDate;
            var result = Query.DoQuery();

            var records  = new List <StandardRecord>();
            var relevent = result.Data.FirstOrDefault(d => d.Date == TargetDate.AddDays(-1).Date);

            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_LfdTests
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.LfdTests_Daily
                ,
                Cumulative = relevent?.LfdTests_Cumulative
            });

            return(new Result <StandardRecord>()
            {
                Records = records,
                QueryRecords = new List <QueryRecord>()
                {
                    new QueryRecord()
                    {
                        Name = NameConstants.LookbackQuery_Lfd_Name, Url = result.Url
                    }
                }
            });
        }
예제 #2
0
        private List <DateTime> GetWindow()
        {
            var list = new List <DateTime>();
            var date = TargetDate.AddDays(-10).Date;

            while (date <= TargetDate.Date)
            {
                list.Add(date);
                date = date.AddDays(1);
            }
            return(list);
        }
예제 #3
0
        public QueryResponce <RegionVaccineProgressQueryModel> DoQuery()
        {
            var targetDate = TargetDate.AddDays(-1).Date;

            Query.Options = new QueryOptions()
            {
                Filter = new Filter()
                {
                    AreaType = new AreaType(AreaTypeMetrics.nation),
                    Date     = new DateFilter(targetDate)
                },
            };
            return(Query.DoQuery());
        }
        public QueryResponce <RegionBreakdownQueryModel> DoQuery()
        {
            var targetDate = TargetDate.AddDays(-1).Date;

            Query.Options = new QueryOptions()
            {
                Filter = new Filter()
                {
                    AreaType = new AreaType(AreaTypeMetrics.overview),
                    Date     = new DateFilter(targetDate)
                },
            };
            return(Query.DoQuery());
        }
        public Result <TitleResult> QueryAndTransform()
        {
            Logger.LogInformation($"Running Query and transform.");
            Query.TargetDate = TargetDate;
            var result = Query.DoQuery();

            LookbackJustVaccineQuery.TargetDate = TargetDate;
            var yesterdayResult = LookbackJustVaccineQuery.DoQuery();

            var relevent          = result.Data.Where(d => d.Date == TargetDate).FirstOrDefault();
            var yesterdayRelevent = yesterdayResult.Data.Where(d => d.Date == TargetDate.AddDays(-1).Date).FirstOrDefault();

            var titleResult = new TitleResult()
            {
                TotalCases = new SimpleRecord()
                {
                    Date  = TargetDate,
                    Value = relevent?.Cases_Cumulative
                },
                TotalDeaths = new SimpleRecord()
                {
                    Date  = TargetDate,
                    Value = relevent?.Deaths_Cumulative
                },
                TotalVaccines = new SimpleRecord()
                {
                    Date  = TargetDate,
                    Value = yesterdayRelevent?.FirstDose_Cumulative
                },
                Date = TargetDate
            };

            var list = new List <TitleResult>()
            {
                titleResult
            };

            return(new Result <TitleResult>()
            {
                Records = list,
                QueryRecords = new List <QueryRecord>()
                {
                    new QueryRecord()
                    {
                        Name = NameConstants.DailyQuery_Name, Url = result.Url
                    }
                }
            });
        }
        public QueryResponce <LookbackJustVaccineModel> DoQuery()
        {
            var trueTargetDate = TargetDate.AddDays(0);
            var targetDate     = TargetDate.AddDays(-1);

            Query.Options = new QueryOptions()
            {
                Filter = new Filter()
                {
                    AreaType = new AreaType(AreaTypeMetrics.overview),
                    Date     = new DateFilter(targetDate)
                },
            };
            return(Query.DoQuery());
        }
        public QueryResponce <LookbackEnglandQueryModel> DoQuery()
        {
            var trueTargetDate = TargetDate.AddDays(0);
            var targetDate     = TargetDate.AddDays(-1);

            Query.Options = new QueryOptions()
            {
                Filter = new Filter()
                {
                    AreaType = new AreaType(AreaTypeMetrics.nation),
                    AreaName = new AreaName("England"),
                    Date     = new DateFilter(targetDate)
                },
            };
            return(Query.DoQuery());
        }
        public Result <RegionRateRecord> Transform(List <Area> regions, QueryResponce <RegionBreakdownQueryModel> resultToday, QueryResponce <RegionBreakdownQueryModel> resultYesterday)
        {
            var records          = new List <RegionRateRecord>();
            var todayRecords     = resultToday.Data.Where(d => d.Date == TargetDate.Date).ToList();
            var yesterdayRecords = resultYesterday.Data.Where(d => d.Date == TargetDate.AddDays(-1).Date).ToList();

            foreach (var region in regions)
            {
                var today     = todayRecords.FirstOrDefault(r => r.Code == region.Code);
                var yesterday = yesterdayRecords.FirstOrDefault(r => r.Code == region.Code);

                var record = new RegionRateRecord()
                {
                    Name  = region.DisplayName(),
                    Date  = TargetDate.Date,
                    Daily = today?.DailyCases,
                    Delta = today?.DailyCases - yesterday?.DailyCases
                };
                SetRatio(region, record);
                records.Add(record);
            }
            records = records.OrderByDescending(r => r.Rate).ToList();

            return(new Result <RegionRateRecord>()
            {
                Records = records,
                QueryRecords = new List <QueryRecord>()
                {
                    new QueryRecord()
                    {
                        Name = QueryNameToday, Url = resultToday.Url
                    },
                    new QueryRecord()
                    {
                        Name = QueryNameYesterday, Url = resultYesterday.Url
                    }
                }
            });
        }
예제 #9
0
 private IrregularRecord GetRecord(string name, NonDailyQueryModel record, long?value)
 {
     if (record != null)
     {
         return(new IrregularRecord()
         {
             Date = record.Date,
             LastReportedTotal = value,
             Name = name,
             IsNew = (record.Date == TargetDate || record.Date == TargetDate.AddDays(-1))
         });
     }
     else
     {
         return(null);
         //return new IrregularRecord()
         //{
         //    Date = DateTime.MinValue,
         //    LastReportedTotal = null,
         //    Name = name
         //};
     }
 }
예제 #10
0
        public Result <RegionProgressRecord> Transform(List <Area> regions, QueryResponce <RegionVaccineProgressQueryModel> resultToday, QueryResponce <RegionVaccineProgressQueryModel> resultYesterday)
        {
            var records          = new List <RegionProgressRecord>();
            var todayRecords     = resultToday.Data.Where(d => d.Date == TargetDate.Date.AddDays(-1).Date).ToList();
            var yesterdayRecords = resultYesterday.Data.Where(d => d.Date == TargetDate.AddDays(-2).Date).ToList();

            foreach (var region in regions)
            {
                var today       = todayRecords.FirstOrDefault(r => r.Code == region.Code);
                var yesterday   = yesterdayRecords.FirstOrDefault(r => r.Code == region.Code);
                var regionStats = region;

                long?  firstDoseTotal = null;
                long?  firstDoseNew   = null;
                double?firstDosePercentageProgress = null;
                double?firstDoseIncrease           = null;

                if (today?.FirstDoseNew != null && today?.FirstDoseCum != null)
                {
                    firstDoseTotal = today?.FirstDoseCum;
                    firstDoseNew   = today?.FirstDoseNew;
                    firstDosePercentageProgress = ((double)today.FirstDoseCum / (double)regionStats.TwelveOrMorePopulation()) * (double)100;

                    if (yesterday?.FirstDoseCum != null)
                    {
                        var percentageYesterday = ((double)yesterday.FirstDoseCum / (double)regionStats.TwelveOrMorePopulation()) * (double)100;
                        firstDoseIncrease = firstDosePercentageProgress - percentageYesterday;
                    }
                }

                long?  secondDoseTotal = null;
                long?  secondDoseNew   = null;
                double?secondDosePercentageProgress = null;
                double?secondDoseIncrease           = null;

                if (today?.SecondDoseNew != null && today?.SecondDoseCum != null)
                {
                    secondDoseTotal = today?.SecondDoseCum;
                    secondDoseNew   = today?.SecondDoseNew;
                    secondDosePercentageProgress = ((double)today.SecondDoseCum / (double)regionStats.TwelveOrMorePopulation()) * (double)100;

                    if (yesterday?.SecondDoseCum != null)
                    {
                        var percentageYesterday = ((double)yesterday.SecondDoseCum / (double)regionStats.TwelveOrMorePopulation()) * (double)100;
                        secondDoseIncrease = secondDosePercentageProgress - percentageYesterday;
                    }
                }

                long?  thirdDoseTotal = null;
                long?  thirdDoseNew   = null;
                double?thirdDosePercentageProgress = null;
                double?thirdDoseIncrease           = null;

                if (today?.ThirdDoseNew != null && today?.ThirdDoseCum != null)
                {
                    thirdDoseTotal = today?.ThirdDoseCum;
                    thirdDoseNew   = today?.ThirdDoseNew;
                    thirdDosePercentageProgress = ((double)today.ThirdDoseCum / (double)regionStats.TwelveOrMorePopulation()) * (double)100;

                    if (yesterday?.ThirdDoseCum != null)
                    {
                        var percentageYesterday = ((double)yesterday.ThirdDoseCum / (double)regionStats.TwelveOrMorePopulation()) * (double)100;
                        thirdDoseIncrease = thirdDosePercentageProgress - percentageYesterday;
                    }
                }

                var record = new RegionProgressRecord()
                {
                    Name                        = region.DisplayName(),
                    Date                        = TargetDate.Date,
                    FirstDoseTotal              = firstDoseTotal,
                    FirstDoseDailyIncrease      = firstDoseNew,
                    FirstDosePercentageProgress = firstDosePercentageProgress,
                    FirstDoseIncrease           = firstDoseIncrease,

                    SecondDoseTotal              = secondDoseTotal,
                    SecondDoseDailyIncrease      = secondDoseNew,
                    SecondDosePercentageProgress = secondDosePercentageProgress,
                    SecondDoseIncrease           = secondDoseIncrease,

                    ThirdDoseTotal              = thirdDoseTotal,
                    ThirdDoseDailyIncrease      = thirdDoseNew,
                    ThirdDosePercentageProgress = thirdDosePercentageProgress,
                    ThirdDoseIncrease           = thirdDoseIncrease
                };
                records.Add(record);
            }
            records = records.OrderByDescending(r => r.FirstDosePercentageProgress).ToList();

            return(new Result <RegionProgressRecord>()
            {
                Records = records,
                QueryRecords = new List <QueryRecord>()
                {
                    new QueryRecord()
                    {
                        Name = QueryNameToday, Url = resultToday.Url
                    },
                    new QueryRecord()
                    {
                        Name = QueryNameYesterday, Url = resultYesterday.Url
                    }
                }
            });
        }
예제 #11
0
        public Result <StandardRecord> QueryAndTransform()
        {
            Logger.LogInformation($"Running Query and transform.");
            Query.TargetDate = TargetDate;
            var result = Query.DoQuery();

            var records  = new List <StandardRecord>();
            var relevent = result.Data.FirstOrDefault(d => d.Date == TargetDate.AddDays(-1).Date);

            //records.Add(new StandardRecord()
            //{
            //    Name = NameConstants.LookbackQuery_FirstDose
            //    ,
            //    Date = TargetDate.AddDays(-1).Date
            //    ,
            //    Daily = relevent?.FirstDose?.Daily
            //    ,
            //    Cumulative = relevent?.FirstDose?.Cumulative
            //});

            //records.Add(new StandardRecord()
            //{
            //    Name = NameConstants.LookbackQuery_SecondDose
            //    ,
            //    Date = TargetDate.AddDays(-1).Date
            //    ,
            //    Daily = relevent?.SecondDose?.Daily
            //    ,
            //    Cumulative = relevent?.SecondDose?.Cumulative
            //});

            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_Pillar1
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.Pillar1_Daily
                ,
                Cumulative = relevent?.Pillar1_Cumulative
            });
            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_Pillar2
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.Pillar2_Daily
                ,
                Cumulative = relevent?.Pillar2_Cumulative
            });
            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_Pillar3
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.Pillar3_Daily
                ,
                Cumulative = relevent?.Pillar3_Cumulative
            });
            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_Pillar4
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.Pillar4_Daily
                ,
                Cumulative = relevent?.Pillar4_Cumulative
            });
            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_PillarAll
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.PillarAll_Daily
                ,
                Cumulative = relevent?.PillarAll_Cumulative
            });
            records.Add(new StandardRecord()
            {
                Name = NameConstants.LookbackQuery_PcrTests
                ,
                Date = TargetDate.AddDays(-1).Date
                ,
                Daily = relevent?.PcrTests_Daily
                ,
                Cumulative = relevent?.PcrTests_Cumulative
            });


            return(new Result <StandardRecord>()
            {
                Records = records,
                QueryRecords = new List <QueryRecord>()
                {
                    new QueryRecord()
                    {
                        Name = NameConstants.LookbackQuery_Name, Url = result.Url
                    }
                }
            });
        }