feat(monitoring): match citations by canonical link and scope summary by brand/keyword/platform/date

Replace the domain+title fuzzy alias scoring with a canonical
candidate-key index built from published-link aliases — only exact
matches now resolve to a SaaS source, eliminating false positives
across articles sharing a host (e.g. m.163.com vs www.163.com).

Surface the summary scoping that already existed on loadCitationRanking
/ loadCitedArticles by accepting brand_id, keyword_id, ai_platform_id
and business_date on CitationSummary, plumbing them through the handler
and admin tracking view.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-01 11:46:17 +08:00
parent 2436f50c1f
commit b345ee26e4
10 changed files with 592 additions and 307 deletions
@@ -66,7 +66,21 @@ func (h *MonitoringHandler) CitationSummary(c *gin.Context) {
return
}
data, svcErr := h.svc.CitationSummary(c.Request.Context(), days)
brandID, err := parseOptionalInt64(c.Query("brand_id"))
if err != nil {
response.Error(c, response.ErrBadRequest(40031, "invalid_brand_id", "brand_id must be a number"))
return
}
keywordID, err := parseOptionalInt64Pointer(c.Query("keyword_id"))
if err != nil {
response.Error(c, response.ErrBadRequest(40031, "invalid_keyword_id", "keyword_id must be a number"))
return
}
aiPlatformID := parseOptionalStringPointer(c.Query("ai_platform_id"))
data, svcErr := h.svc.CitationSummary(c.Request.Context(), days, brandID, keywordID, c.Query("business_date"), aiPlatformID)
if svcErr != nil {
response.Error(c, svcErr)
return