|
@@ -18,7 +18,7 @@ import (
|
|
const (
|
|
const (
|
|
customCacheDb = "newother"
|
|
customCacheDb = "newother"
|
|
customDataCacheKey = "leadGeneration_customData_%s"
|
|
customDataCacheKey = "leadGeneration_customData_%s"
|
|
- customDataCacheTimeLong = 60 * 60 * 24 * 31
|
|
|
|
|
|
+ customDataCacheTimeLong = 60 * 60 * 24 * 30
|
|
)
|
|
)
|
|
|
|
|
|
// CustomManager 定制化报告管理
|
|
// CustomManager 定制化报告管理
|
|
@@ -45,7 +45,9 @@ func InitCustomManager(conf vars.CustomConfig) *CustomManager {
|
|
Conf: conf,
|
|
Conf: conf,
|
|
UserGroup: make(map[string]int),
|
|
UserGroup: make(map[string]int),
|
|
}
|
|
}
|
|
|
|
+ //圈用户
|
|
go manager.ScheduledTasks()
|
|
go manager.ScheduledTasks()
|
|
|
|
+ //执行查询
|
|
go manager.DoSearch()
|
|
go manager.DoSearch()
|
|
return manager
|
|
return manager
|
|
}
|
|
}
|
|
@@ -94,20 +96,29 @@ func (this *CustomManager) ScheduledTasks() {
|
|
// UpdateUserGroupJob 更新用户群组
|
|
// UpdateUserGroupJob 更新用户群组
|
|
func (this *CustomManager) UpdateUserGroupJob() {
|
|
func (this *CustomManager) UpdateUserGroupJob() {
|
|
//查询月活用户
|
|
//查询月活用户
|
|
- userMap := activeUsers.GetMonthActiveFreeUsers()
|
|
|
|
|
|
+ userArr := activeUsers.GetMonthActiveFreeUsers()
|
|
|
|
+
|
|
|
|
+ newMap := map[string]int{}
|
|
|
|
+ //测试账户
|
|
|
|
+ if len(vars.Config.TestUid) > 0 {
|
|
|
|
+ for _, uid := range vars.Config.TestUid {
|
|
|
|
+ newMap[uid] = 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, uId := range userArr {
|
|
|
|
+ newMap[uId] = 0
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新新用户群组
|
|
this.Lock()
|
|
this.Lock()
|
|
defer this.Unlock()
|
|
defer this.Unlock()
|
|
- this.UserGroup = userMap
|
|
|
|
-
|
|
|
|
|
|
+ this.UserGroup = newMap
|
|
//更新批次标识
|
|
//更新批次标识
|
|
batchFlag := time.Now().Format(public.Date_Full_Layout)
|
|
batchFlag := time.Now().Format(public.Date_Full_Layout)
|
|
this.BatchFlag = batchFlag
|
|
this.BatchFlag = batchFlag
|
|
-
|
|
|
|
- userArr := make([]string, len(this.UserGroup), 0)
|
|
|
|
- for userId, _ := range this.UserGroup {
|
|
|
|
- userArr = append(userArr, userId)
|
|
|
|
- }
|
|
|
|
- go this.activityUserQueue(batchFlag, []string{})
|
|
|
|
|
|
+ log.Printf("CustomManager NewGroup %v\n", newMap)
|
|
|
|
+ go this.activityUserQueue(batchFlag, userArr)
|
|
}
|
|
}
|
|
|
|
|
|
// activityUserQueue 活跃用户查询队列
|
|
// activityUserQueue 活跃用户查询队列
|
|
@@ -131,6 +142,9 @@ func (this *CustomManager) activityUserQueue(batchFlag string, userIds []string)
|
|
// DoSearch 定制化分析报告查询队列
|
|
// DoSearch 定制化分析报告查询队列
|
|
func (this *CustomManager) DoSearch() {
|
|
func (this *CustomManager) DoSearch() {
|
|
for {
|
|
for {
|
|
|
|
+ //是否在可执行时间段内
|
|
|
|
+ //???
|
|
|
|
+
|
|
var obj *SearchEntity
|
|
var obj *SearchEntity
|
|
select { //优先级 newRegisterUserQueue > activityUserQueue
|
|
select { //优先级 newRegisterUserQueue > activityUserQueue
|
|
case obj = <-newRegisterUserQueue:
|
|
case obj = <-newRegisterUserQueue:
|
|
@@ -142,7 +156,7 @@ func (this *CustomManager) DoSearch() {
|
|
}
|
|
}
|
|
//查询结果处理
|
|
//查询结果处理
|
|
data := search.PotentialCustomizeAnalysis(obj.UserId, obj.Value)
|
|
data := search.PotentialCustomizeAnalysis(obj.UserId, obj.Value)
|
|
- if data != nil || len(data) == 0 {
|
|
|
|
|
|
+ if data == nil || len(data) == 0 {
|
|
log.Printf("[ERROR]CustomManager %s DoSearch %s Error %v\n", obj.UserId, obj.Value)
|
|
log.Printf("[ERROR]CustomManager %s DoSearch %s Error %v\n", obj.UserId, obj.Value)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -155,6 +169,13 @@ func (this *CustomManager) DoSearch() {
|
|
|
|
|
|
// checkActivityUser 校验用户是否是活跃用户
|
|
// checkActivityUser 校验用户是否是活跃用户
|
|
func (this *CustomManager) checkActivityUser(userId string) (exists bool) {
|
|
func (this *CustomManager) checkActivityUser(userId string) (exists bool) {
|
|
|
|
+ if len(vars.Config.TestUid) > 0 {
|
|
|
|
+ for _, uid := range vars.Config.TestUid {
|
|
|
|
+ if uid == userId {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
this.RLock()
|
|
this.RLock()
|
|
defer this.RUnlock()
|
|
defer this.RUnlock()
|
|
_, exists = this.UserGroup[userId]
|
|
_, exists = this.UserGroup[userId]
|