mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 11:58:34 +08:00
fix(wiki): count only the latest job per raw in KB failure stats
This commit is contained in:
parent
7949b6ff38
commit
fb4206e356
@ -15,6 +15,7 @@ import vip.mate.wiki.model.WikiPageEntity;
|
|||||||
import vip.mate.wiki.repository.WikiPageCitationMapper;
|
import vip.mate.wiki.repository.WikiPageCitationMapper;
|
||||||
import vip.mate.wiki.service.*;
|
import vip.mate.wiki.service.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -96,12 +97,21 @@ public class WikiRelationController {
|
|||||||
long enrichedCount = pageService.listByKbIdWithContent(kbId).stream()
|
long enrichedCount = pageService.listByKbIdWithContent(kbId).stream()
|
||||||
.filter(p -> p.getContent() != null && p.getContent().contains("[["))
|
.filter(p -> p.getContent() != null && p.getContent().contains("[["))
|
||||||
.count();
|
.count();
|
||||||
// Use listByKbId (all statuses) instead of listQueued (queued-only)
|
// Use listByKbId (all statuses) instead of listQueued (queued-only).
|
||||||
|
// A raw material accumulates one job row per (re)processing attempt;
|
||||||
|
// only its most recent job reflects current state. Collapse to the
|
||||||
|
// latest job per raw (highest snowflake id wins) so a failed attempt
|
||||||
|
// that a later successful reprocess superseded stops being counted.
|
||||||
var allJobs = jobMapper.listByKbId(kbId, 200);
|
var allJobs = jobMapper.listByKbId(kbId, 200);
|
||||||
int failedJobCount = (int) allJobs.stream()
|
Map<Long, WikiProcessingJobEntity> latestByRaw = new HashMap<>();
|
||||||
|
for (WikiProcessingJobEntity job : allJobs) {
|
||||||
|
latestByRaw.merge(job.getRawId(), job,
|
||||||
|
(a, b) -> a.getId() >= b.getId() ? a : b);
|
||||||
|
}
|
||||||
|
int failedJobCount = (int) latestByRaw.values().stream()
|
||||||
.filter(j -> "failed".equals(j.getStatus()))
|
.filter(j -> "failed".equals(j.getStatus()))
|
||||||
.count();
|
.count();
|
||||||
int runningJobCount = (int) allJobs.stream()
|
int runningJobCount = (int) latestByRaw.values().stream()
|
||||||
.filter(j -> "running".equals(j.getStatus()))
|
.filter(j -> "running".equals(j.getStatus()))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user