@@ -0,0 +1,59 @@
|
||||
package keyword
|
||||
|
||||
import (
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/timeutil/timerange"
|
||||
"91porn-server/models/l/searchlogmod"
|
||||
"91porn-server/models/s/kwstatmod"
|
||||
)
|
||||
|
||||
type TimeRange = timerange.TimeRange
|
||||
|
||||
func toKeywordIncDoc(realm constant.RealmType, data map[string]int64) []kwstatmod.KeywordIncDoc {
|
||||
list := make([]kwstatmod.KeywordIncDoc, len(data))
|
||||
i := 0
|
||||
for k, v := range data {
|
||||
word := k
|
||||
count := v
|
||||
list[i] = kwstatmod.KeywordIncDoc{
|
||||
Realm: realm,
|
||||
Word: word,
|
||||
Count: count,
|
||||
}
|
||||
i++
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
func GetIncDocList(timeRange TimeRange) ([]kwstatmod.KeywordIncDoc, error) {
|
||||
incDocList := []kwstatmod.KeywordIncDoc{}
|
||||
//综合关键字搜索数
|
||||
complexKeywordCountMap, err := searchlogmod.GetKeywordCountMapByTime(timeRange.Head, timeRange.Tail, constant.SearchComplex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
complexIncDocList := toKeywordIncDoc(constant.SearchComplex, complexKeywordCountMap)
|
||||
incDocList = append(incDocList, complexIncDocList...)
|
||||
//视屏关键字搜索数
|
||||
vidKeywordCountMap, err := searchlogmod.GetKeywordCountMapByTime(timeRange.Head, timeRange.Tail, constant.SearchSP)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
videoIncDocList := toKeywordIncDoc(constant.SearchSP, vidKeywordCountMap)
|
||||
incDocList = append(incDocList, videoIncDocList...)
|
||||
//标签关键字搜索数
|
||||
tagKeywordCountMap, err := searchlogmod.GetKeywordCountMapByTime(timeRange.Head, timeRange.Tail, constant.SearchTag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tagIncDocList := toKeywordIncDoc(constant.SearchTag, tagKeywordCountMap)
|
||||
incDocList = append(incDocList, tagIncDocList...)
|
||||
//用户关键字搜索数
|
||||
userKeywordCountMap, err := searchlogmod.GetKeywordCountMapByTime(timeRange.Head, timeRange.Tail, constant.SearchUser)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userIncDocList := toKeywordIncDoc(constant.SearchUser, userKeywordCountMap)
|
||||
incDocList = append(incDocList, userIncDocList...)
|
||||
return incDocList, nil
|
||||
}
|
||||
Reference in New Issue
Block a user