< Summary

Information
Class: OzonOrdersWeb.WebServices.Admin.AdminAuditGridDefinition
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Admin/AdminAuditGridDefinition.cs
Line coverage
95%
Covered lines: 21
Uncovered lines: 1
Coverable lines: 22
Total lines: 40
Line coverage: 95.4%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%1193.33%
ApplyParams(...)100%1212100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/WebServices/Admin/AdminAuditGridDefinition.cs

#LineLine coverage
 1using OzonDomains.Models.Authorization;
 2using OzonOrdersWeb.WebServices.Grid;
 3
 4namespace OzonOrdersWeb.WebServices.Admin;
 5
 6/// <summary>
 7/// Серверный грид журнала аудита /Admin/AuditLog (AG Grid Infinite Row Model поверх <see cref="ServerGridQuery"/>):
 8/// whitelist колонок (colId → выражение EF), поиск и порядок «новые сверху». Журнал растёт без ограничения,
 9/// поэтому фильтры, сортировка и фасеты считаются на сервере по всему набору.
 10/// </summary>
 11public static class AdminAuditGridDefinition
 12{
 113    public static readonly ServerGridDefinition<AuditLogEntry> Entries =
 114        new ServerGridDefinition<AuditLogEntry>
 115            {
 016                DefaultOrder = q => q.OrderByDescending(e => e.Timestamp).ThenByDescending(e => e.Id),
 117                TieBreaker = e => e.Id
 118            }
 119            .Col("id", e => e.Id)
 120            .Col("timestamp", e => e.Timestamp)
 121            .Col("actorUserName", e => e.ActorUserName)
 122            .Col("action", e => e.Action)
 123            .Col("entityType", e => e.EntityType)
 124            .Col("entityId", e => e.EntityId)
 125            .Col("ipAddress", e => e.IpAddress)
 126            .Col("comment", e => e.Comment)
 127            .Search(e => e.ActorUserName, e => e.Action, e => e.EntityType, e => e.EntityId, e => e.Comment);
 28
 29    /// <summary>Параметры прежних ссылок журнала (?action=&amp;entity=&amp;user=) — ограничение набора до фильтров грид
 30    public static IQueryable<AuditLogEntry> ApplyParams(IQueryable<AuditLogEntry> query, IReadOnlyDictionary<string, str
 31    {
 332        if (parameters.TryGetValue("action", out var action) && !string.IsNullOrWhiteSpace(action))
 133            query = query.Where(e => e.Action == action);
 334        if (parameters.TryGetValue("entity", out var entity) && !string.IsNullOrWhiteSpace(entity))
 135            query = query.Where(e => e.EntityType == entity);
 336        if (parameters.TryGetValue("user", out var user) && !string.IsNullOrWhiteSpace(user))
 137            query = query.Where(e => (e.ActorUserName != null && e.ActorUserName.Contains(user)) || e.ActorUserId == use
 338        return query;
 39    }
 40}