|
@@ -211,6 +211,8 @@ func getDataByAppid(appid string, i_day, next, i_all int, limittodaykey string,
|
|
|
|
|
|
log.Debug("query:", query)
|
|
|
i_next = next
|
|
|
+ //是否获取过,默认无值
|
|
|
+ fields["bget"] = 1
|
|
|
data, bdata := Mgo.Find("usermail", query, `{"_id":1}`, fields, false, i_next, QUERY_LIMIT)
|
|
|
if bdata && data != nil && *data != nil && len(*data) > 0 {
|
|
|
infos = *data
|
|
@@ -220,20 +222,41 @@ func getDataByAppid(appid string, i_day, next, i_all int, limittodaykey string,
|
|
|
redis.Put(REDISDB, "lastid_"+appid, lastid, DesZero())
|
|
|
}
|
|
|
}
|
|
|
+ newGetLen := 0
|
|
|
+ updateMap := [][]map[string]interface{}{}
|
|
|
for _, v := range infos {
|
|
|
+ if util.IntAll(v["bget"]) == 0 {
|
|
|
+ newGetLen++
|
|
|
+ updateMap = append(updateMap, []map[string]interface{}{
|
|
|
+ map[string]interface{}{
|
|
|
+ "_id": v["_id"],
|
|
|
+ },
|
|
|
+ map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "bget": 1,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
delete(v, "_id")
|
|
|
+ delete(v, "bget")
|
|
|
}
|
|
|
if len(*data) == QUERY_LIMIT && !blastid {
|
|
|
i_next = i_next + QUERY_LIMIT
|
|
|
} else {
|
|
|
i_next = -1
|
|
|
}
|
|
|
- //处理总条数
|
|
|
- redis.Decrby(REDISDB, "limitnum_"+appid, len(*data))
|
|
|
+ //处理总条数,有重复获取的信息条不计数,*******************
|
|
|
+ thisLen := len(*data)
|
|
|
+ if newGetLen > 0 {
|
|
|
+ redis.Decrby(REDISDB, "limitnum_"+appid, newGetLen)
|
|
|
+ go Mgo.UpdateBulk("usermail", updateMap...)
|
|
|
+ }
|
|
|
go Mgo.Save("userdatalog", map[string]interface{}{
|
|
|
- "appid": appid,
|
|
|
- "datalen": len(*data),
|
|
|
- "date": time.Now().Unix(),
|
|
|
+ "appid": appid,
|
|
|
+ "datalen": thisLen,
|
|
|
+ "newgetlen": newGetLen,
|
|
|
+ "date": time.Now().Unix(),
|
|
|
})
|
|
|
} else { //没有数据
|
|
|
i_next = 0
|