public async Task GetStatisticsPerPeriod(StatsCommand statsCommand, Contexts contexts)
        {
            var period = this._reportsService.SelectPeriod(statsCommand);

            if (this.implementedBySplitter.Contains(period))
            {
                var query  = new GetMessagesStatisticsQuery(period);
                var result = await this._queryBus.ExecuteAsync(query);

                var periodStats = result.PeriodStatistics.Where(x => x.Count > 0);
                return;
            }

            var getMessages = new GetMessagesQuery(contexts.Server.Id);
            var messages    = this._queryBus.Execute(getMessages).Messages.ToList();
            var report      = this._reportsService.CreateReport(messages, period);

            Log.Information("Generated statistics for time range {start} {end}", report.TimeRange.Start, report.TimeRange.End);
#if DEBUG
            PrintDebugStats(report);
#endif
            var stream = await this._chartsService.GetImageStatisticsPerPeriod(report);

            var messagesService = this._messagesServiceFactory.Create(contexts);
            await messagesService.SendFile("Statistics.png", stream);
        }
        public async Task <IEnumerable <PeriodStatisticDto> > GetMessagesStatisticsPerDay()
        {
            var query  = new GetMessagesStatisticsQuery(Period.Day);
            var result = await this.queryBus.ExecuteAsync(query);

            return(result.PeriodStatistics.Select(x => new PeriodStatisticDto(x)));
        }
Example #3
0
        public async Task GetStatisticsPerPeriod(DiscordRequest request, Contexts contexts)
        {
            var period = _reportsService.SelectPeriod(request.Arguments.FirstOrDefault()?.Value);

            if (implementedBySplitter.Contains(period))
            {
                var query  = new GetMessagesStatisticsQuery(period);
                var result = await this._queryBus.ExecuteAsync(query);

                var periodStats = result.PeriodStatistics.Where(x => x.Count > 0); // todo
                return;
            }

            var getMessages = new GetMessagesQuery(contexts.Server.Id);
            var messages    = this._queryBus.Execute(getMessages).Messages.ToList();
            var report      = _reportsService.CreateReport(messages, period);

            Log.Information("Generated statistics for time range {start} {end}", report.TimeRange.Start, report.TimeRange.End);
#if DEBUG
            PrintDebugStats(report);
#endif
            var path            = _chartsService.GetImageStatisticsPerPeriod(report);
            var messagesService = _messagesServiceFactory.Create(contexts);
            await messagesService.SendFile(path);
        }