|
@@ -25,7 +25,7 @@ type MemberInterest struct {
|
|
|
}
|
|
|
|
|
|
//初始化缓存,在每次执行任务时调用,
|
|
|
-func InitCache(flag, m_openid string,bview bool) map[string]*[]*MemberInterest {
|
|
|
+func InitCache(flag, m_openid string, bview bool) map[string]*[]*MemberInterest {
|
|
|
defer func() {
|
|
|
if r := recover(); r != nil {
|
|
|
log.Println("[E]", r)
|
|
@@ -42,18 +42,18 @@ func InitCache(flag, m_openid string,bview bool) map[string]*[]*MemberInterest {
|
|
|
cache := make(map[string]*[]*MemberInterest)
|
|
|
q := map[string]interface{}{}
|
|
|
if m_openid != "" {
|
|
|
- if bview{
|
|
|
+ if bview {
|
|
|
q = map[string]interface{}{
|
|
|
- "s_m_openid": m_openid,
|
|
|
- }
|
|
|
- }else{
|
|
|
+ "s_m_openid": m_openid,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
q = map[string]interface{}{
|
|
|
- "o_msgset." + flag + ".i_switchstatus": 1,
|
|
|
- "o_msgset." + flag + ".i_status": 1,
|
|
|
- "s_m_openid": m_openid,
|
|
|
- }
|
|
|
+ "o_msgset." + flag + ".i_switchstatus": 1,
|
|
|
+ "o_msgset." + flag + ".i_status": 1,
|
|
|
+ "s_m_openid": m_openid,
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
fixPush := util.ObjToString(PushConfig["fixPush"])
|
|
|
if len(fixPush) > 5 {
|
|
@@ -76,8 +76,10 @@ func InitCache(flag, m_openid string,bview bool) map[string]*[]*MemberInterest {
|
|
|
"o_msgset.l_modifydate": 1,
|
|
|
"s_m_openid": 1,
|
|
|
}).Iter()
|
|
|
+ n := 0
|
|
|
for tmp := make(map[string]interface{}); query.Next(tmp); {
|
|
|
util.Try(func() {
|
|
|
+ n++
|
|
|
_id := fmt.Sprintf("%x", string(tmp["_id"].(bson.ObjectId)))
|
|
|
o_msgset := tmp["o_msgset"].(map[string]interface{})
|
|
|
flagModule := o_msgset[flag].(map[string]interface{})
|
|
@@ -91,7 +93,11 @@ func InitCache(flag, m_openid string,bview bool) map[string]*[]*MemberInterest {
|
|
|
Interest: a_key,
|
|
|
Openid: util.ObjToString(tmp["s_m_openid"]),
|
|
|
}
|
|
|
- date := o_msgset["l_modifydate"]
|
|
|
+ log.Println("find-openid:", user.Openid)
|
|
|
+ date := flagModule["l_modifydate"]
|
|
|
+ if date == nil {
|
|
|
+ date = o_msgset["l_modifydate"]
|
|
|
+ }
|
|
|
if date != nil {
|
|
|
util.Try(func() {
|
|
|
user.InterestDate = date.(int64)
|
|
@@ -114,6 +120,7 @@ func InitCache(flag, m_openid string,bview bool) map[string]*[]*MemberInterest {
|
|
|
})
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
|
+ log.Println(flag, "本次查询用户总数:", n)
|
|
|
return cache
|
|
|
}
|
|
|
|