|
@@ -14,18 +14,20 @@ type NewActiveMsg struct {
|
|
|
TimeStamp int64 //活跃时间
|
|
|
}
|
|
|
|
|
|
-func GetNewActiveUser(st, ed time.Time) []*NewActiveMsg {
|
|
|
+func GetNewActiveUser(st time.Time) ([]*NewActiveMsg, time.Time) {
|
|
|
var (
|
|
|
mgoIds []string
|
|
|
ctx = context.Background()
|
|
|
)
|
|
|
+ //统计昨天的所有注册用户 过滤掉
|
|
|
+ end := st.AddDate(0, 0, 1)
|
|
|
+ ed := time.Date(end.Year(), end.Month(), end.Day(), 0, 0, 0, 0, st.Location())
|
|
|
stYear, stMonth, stDay := st.Date()
|
|
|
- _, edMonth, edDay := ed.Date()
|
|
|
nst := st.AddDate(0, -1, 0)
|
|
|
_, nstMonth, nstDay := nst.Date()
|
|
|
//昨天所有活跃用户
|
|
|
res, err := g.DB("useranaly").Query(ctx, fmt.Sprintf(`SELECT DISTINCT user_mongoid FROM user_countbyhour
|
|
|
-WHERE CONCAT(month, '-', day) >= '%s' AND CONCAT(month, '-', day) <= '%s'`, fmt.Sprintf("%d-%d", int(stMonth), stDay), fmt.Sprintf("%d-%d", int(edMonth), edDay)))
|
|
|
+WHERE CONCAT(month, '-', day) = '%s'`, fmt.Sprintf("%d-%d", int(stMonth), stDay)))
|
|
|
//res, err := g.DB().Query(ctx, fmt.Sprintf(`SELECT DISTINCT user_mongoid FROM user_countbyhour WHERE %s `, sql))
|
|
|
if err == nil && !res.IsEmpty() {
|
|
|
for _, m := range res.List() {
|
|
@@ -60,5 +62,5 @@ WHERE user_mongoid = '%s' and CONCAT(month, '-', day) >= '%s' AND CONCAT(month,
|
|
|
}(id)
|
|
|
}
|
|
|
wait.Wait()
|
|
|
- return data
|
|
|
+ return data, ed
|
|
|
}
|