[Ingest] Persistent crawl run-log + per-source breakdown on admin queue
Each ingestion run now records an IngestionRun row (found/queued/published/flagged/spam/duplicates + a per-source detail string). Admin → صف آگهیها shows a «تاریخچه جمعآوری» table of the last 15 runs (hover a row for the per-source breakdown), so admins can see how much each source found vs added over time. IngestionSummary gains TotalFetched. Migration: IngestionRuns table. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ public record SourceResult(string Source, int Fetched, int Queued, int Published
|
||||
|
||||
public record IngestionSummary(List<SourceResult> Sources)
|
||||
{
|
||||
public int TotalFetched => Sources.Sum(s => s.Fetched);
|
||||
public int TotalQueued => Sources.Sum(s => s.Queued);
|
||||
public int TotalPublished => Sources.Sum(s => s.Published);
|
||||
public int TotalFlagged => Sources.Sum(s => s.Flagged);
|
||||
@@ -108,7 +109,27 @@ public class IngestionService
|
||||
source.Name, fetched, queued, published, flagged, spam, dupes);
|
||||
}
|
||||
|
||||
return new IngestionSummary(results);
|
||||
var summary = new IngestionSummary(results);
|
||||
|
||||
// Persist a run-log row so admins get a crawl history (with a per-source breakdown).
|
||||
if (results.Count > 0)
|
||||
{
|
||||
var detail = string.Join("؛ ", results.Select(r =>
|
||||
$"{r.Source}: یافت {r.Fetched}، صف {r.Queued}، منتشر {r.Published}، پرچم {r.Flagged}، اسپم {r.Spam}، تکراری {r.Duplicates}"));
|
||||
_db.IngestionRuns.Add(new IngestionRun
|
||||
{
|
||||
Fetched = summary.TotalFetched,
|
||||
Queued = summary.TotalQueued,
|
||||
Published = summary.TotalPublished,
|
||||
Flagged = summary.TotalFlagged,
|
||||
Spam = summary.TotalSpam,
|
||||
Duplicates = summary.TotalDuplicates,
|
||||
Detail = detail.Length > 2000 ? detail[..2000] : detail,
|
||||
});
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
private static (RawListingStatus status, string? reason, int confidence) Decide(
|
||||
|
||||
Reference in New Issue
Block a user