thread-master/backend/internal/worker/job/similar_accounts.go

43 lines
1.4 KiB
Go
Raw Permalink Normal View History

2026-06-28 08:28:42 +00:00
package job
import (
missionentity "haixun-backend/internal/model/copy_mission/domain/entity"
missiondomain "haixun-backend/internal/model/copy_mission/domain/usecase"
)
// similarAccountsFromSummary converts the read-side usecase summary back into a
// write-side entity slice so that worker jobs can preserve previously
// discovered accounts (including MatchedSource provenance) across re-runs
// without losing information. Fields that the summary does not carry are left
// at their zero value.
func similarAccountsFromSummary(in []missiondomain.SimilarAccountSummary) []missionentity.SimilarAccount {
if len(in) == 0 {
return nil
}
out := make([]missionentity.SimilarAccount, 0, len(in))
for _, item := range in {
matched := item.MatchedSource
if len(matched) == 0 && item.Source != "" {
matched = []string{item.Source}
}
out = append(out, missionentity.SimilarAccount{
Username: item.Username,
Reason: item.Reason,
Source: item.Source,
MatchedSource: matched,
Confidence: item.Confidence,
Status: item.Status,
TopicRelevance: item.TopicRelevance,
LastSeenAt: item.LastSeenAt,
ProfileURL: item.ProfileURL,
AuthorVerified: item.AuthorVerified,
FollowerCount: item.FollowerCount,
EngagementScore: item.EngagementScore,
LikeCount: item.LikeCount,
ReplyCount: item.ReplyCount,
PostCount: item.PostCount,
})
}
return out
}