Merge pull request #823 from iceljc/master

refine idle conv
This commit is contained in:
iceljc 2025-01-10 12:58:51 -06:00 committed by GitHub
commit a4b7f77a65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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)