fix: 消息时间改为累加方式,确保对话顺序严格单调递增
This commit is contained in:
@@ -815,8 +815,12 @@ def sync_to_central(pg, sp_id: int, contacts_data, run_counter: int = 1):
|
||||
|
||||
for j, (sender_role, msg_type, content) in enumerate(messages):
|
||||
local_id_counter += 1
|
||||
# 时间递增:每条消息间隔 2~30 分钟
|
||||
msg_time = base_time + time_offset + dt.timedelta(minutes=j * random.randint(2, 30))
|
||||
# 时间递增:每条消息在前一条基础上累加 2~30 分钟,确保单调递增
|
||||
if j == 0:
|
||||
cumulative_minutes = 0
|
||||
else:
|
||||
cumulative_minutes += random.randint(2, 30)
|
||||
msg_time = base_time + time_offset + dt.timedelta(minutes=cumulative_minutes)
|
||||
|
||||
if sender_role == "customer":
|
||||
sender_wx = wx_username if not is_group else f"wxid_customer_{j}"
|
||||
|
||||
Reference in New Issue
Block a user