Example #1
0
        public void TestGetEmailMemberUnlockings()
        {
            var channel = _channelsQuery.GetChannel("Web");
            var app     = _channelsQuery.GetChannelApp(channel.Id, "Web");

            Assert.AreEqual(0, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            // Make some contacts.

            var employer1 = _employersCommand.CreateTestEmployer(1, _organisationsCommand.CreateTestOrganisation(1));

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer1.Id
            });
            var employer2 = _employersCommand.CreateTestEmployer(2, _organisationsCommand.CreateTestOrganisation(2));

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <ContactCredit>().Id, OwnerId = employer2.Id
            });

            var member1 = _membersCommand.CreateTestMember(1);

            _userAccountsCommand.EnableUserAccount(member1, Guid.NewGuid());
            member1 = _membersQuery.GetMember(member1.Id);

            var member2 = _membersCommand.CreateTestMember(2);

            _userAccountsCommand.EnableUserAccount(member2, Guid.NewGuid());
            member2 = _membersQuery.GetMember(member2.Id);

            var member3 = _membersCommand.CreateTestMember(3);

            _userAccountsCommand.EnableUserAccount(member3, Guid.NewGuid());
            member3 = _membersQuery.GetMember(member3.Id);

            _employerMemberViewsCommand.AccessMember(app, employer1, _employerMemberViewsQuery.GetProfessionalView(employer1, member1), MemberAccessReason.MessageSent);
            Assert.AreEqual(1, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            _employerMemberViewsCommand.AccessMember(app, employer1, _employerMemberViewsQuery.GetProfessionalView(employer1, member2), MemberAccessReason.MessageSent);
            Assert.AreEqual(2, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            _employerMemberViewsCommand.AccessMember(app, employer2, _employerMemberViewsQuery.GetProfessionalView(employer2, member1), MemberAccessReason.MessageSent);
            Assert.AreEqual(3, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);

            _employerMemberViewsCommand.AccessMember(app, employer2, _employerMemberViewsQuery.GetProfessionalView(employer2, member3), MemberAccessReason.MessageSent);
            Assert.AreEqual(4, _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(channel, DayRange.Today).MessagesSent);
        }
Example #2
0
        DailyReport IDailyReportsQuery.GetDailyReport(DayRange day)
        {
            var week  = new DateTimeRange(day.Start.Value.AddDays(-7), day.End.Value);
            var month = new DateTimeRange(day.Start.Value.AddMonths(-1), day.End.Value);

            var web      = _channelsQuery.GetChannel("Web");
            var api      = _channelsQuery.GetChannel("API");
            var channels = new[] { web, api };

            var userTypes = new[] { UserType.Member, UserType.Employer, UserType.Administrator, UserType.Custodian };

            return(new DailyReport
            {
                Day = day,
                OpenJobAds = _jobAdReportsQuery.GetOpenJobAds(),
                ResumeSearchAlerts = _memberSearchReportsQuery.GetMemberSearchAlerts(),
                JobSearchAlerts = _jobAdSearchReportsQuery.GetJobAdSearchAlerts(),
                JobSearches = _jobAdSearchReportsQuery.GetJobAdSearches(day),
                InternalJobApplications = _jobAdReportsQuery.GetInternalApplications(day),
                ExternalJobApplications = _jobAdReportsQuery.GetExternalApplications(day),
                InvitationsSent = _networkingReportsQuery.GetInvitationsSent(day),
                InvitationsAccepted = _networkingReportsQuery.GetInvitationsAccepted(day),
                AcceptanceRateLast48Hours = (int)_networkingReportsQuery.Get48HourInvitationAcceptancePercent(),
                AcceptanceRatePreviousMonth = (int)_networkingReportsQuery.GetMonthlyInvitationAcceptancePercent(),

                MemberReport = new MemberReport
                {
                    Total = _accountReportsQuery.GetUsers(UserType.Member, day.End.Value),
                    Enabled = _accountReportsQuery.GetEnabledUsers(UserType.Member, day.End.Value),
                    Active = _accountReportsQuery.GetActiveUsers(UserType.Member, day.End.Value),
                    New = _accountReportsQuery.GetNewUsers(UserType.Member, day),
                },

                ResumeReport = new ResumeReport
                {
                    Total = _resumeReportsQuery.GetResumes(day.End.Value),
                    Searchable = _resumeReportsQuery.GetSearchableResumes(day.End.Value),
                    New = _resumeReportsQuery.GetNewResumes(day),
                    Uploaded = _resumeReportsQuery.GetUploadedResumes(day),
                    Reloaded = _resumeReportsQuery.GetReloadedResumes(day),
                    Edited = _resumeReportsQuery.GetEditedResumes(day),
                    Updated = _resumeReportsQuery.GetUpdatedResumes(day),
                },

                // Logins.

                DailyLogIns = (from u in userTypes select new { UserType = u, LogIns = _accountReportsQuery.GetLogIns(u, day) }).ToDictionary(x => x.UserType, x => x.LogIns),
                WeeklyLogIns = (from u in userTypes select new { UserType = u, LogIns = _accountReportsQuery.GetLogIns(u, week) }).ToDictionary(x => x.UserType, x => x.LogIns),
                MonthlyLogIns = (from u in userTypes select new { UserType = u, LogIns = _accountReportsQuery.GetLogIns(u, month) }).ToDictionary(x => x.UserType, x => x.LogIns),

                // Member search reports.

                MemberSearchReports = (from c in channels
                                       select new
                {
                    c.Name,
                    Report = new MemberSearchReport
                    {
                        TotalSearches = _memberSearchReportsQuery.GetMemberSearches(c, day),
                        FilterSearches = _memberSearchReportsQuery.GetFilterMemberSearches(c, day),
                        SavedSearches = _memberSearchReportsQuery.GetSavedMemberSearches(c, day),
                        AnonymousSearches = _memberSearchReportsQuery.GetAnonymousMemberSearches(c, day),
                    }
                }).ToDictionary(x => x.Name, x => x.Report),

                MemberViewingReports = (from c in channels
                                        select new
                {
                    c.Name,
                    Report = _employerMemberAccessReportsQuery.GetEmployerMemberViewingReport(c, day),
                }).ToDictionary(x => x.Name, x => x.Report),

                MemberAccessReports = (from c in channels
                                       select new
                {
                    c.Name,
                    Report = _employerMemberAccessReportsQuery.GetEmployerMemberAccessReport(c, day),
                }).ToDictionary(x => x.Name, x => x.Report),

                // Others.

                OrderReports = _orderReportsQuery.GetOrderReports(day),
                CommunciationReports = GetCommunicationReports(day),
                PromotionCodeReports = _registrationReportsQuery.GetPromotionCodeReports(day).ToDictionary(x => x.Key, x => x.Value),
                JobAdIntegrationReports = GetJobAdIntegrationReports(day),
            });
        }