findMsgInfoBySeq

This commit is contained in:
withchao 2023-05-29 20:02:15 +08:00
parent 25faf3579a
commit 57028450df
3 changed files with 12 additions and 11 deletions

View File

@ -341,7 +341,7 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversa
func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversationID string, seqs []int64) (totalMsgs []*sdkws.MsgData, err error) {
var totalUnExistSeqs []int64
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, seqs) {
log.ZDebug(ctx, "getMsgBySeqs", "docID", docID, "seqs", seqs)
//log.ZDebug(ctx, "getMsgBySeqs", "docID", docID, "seqs", seqs)
msgs, unexistSeqs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
if err != nil {
return nil, err
@ -396,7 +396,7 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
// }
func (db *commonMsgDatabase) findMsgInfoBySeq(ctx context.Context, userID, docID string, seqs []int64) (totalMsgs []*unRelationTb.MsgInfoModel, unExistSeqs []int64, err error) {
msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, docID, userID, seqs)
msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, docID, seqs)
if err != nil {
return nil, nil, err
}

View File

@ -2,7 +2,6 @@ package controller
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"strconv"
@ -165,7 +164,7 @@ func Test_Insert(t *testing.T) {
Content: fmt.Sprintf("test-%d", i),
})
}
if err := db.BatchInsertBlock(ctx, "test", arr, updateKeyMsg, 0); err != nil {
if err := db.BatchInsertBlock(ctx, "test", arr, updateKeyMsg, 1); err != nil {
t.Fatal(err)
}
}
@ -189,12 +188,14 @@ func Test_Revoke(t *testing.T) {
func Test_FindBySeq(t *testing.T) {
db := GetDB()
ctx := context.Background()
res, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, "123456", "test:0", []int64{1, 2, 3})
if err != nil {
t.Fatal(err)
}
data, _ := json.Marshal(res)
fmt.Println(string(data))
fmt.Println(db.getMsgBySeqs(ctx, "100", "si_100_101", []int64{1}))
//res, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, "123456", "test:0", []int64{1, 2, 3})
//if err != nil {
// t.Fatal(err)
//}
//db.GetMsgBySeqs(ctx, "100", "si_100_101:0", []int64{6})
//data, _ := json.Marshal(res)
//fmt.Println(string(data))
}
//func Test_Delete(t *testing.T) {

View File

@ -191,6 +191,7 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, userID stri
{
{"$project", bson.D{
{"_id", 0},
{"doc_id", 1},
{"msgs", bson.D{
{"$map", bson.D{
{"input", indexs},
@ -219,7 +220,6 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, userID stri
},
{
{"$project", bson.D{
{"doc_id", 0},
{"msgs.del_list", 0},
}},
},