Ejemplo n.º 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));
        }
 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())));
 }
 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())));
 }
 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())));
 }
        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]);
Ejemplo n.º 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)>());
        }
Ejemplo n.º 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));
        }
 public Task <IEnumerable <WebRequest> > InTimeRange(DateTime from, DateTime to) => store.InTimeRange(from, to);