refine conv filter
This commit is contained in:
parent
0198fbccbb
commit
3d1c3c0daa
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue