コード例 #1
0
        public async Task <IActionResult> Index()
        {
            var from = DateTime.MinValue;
            var to   = DateTime.MaxValue;

            var total = await _analyticStore.CountAsync(from, to);

            if (total == 0)
            {
                await LoadDemoData(_analyticStore);
            }

            var stat = new WebStat
            {
                TotalServed     = await _analyticStore.CountAsync(from, to),
                UniqueVisitors  = await _analyticStore.CountUniqueIndentitiesAsync(from, to),
                DailyAverage    = await _analyticStore.DailyAverage(from, to),
                DailyServed     = await _analyticStore.DailyServed(from, to),
                HourlyServed    = await _analyticStore.HourlyServed(from, to),
                ServedByCountry = await _analyticStore.ServedByCountry(from, to),
                UrlServed       = await _analyticStore.UrlServed(from, to),
                Requests        = await _analyticStore.InTimeRange(DateTime.Now - TimeSpan.FromDays(1), DateTime.Now)
            };

            return(View(stat));
        }
コード例 #2
0
 public static async Task <IEnumerable <(string Country, long Served)> > ServedByCountry
     (this IAnalyticStore analyticStore, DateTime from, DateTime to)
 {
     return((await analyticStore.InTimeRange(from, to))
            .GroupBy(x => x.CountryCode)
            .Select(x => (Country.FromCode(x.Key).CommonName, x.LongCount())));
 }
コード例 #3
0
 public static async Task <IEnumerable <(string Url, long Served)> > UrlServed
     (this IAnalyticStore analyticStore, DateTime from, DateTime to)
 {
     return((await analyticStore.InTimeRange(from, to))
            .GroupBy(x => x.Path)
            .Select(x => (x.Key, x.LongCount())));
 }
コード例 #4
0
 public static async Task <IEnumerable <(int Hour, long Served)> > HourlyServed
     (this IAnalyticStore analyticStore, DateTime from, DateTime to)
 {
     return((await analyticStore.InTimeRange(from, to))
            .GroupBy(x => x.Timestamp.Hour)
            .Select(x => (x.Key, x.LongCount())));
 }
コード例 #5
0
        public static async Task <IEnumerable <(DateTime Day, long Served)> > DailyServed(this IAnalyticStore analyticStore, DateTime from, DateTime to)
        {
            var r = (await analyticStore.InTimeRange(from, to)).ToArray();

            return(r.Length > 0
                ? r.GroupBy(x => x.Timestamp.Date)
                   .Select(x => (x.Key, x.LongCount()))
                : new (DateTime Day, long Served)[0]);
コード例 #6
0
        public static async Task <IEnumerable <(string Url, long Served)> > UrlServed(this IAnalyticStore analyticStore, DateTime from, DateTime to)
        {
            if (analyticStore == null)
            {
                throw new ArgumentNullException(nameof(analyticStore));
            }

            var r = (await analyticStore.InTimeRange(from, to).ConfigureAwait(true)).ToArray();

            return(r.Length > 0
                ? r.GroupBy(x => x.Path)
                   .Select(x => (x.Key, x.LongCount()))
                : Array.Empty <(string Url, long Served)>());
        }
コード例 #7
0
        public async Task <ActionResult> Index()
        {
            var from = DateTime.MinValue;
            var to   = DateTime.MaxValue;

            var stat = new WebStat
            {
                TotalServed     = await _store.CountAsync(from, to),
                UniqueVisitors  = await _store.CountUniqueIndentitiesAsync(from, to),
                DailyAverage    = await _store.DailyAverage(from, to),
                DailyServed     = await _store.DailyServed(from, to),
                HourlyServed    = await _store.HourlyServed(from, to),
                ServedByCountry = await _store.ServedByCountry(from, to),
                UrlServed       = await _store.UrlServed(from, to),
                Requests        = (await _store.InTimeRange(DateTime.Now - TimeSpan.FromMinutes(30), DateTime.Now))
                                  .OrderByDescending(x => x.Timestamp)
            };

            return(View(stat));
        }
コード例 #8
0
 public Task <IEnumerable <WebRequest> > InTimeRange(DateTime from, DateTime to) => store.InTimeRange(from, to);