Skip to content

Commit a4b7f77

Browse files
authored
Merge pull request #823 from iceljc/master
refine idle conv
2 parents 43eb549 + c5c2117 commit a4b7f77

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,13 @@ public List<string> GetIdleConversations(int batchSize, int messageLimit, int bu
507507
continue;
508508
}
509509

510-
if (excludeAgentIds.Contains(conv.AgentId) || conv.UpdatedTime > utcNow.AddHours(-bufferHours))
510+
if (conv.UpdatedTime > utcNow.AddHours(-bufferHours))
511511
{
512512
continue;
513513
}
514514

515-
if (conv.DialogCount <= messageLimit)
515+
if ((excludeAgentIds.Contains(conv.AgentId) && conv.DialogCount == 0)
516+
|| (!excludeAgentIds.Contains(conv.AgentId) && conv.DialogCount <= messageLimit))
516517
{
517518
ids.Add(conv.Id);
518519
if (ids.Count >= batchSize)

src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Conversation.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,9 @@ public List<string> GetIdleConversations(int batchSize, int messageLimit, int bu
455455
{
456456
var skip = (page - 1) * batchSize;
457457
var candidates = _dc.Conversations.AsQueryable()
458-
.Where(x => !excludeAgentIds.Contains(x.AgentId) && x.DialogCount <= messageLimit && x.UpdatedTime <= utcNow.AddHours(-bufferHours))
458+
.Where(x => ((!excludeAgentIds.Contains(x.AgentId) && x.DialogCount <= messageLimit)
459+
|| (excludeAgentIds.Contains(x.AgentId) && x.DialogCount == 0))
460+
&& x.UpdatedTime <= utcNow.AddHours(-bufferHours))
459461
.Skip(skip)
460462
.Take(batchSize)
461463
.Select(x => x.Id)

0 commit comments

Comments
 (0)