using Deal.Infrastructure.Persistence.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Deal.Infrastructure.Persistence.Configurations;
///
/// EF-конфигурация отсева пайплайна
///
public sealed class RejectedItemConfiguration : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.ToTable("RejectedItems");
builder.HasKey(x => x.Id);
builder.Property(x => x.Text).HasColumnType("text");
builder.Property(x => x.Reason).HasColumnType("text");
builder.Property(x => x.Kw).HasColumnType("text");
builder.Property(x => x.SearchTsv)
.HasComputedColumnSql("to_tsvector('russian', coalesce(\"Text\",''))", stored: true);
// Автоочистка старше 3 суток и сортировка списка идут по времени отсева.
builder.HasIndex(x => x.RejectedAt);
builder.HasIndex(x => x.SearchTsv).HasMethod("gin");
}
}