Link pageFetcher.PageFetches to cvSearch.JobSearchSessions
Adds nullable JobSearchSessionId to PageFetchEntity and FetchPageRequest. cv-search-job passes session.Id on every fetch so all Playwright page loads for a job search session can be traced back to their session. Includes index on JobSearchSessionId for efficient lookup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,4 +17,10 @@ public sealed class FetchPageRequest
|
||||
/// Identifies the calling service for audit purposes (e.g. <c>cv-matcher-api</c>, <c>cv-search-job</c>).
|
||||
/// </summary>
|
||||
public string CallerService { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Optional reference to the job search session that triggered this fetch.
|
||||
/// Stored on <c>pageFetcher.PageFetches</c> for cross-schema audit queries.
|
||||
/// </summary>
|
||||
public string? JobSearchSessionId { get; set; }
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public sealed class PageFetcherService
|
||||
Id = Guid.NewGuid().ToString("N"),
|
||||
Url = request.Url,
|
||||
CallerService = request.CallerService ?? string.Empty,
|
||||
JobSearchSessionId = request.JobSearchSessionId,
|
||||
HttpStatusCode = statusCode,
|
||||
Html = html,
|
||||
Text = text,
|
||||
|
||||
@@ -31,4 +31,10 @@ public sealed class PageFetchEntity : BaseEntity
|
||||
|
||||
/// <summary>Exception message when <see cref="Success"/> is <c>false</c>.</summary>
|
||||
public string? ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional reference to the <c>cvSearch.JobSearchSessions</c> row that triggered this fetch.
|
||||
/// Null for fetches not originating from a job search session (e.g. direct CV-to-job matches).
|
||||
/// </summary>
|
||||
public string? JobSearchSessionId { get; set; }
|
||||
}
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using PageFetcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PageFetcher.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(PageFetchDbContext))]
|
||||
[Migration("20260608165542_AddJobSearchSessionId")]
|
||||
partial class AddJobSearchSessionId
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("pageFetcher")
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("PageFetcher.Data.Entities.PageFetchEntity", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)");
|
||||
|
||||
b.Property<string>("CallerService")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("datetime2")
|
||||
.HasDefaultValueSql("SYSUTCDATETIME()");
|
||||
|
||||
b.Property<long>("DurationMs")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("ErrorMessage")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("nvarchar(2000)");
|
||||
|
||||
b.Property<string>("Html")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("HttpStatusCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("JobSearchSessionId")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)");
|
||||
|
||||
b.Property<bool>("Success")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("nvarchar(2000)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CreatedAt");
|
||||
|
||||
b.HasIndex("JobSearchSessionId");
|
||||
|
||||
b.HasIndex("Url");
|
||||
|
||||
b.ToTable("PageFetches", "pageFetcher");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using PageFetcher.Data;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PageFetcher.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddJobSearchSessionId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "JobSearchSessionId",
|
||||
schema: MigrationConstants.SchemaName,
|
||||
table: "PageFetches",
|
||||
type: "nvarchar(64)",
|
||||
maxLength: 64,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PageFetches_JobSearchSessionId",
|
||||
schema: MigrationConstants.SchemaName,
|
||||
table: "PageFetches",
|
||||
column: "JobSearchSessionId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PageFetches_JobSearchSessionId",
|
||||
schema: MigrationConstants.SchemaName,
|
||||
table: "PageFetches");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "JobSearchSessionId",
|
||||
schema: MigrationConstants.SchemaName,
|
||||
table: "PageFetches");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,10 @@ namespace PageFetcher.Data.Migrations
|
||||
b.Property<int?>("HttpStatusCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("JobSearchSessionId")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)");
|
||||
|
||||
b.Property<bool>("Success")
|
||||
.HasColumnType("bit");
|
||||
|
||||
@@ -69,6 +73,8 @@ namespace PageFetcher.Data.Migrations
|
||||
|
||||
b.HasIndex("CreatedAt");
|
||||
|
||||
b.HasIndex("JobSearchSessionId");
|
||||
|
||||
b.HasIndex("Url");
|
||||
|
||||
b.ToTable("PageFetches", "pageFetcher");
|
||||
|
||||
@@ -36,8 +36,11 @@ public sealed class PageFetchDbContext : DbContext
|
||||
entity.Property(x => x.Html).IsRequired();
|
||||
entity.Property(x => x.Text).IsRequired();
|
||||
entity.Property(x => x.ErrorMessage).HasMaxLength(2000);
|
||||
entity.Property(x => x.JobSearchSessionId).HasMaxLength(64);
|
||||
entity.Property(x => x.CreatedAt).HasDefaultValueSql("SYSUTCDATETIME()");
|
||||
|
||||
entity.HasIndex(x => x.JobSearchSessionId);
|
||||
|
||||
entity.HasIndex(x => x.Url);
|
||||
entity.HasIndex(x => x.CreatedAt);
|
||||
});
|
||||
|
||||
@@ -169,7 +169,8 @@ public sealed class CvSearchJobTask : IJobTask
|
||||
{
|
||||
Url = url,
|
||||
WaitFor = "domcontentloaded",
|
||||
CallerService = "cv-search-job"
|
||||
CallerService = "cv-search-job",
|
||||
JobSearchSessionId = session.Id
|
||||
}, ct);
|
||||
|
||||
if (!fetchResponse.Success || string.IsNullOrWhiteSpace(fetchResponse.Text))
|
||||
|
||||
Reference in New Issue
Block a user