예제 #1
0
        private void AnalyseSuspensions(List <Suspension> suspensions)
        {
            TotalSuspensions = suspensions.Count;
            TotalBans        = suspensions.Count(x => x.SuspensionType == SuspensionType.Ban);
            TotalTimeouts    = suspensions.Count(x => x.SuspensionType == SuspensionType.Timeout);

            UniqueUsersSuspensions = suspensions.DistinctBy(x => x.Username).Count();
            UniqueUsersTimeout     = suspensions.DistinctBy(x => x.Username).Count(x => x.SuspensionType == SuspensionType.Timeout);
            UniqueUsersBan         = suspensions.DistinctBy(x => x.Username).Count(x => x.SuspensionType == SuspensionType.Ban);

            var suspensionsOnDate = new Dictionary <DateTime, List <Suspension> >();

            foreach (var group in suspensions.GroupBy(x => x.Timestamp.Date))
            {
                suspensionsOnDate.Add(group.Key, group.ToList());
            }

            foreach (var suspensionDate in suspensionsOnDate)
            {
                SuspensionsPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count);
                BansPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.SuspensionType == SuspensionType.Ban));
                TimeoutsPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.SuspensionType == SuspensionType.Timeout));
            }

            foreach (var group in suspensions.SelectMany(x => x.Tags).GroupBy(x => x.TagId))
            {
                TagAppearances.Add(group.First(), group.Count());
            }
        }
예제 #2
0
        public SystemReport(List <Suspension> unauditedSuspensions, List <Suspension> auditedSuspensions, List <Suspension> systemSuspensions, int uniqueUsers)
        {
            AuditedSuspensions = auditedSuspensions;
            UniqueUsers        = uniqueUsers;
            SystemSuspensions  = systemSuspensions;

            UniqueUsersSuspendedBySystem = systemSuspensions.DistinctBy(x => x.Username, StringComparer.OrdinalIgnoreCase).Count();

            ValidTotalSuspensions = auditedSuspensions.Count(x => !x.InvalidSuspension);
            ValidTotalBans        = auditedSuspensions.Count(x => x.SuspensionType == SuspensionType.Ban && !x.InvalidSuspension);
            ValidTotalTimeouts    = auditedSuspensions.Count(x => x.SuspensionType == SuspensionType.Timeout && !x.InvalidSuspension);

            ValidUniqueUsersSuspensions = auditedSuspensions.DistinctBy(x => x.Username).Count(x => !x.InvalidSuspension);
            ValidUniqueUsersTimeout     = auditedSuspensions.DistinctBy(x => x.Username).Count(x => x.SuspensionType == SuspensionType.Timeout && !x.InvalidSuspension);
            ValidUniqueUsersBan         = auditedSuspensions.DistinctBy(x => x.Username).Count(x => x.SuspensionType == SuspensionType.Ban && !x.InvalidSuspension);

            InvalidTotalSuspensions = auditedSuspensions.Count(x => x.InvalidSuspension);
            InvalidTotalBans        = auditedSuspensions.Count(x => x.SuspensionType == SuspensionType.Ban && x.InvalidSuspension);
            InvalidTotalTimeouts    = auditedSuspensions.Count(x => x.SuspensionType == SuspensionType.Timeout && x.InvalidSuspension);

            InvalidUniqueUsersSuspensions = auditedSuspensions.DistinctBy(x => x.Username).Count(x => x.InvalidSuspension);
            InvalidUniqueUsersTimeout     = auditedSuspensions.DistinctBy(x => x.Username).Count(x => x.SuspensionType == SuspensionType.Timeout && x.InvalidSuspension);
            InvalidUniqueUsersBan         = auditedSuspensions.DistinctBy(x => x.Username).Count(x => x.SuspensionType == SuspensionType.Ban && x.InvalidSuspension);

            var suspensionsOnDate = new Dictionary <DateTime, List <Suspension> >();

            foreach (var group in auditedSuspensions.GroupBy(x => x.Timestamp.Date))
            {
                suspensionsOnDate.Add(group.Key, group.ToList());
            }

            foreach (var suspensionDate in suspensionsOnDate)
            {
                ValidSuspensionsPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => !x.InvalidSuspension));
                ValidBansPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.SuspensionType == SuspensionType.Ban && !x.InvalidSuspension));
                ValidTimeoutsPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.SuspensionType == SuspensionType.Timeout && !x.InvalidSuspension));

                InvalidSuspensionsPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.InvalidSuspension));
                InvalidBansPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.SuspensionType == SuspensionType.Ban && x.InvalidSuspension));
                InvalidTimeoutsPerDay.Add(suspensionDate.Key, suspensionDate.Value.Count(x => x.SuspensionType == SuspensionType.Timeout && x.InvalidSuspension));
            }

            foreach (var group in auditedSuspensions.Where(x => !x.InvalidSuspension).SelectMany(x => x.Tags).GroupBy(x => x.TagId))
            {
                TagAppearances.Add(group.First(), group.Count());
            }

            UnauditedSuspensions = unauditedSuspensions;
        }