feat: integrate creator hub douyin workflows

This commit is contained in:
2026-09-14 19:22:07 +08:00
parent 025fe62c37
commit 44a28954cf
42 changed files with 2850 additions and 880 deletions
+29
View File
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"encoding/json"
"errors"
"fmt"
"strings"
"time"
@@ -123,6 +124,34 @@ func (s *Store) upsertRuleResult(ctx context.Context, commentID string, rule Lea
return RuleResult{CommentID: commentID, RuleID: rule.ID, Status: status, Reason: reason, MatchedKeywords: matched, RuleSnapshot: rule, AnalysedAt: analysedAt}, nil
}
func (s *Store) AnalyzeComments(ctx context.Context, commentIDs []string, ruleID string, analyzer ThemeAnalyzer) ([]RuleAnalysisItem, error) {
if len(commentIDs) == 0 || len(commentIDs) > 100 || strings.TrimSpace(ruleID) == "" {
return nil, ErrInvalid
}
seen := make(map[string]struct{}, len(commentIDs))
items := make([]RuleAnalysisItem, 0, len(commentIDs))
var batchErr error
for _, commentID := range commentIDs {
commentID = strings.TrimSpace(commentID)
if commentID == "" {
return nil, ErrInvalid
}
if _, ok := seen[commentID]; ok {
continue
}
seen[commentID] = struct{}{}
result, err := s.AnalyzeComment(ctx, commentID, ruleID, analyzer)
item := RuleAnalysisItem{CommentID: commentID, Result: &result}
if err != nil {
item.Result = nil
item.Error = err.Error()
batchErr = errors.Join(batchErr, err)
}
items = append(items, item)
}
return items, batchErr
}
func (s *Store) AnalyzeComment(ctx context.Context, commentID, ruleID string, analyzer ThemeAnalyzer) (RuleResult, error) {
comment, err := s.GetComment(ctx, commentID)
if err != nil {