fix: use group message shard directory
This commit is contained in:
@@ -461,14 +461,19 @@ func internalGroupMessageSource(tenantID types.TenantID) (string, error) {
|
||||
}
|
||||
selects = append(selects, fmt.Sprintf(`SELECT message_id AS id,tenant_id,topic,seqid,from_user,msg_type,status,content,head,reply_seqid,mentioned_user_ids,created_at,updated_at FROM %s`, table))
|
||||
}
|
||||
selects = append(selects, internalLegacyGroupMessagesSelect(tenantID))
|
||||
return "(" + strings.Join(selects, " UNION ALL ") + ")", nil
|
||||
}
|
||||
|
||||
func internalLegacyGroupMessagesSelect(tenantID types.TenantID) string {
|
||||
// legacy 行内联租户条件(tenantID 来自租户注册表数值 ID,非用户输入)
|
||||
selects = append(selects, fmt.Sprintf(`SELECT id,tenant_id,topic COLLATE utf8mb4_0900_ai_ci AS topic,seqid,from_user,
|
||||
return fmt.Sprintf(`SELECT id,tenant_id,topic COLLATE utf8mb4_0900_ai_ci AS topic,seqid,from_user,
|
||||
msg_type COLLATE utf8mb4_0900_ai_ci AS msg_type,status COLLATE utf8mb4_0900_ai_ci AS status,
|
||||
content,head,reply_seqid,mentioned_user_ids,created_at,updated_at
|
||||
FROM im_group_messages AS legacy WHERE legacy.tenant_id=%d AND NOT EXISTS (
|
||||
SELECT 1 FROM im_group_message_topic_shards AS route
|
||||
WHERE route.topic=legacy.topic COLLATE utf8mb4_0900_ai_ci AND legacy.seqid BETWEEN route.min_seq AND route.max_seq)`, int64(tenantID)))
|
||||
return "(" + strings.Join(selects, " UNION ALL ") + ")", nil
|
||||
SELECT 1 FROM im_group_message_shards AS route
|
||||
WHERE route.tenant_id=legacy.tenant_id AND route.status<>'archived'
|
||||
AND legacy.created_at>=route.shard_start AND legacy.created_at<route.shard_end)`, int64(tenantID))
|
||||
}
|
||||
|
||||
func validInternalGroupMessageTable(table string) bool {
|
||||
|
||||
Reference in New Issue
Block a user