fix(time): mongo query error
This commit is contained in:
parent
c4e6ac8fb4
commit
487ce31c4c
14
collect.go
14
collect.go
|
@ -16,20 +16,28 @@ import (
|
||||||
func collectCopyCountLiveAnchors(cxt *WorkerContext) {
|
func collectCopyCountLiveAnchors(cxt *WorkerContext) {
|
||||||
defer cxt.Done()
|
defer cxt.Done()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
var ok bool
|
||||||
for !ps.IsClose() {
|
for !ps.IsClose() {
|
||||||
|
|
||||||
liveanchor := &CountLiveAnchors{}
|
liveanchor := &CountLiveAnchors{}
|
||||||
ok, err := db.T.CountLiveAnchors.OrderBy("create_at desc").Limit(1).Get(liveanchor)
|
ok, err = db.T.CountLiveAnchors.OrderBy("create_at desc").Limit(1).Get(liveanchor)
|
||||||
if ok || (ok == false && err == nil) {
|
if ok || (ok == false && err == nil) {
|
||||||
|
|
||||||
var cur *mongo.Cursor
|
var cur *mongo.Cursor
|
||||||
|
var last time.Time
|
||||||
if ok == false {
|
if ok == false {
|
||||||
cur, err = mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gt": "2020-05-30"}})
|
last, err = time.ParseInLocation("2006-01-02", "2020-05-30", time.Local)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
cur, err = mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gt": last}})
|
||||||
} else {
|
} else {
|
||||||
last := liveanchor.CreateAt
|
last = liveanchor.CreateAt
|
||||||
log.Println("last: ", last)
|
log.Println("last: ", last)
|
||||||
cur, err = mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gt": last}})
|
cur, err = mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gt": last}})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
ps.Wait(time.Second * 5)
|
ps.Wait(time.Second * 5)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user