< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Data.EntityMaps.AuditLogDbMap
Assembly: ArturRios.Heimdall.Data
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Infrastructure/ArturRios.Heimdall.Data/EntityMaps/AuditLogDbMap.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 39
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Configure(...)100%11100%

File(s)

/home/ci/agent/workspace/heimdall-api-docs_main/app/src/Infrastructure/ArturRios.Heimdall.Data/EntityMaps/AuditLogDbMap.cs

#LineLine coverage
 1using ArturRios.Heimdall.Domain.Entities;
 2using Microsoft.EntityFrameworkCore;
 3using Microsoft.EntityFrameworkCore.Metadata.Builders;
 4
 5namespace ArturRios.Heimdall.Data.EntityMaps;
 6
 7internal static class AuditLogDbMap
 8{
 9    public static void Configure(this EntityTypeBuilder<AuditLog> auditLog)
 10    {
 411        auditLog.ToTable("audit_log");
 412        auditLog.HasKey(x => x.Id);
 13
 414        auditLog.Property(x => x.PublicId).IsRequired();
 415        auditLog.HasIndex(x => x.PublicId).IsUnique();
 416        auditLog.HasIndex(x => x.CreatedAt);
 417        auditLog.HasIndex(x => x.ActorPersonId);
 18
 19        // UC-48 filters by target ("what happened to this entity?"); without this that is a scan of
 20        // a table that only grows.
 421        auditLog.HasIndex(x => x.TargetId);
 22
 23        // NFR-21's pass selects the entries past the attribution period oldest first, and only those that
 24        // still have an actor, or a target, to clear (#206). Partial, so each holds only the rows its query
 25        // can still return and shrinks as the pass clears them; created with CONCURRENTLY by
 26        // AddAuditRetentionIndexes, since audit_log is written on every command.
 427        auditLog.HasIndex(x => x.CreatedAt, "ix_audit_log_created_at_attributed")
 428            .HasDatabaseName("ix_audit_log_created_at_attributed")
 429            .HasFilter("actor_person_id IS NOT NULL");
 430        auditLog.HasIndex(x => x.CreatedAt, "ix_audit_log_created_at_targeted")
 431            .HasDatabaseName("ix_audit_log_created_at_targeted")
 432            .HasFilter("target_id IS NOT NULL");
 33
 434        auditLog.Property(x => x.Action).IsRequired();
 435        auditLog.Property(x => x.CreatedAt).HasDefaultValueSql("now()");
 36
 37        // ActorPersonId/ActorRole/TargetId are plain nullable columns — no FK, no required navigation.
 438    }
 39}