refine idle conv

This commit is contained in:
Jicheng Lu 2025-01-10 12:58:16 -06:00
parent 43eb549bd0
commit c5c2117fd0
2 changed files with 6 additions and 3 deletions

View file

@ -507,12 +507,13 @@ namespace BotSharp.Core.Repository
continue;
}
if (excludeAgentIds.Contains(conv.AgentId) || conv.UpdatedTime > utcNow.AddHours(-bufferHours))
if (conv.UpdatedTime > utcNow.AddHours(-bufferHours))
{
continue;
}
if (conv.DialogCount <= messageLimit)
if ((excludeAgentIds.Contains(conv.AgentId) && conv.DialogCount == 0)
|| (!excludeAgentIds.Contains(conv.AgentId) && conv.DialogCount <= messageLimit))
{
ids.Add(conv.Id);
if (ids.Count >= batchSize)

View file

@ -455,7 +455,9 @@ public partial class MongoRepository
{
var skip = (page - 1) * batchSize;
var candidates = _dc.Conversations.AsQueryable()
.Where(x => !excludeAgentIds.Contains(x.AgentId) && x.DialogCount <= messageLimit && x.UpdatedTime <= utcNow.AddHours(-bufferHours))
.Where(x => ((!excludeAgentIds.Contains(x.AgentId) && x.DialogCount <= messageLimit)
|| (excludeAgentIds.Contains(x.AgentId) && x.DialogCount == 0))
&& x.UpdatedTime <= utcNow.AddHours(-bufferHours))
.Skip(skip)
.Take(batchSize)
.Select(x => x.Id)