mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-31 11:51:28 +08:00
test cron
This commit is contained in:
parent
9182f15ee0
commit
d391a4d023
@ -79,7 +79,7 @@ func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[]
|
||||
if err != nil || msgs.UID == "" {
|
||||
if err != nil {
|
||||
if err == db.ErrMsgListNotExist {
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), ID, index, err.Error())
|
||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "ID:", ID, "index:", index, err.Error())
|
||||
} else {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ const cronTaskOperationID = "cronTaskOperationID-"
|
||||
|
||||
func StartCronTask() {
|
||||
log.NewPrivateLog("cron")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task", "cron config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
c := cron.New()
|
||||
fmt.Println("config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
fmt.Println("cron config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, func() {
|
||||
// user msg clear
|
||||
operationID := getCronTaskOperationID()
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"fmt"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/gogo/protobuf/sortkeys"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"math/rand"
|
||||
@ -268,7 +267,8 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er
|
||||
regex := fmt.Sprintf("/^%s/", ID)
|
||||
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
||||
var msgs []UserChat
|
||||
cursor, err := c.Find(ctx, bson.M{"uid": primitive.Regex{Pattern: regex}}, findOpts)
|
||||
//primitive.Regex{Pattern: regex}
|
||||
cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": regex}}, findOpts)
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user