mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-20 11:49:57 +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 || msgs.UID == "" {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == db.ErrMsgListNotExist {
|
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 {
|
} else {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID)
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ const cronTaskOperationID = "cronTaskOperationID-"
|
|||||||
|
|
||||||
func StartCronTask() {
|
func StartCronTask() {
|
||||||
log.NewPrivateLog("cron")
|
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()
|
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() {
|
_, err := c.AddFunc(config.Config.Mongo.ChatRecordsClearTime, func() {
|
||||||
// user msg clear
|
// user msg clear
|
||||||
operationID := getCronTaskOperationID()
|
operationID := getCronTaskOperationID()
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"github.com/gogo/protobuf/sortkeys"
|
"github.com/gogo/protobuf/sortkeys"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -268,7 +267,8 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er
|
|||||||
regex := fmt.Sprintf("/^%s/", ID)
|
regex := fmt.Sprintf("/^%s/", ID)
|
||||||
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1})
|
||||||
var msgs []UserChat
|
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 {
|
if err != nil {
|
||||||
return nil, utils.Wrap(err, "")
|
return nil, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user