Exemplo n.º 1
0
        private async Task GenerateStatsForLastDay()
        {
            var servers        = this._discordServersService.GetDiscordServersAsync();
            var yesterdayDate  = DateTime.Today.AddDays(-1);
            var todayDate      = DateTime.Today;
            var yesterdayRange = new TimeRange(yesterdayDate, todayDate);

            await foreach (var server in servers)
            {
                var query = new GetMessagesQuery(server.Id)
                {
                    SentDate = yesterdayRange
                };
                var messages = this._queryBus.Execute(query).Messages.ToList();

                var serverStatistic = new ServerDayStatistic(messages, server.Id, DateTime.Today);
                var command         = new AddServerDayStatisticCommand(serverStatistic);
                await this._commandBus.ExecuteAsync(command);
            }
        }
Exemplo n.º 2
0
 public AddServerDayStatisticCommand(ServerDayStatistic serverDayStatistic)
 {
     this.ServerDayStatistic = serverDayStatistic;
 }