Merge pull request #1102 from iceljc/master

Filter conversation by agent ids
This commit is contained in:
iceljc 2025-07-15 14:42:44 -05:00 committed by GitHub
commit efe4d9fea7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 5 deletions

View file

@ -10,6 +10,7 @@ public class ConversationFilter
public string? Title { get; set; }
public string? TitleAlias { get; set; }
public string? AgentId { get; set; }
public List<string>? AgentIds { get; set; }
public string? Status { get; set; }
public string? Channel { get; set; }
public string? ChannelId { get; set; }

View file

@ -7,6 +7,15 @@ public class SideCarOptions
public static SideCarOptions Empty()
{
return new SideCarOptions();
return new();
}
public static SideCarOptions InheritStates(IEnumerable<string>? targetStates = null)
{
return new()
{
IsInheritStates = true,
InheritStateKeys = targetStates
};
}
}

View file

@ -396,6 +396,12 @@ public partial class FileRepository
Directory.CreateDirectory(dir);
}
if (filter?.AgentId != null)
{
filter.AgentIds ??= [];
filter.AgentIds.Add(filter.AgentId);
}
var totalDirs = Directory.GetDirectories(dir);
foreach (var d in totalDirs)
{
@ -419,9 +425,9 @@ public partial class FileRepository
{
matched = matched && record.TitleAlias.Contains(filter.TitleAlias);
}
if (filter?.AgentId != null)
if (filter?.AgentIds != null && filter.AgentIds.Any())
{
matched = matched && record.AgentId == filter.AgentId;
matched = matched && filter.AgentIds.Contains(record.AgentId);
}
if (filter?.Status != null)
{

View file

@ -346,6 +346,12 @@ public partial class MongoRepository
var convBuilder = Builders<ConversationDocument>.Filter;
var convFilters = new List<FilterDefinition<ConversationDocument>>() { convBuilder.Empty };
if (filter?.AgentId != null)
{
filter.AgentIds ??= [];
filter.AgentIds.Add(filter.AgentId);
}
// Filter conversations
if (!string.IsNullOrEmpty(filter?.Id))
{
@ -359,9 +365,9 @@ public partial class MongoRepository
{
convFilters.Add(convBuilder.Regex(x => x.Title, new BsonRegularExpression(filter.TitleAlias, "i")));
}
if (!string.IsNullOrEmpty(filter?.AgentId))
if (filter?.AgentIds != null && filter.AgentIds.Any())
{
convFilters.Add(convBuilder.Eq(x => x.AgentId, filter.AgentId));
convFilters.Add(convBuilder.In(x => x.AgentId, filter.AgentIds));
}
if (!string.IsNullOrEmpty(filter?.Status))
{