Exemplo n.º 1
0
        public async Task <IActionResult> Stats()
        {
            const int back = 30;

            var data = new StatsComposite()
            {
                CurrentUser = CurrentUser, Back = back
            };
            await DataHandler.Execute(data);

            var meetingDays = new DayDisplay <MeetingDisplay>()
            {
                DateFrom = DateHelper.FormatDayStart(DateTime.UtcNow.AddDays(-back)),
                Days     = back,
                Source   = data.Result.Meetings
            };
            await LogicHandler.Execute(meetingDays);

            var msgDays = new DayDisplay <MsgDisplay>()
            {
                DateFrom = DateHelper.FormatDayStart(DateTime.UtcNow.AddDays(-back)),
                Days     = back,
                Source   = data.Result.Msgs
            };
            await LogicHandler.Execute(msgDays);

            return(Ok(new StatsViewModel()
            {
                Meetings = meetingDays.Result,
                Messages = msgDays.Result,
                Tenant = data.Result.Tenant,
                Success = true
            }));
        }
Exemplo n.º 2
0
        public async Task StatsCompositeDataTest()
        {
            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();

            var query = new StatsComposite()
            {
                Session = session, CurrentUser = UserData.GetFirst()
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Meetings.Count().Should().Be(0);
            query.Result.Msgs.Count().Should().Be(0);
            Assert.That(query.Result.Tenant, Is.DeepEqualTo(TenantData.GetFirstDisplay()));
            query.Result.Searchable.Should().BeNullOrEmpty();
            query.Result.Searchable = new List <string> {
                "something!"
            };
        }