43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package contentreviewser
|
||
|
||
import (
|
||
"91porn-server/models/v/contentreviewmod"
|
||
"91porn-server/models/v/vidmod"
|
||
|
||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||
)
|
||
|
||
// videoScanner 视频帖子扫描策略;匹配 title / content / richText(不检测 tag)
|
||
type videoScanner struct{}
|
||
|
||
func (s *videoScanner) CountTotal() (int64, error) {
|
||
return vidmod.CountForReview()
|
||
}
|
||
|
||
func (s *videoScanner) ScanBatch(taskID, lastID primitive.ObjectID, terms []string) (*ScanResult, error) {
|
||
batch, err := vidmod.FindForReviewBatch(lastID, scanBatchSize)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if len(batch) == 0 {
|
||
return &ScanResult{Done: true}, nil
|
||
}
|
||
|
||
issues := make([]*contentreviewmod.ReviewIssue, 0, len(batch))
|
||
for _, v := range batch {
|
||
b := newIssueBuilder(taskID, contentreviewmod.IssueTargetVideo, v.ID).
|
||
MatchTitle("标题", v.Title, terms).
|
||
MatchContent("内容", v.Content, terms).
|
||
MatchRichText("富文本", v.RichText, terms)
|
||
if b.HasHits() {
|
||
issues = append(issues, b.Build())
|
||
}
|
||
}
|
||
|
||
return &ScanResult{
|
||
Issues: issues,
|
||
Checked: int64(len(batch)),
|
||
NextID: batch[len(batch)-1].ID,
|
||
}, nil
|
||
}
|