add time range
This commit is contained in:
parent
81b2f299cd
commit
7f6f5685f2
|
|
@ -8,6 +8,8 @@ public class InstructLogFilter : Pagination
|
||||||
public List<string>? TemplateNames { get; set; }
|
public List<string>? TemplateNames { get; set; }
|
||||||
public List<string>? UserIds { get; set; }
|
public List<string>? UserIds { get; set; }
|
||||||
public List<KeyValue>? States { get; set; }
|
public List<KeyValue>? States { get; set; }
|
||||||
|
public DateTime? StartTime { get; set; }
|
||||||
|
public DateTime? EndTime { get; set; }
|
||||||
|
|
||||||
public static InstructLogFilter Empty()
|
public static InstructLogFilter Empty()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,10 @@ public partial class FileRepository
|
||||||
{
|
{
|
||||||
matched = matched && record.CreatedTime >= filter.StartTime.Value;
|
matched = matched && record.CreatedTime >= filter.StartTime.Value;
|
||||||
}
|
}
|
||||||
|
if (filter?.EndTime != null)
|
||||||
|
{
|
||||||
|
matched = matched && record.CreatedTime <= filter.EndTime.Value;
|
||||||
|
}
|
||||||
if (filter?.Tags != null && filter.Tags.Any())
|
if (filter?.Tags != null && filter.Tags.Any())
|
||||||
{
|
{
|
||||||
matched = matched && !record.Tags.IsNullOrEmpty() && record.Tags.Exists(t => filter.Tags.Contains(t));
|
matched = matched && !record.Tags.IsNullOrEmpty() && record.Tags.Exists(t => filter.Tags.Contains(t));
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,14 @@ namespace BotSharp.Core.Repository
|
||||||
{
|
{
|
||||||
matched = matched && filter.UserIds.Contains(log.UserId);
|
matched = matched && filter.UserIds.Contains(log.UserId);
|
||||||
}
|
}
|
||||||
|
if (filter.StartTime.HasValue)
|
||||||
|
{
|
||||||
|
matched = matched && log.CreatedTime >= filter.StartTime.Value;
|
||||||
|
}
|
||||||
|
if (filter.EndTime.HasValue)
|
||||||
|
{
|
||||||
|
matched = matched && log.CreatedTime <= filter.EndTime.Value;
|
||||||
|
}
|
||||||
|
|
||||||
// Check states
|
// Check states
|
||||||
if (matched && filter != null && !filter.States.IsNullOrEmpty())
|
if (matched && filter != null && !filter.States.IsNullOrEmpty())
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,14 @@ public partial class MongoRepository
|
||||||
{
|
{
|
||||||
logFilters.Add(logBuilder.In(x => x.TemplateName, filter.TemplateNames));
|
logFilters.Add(logBuilder.In(x => x.TemplateName, filter.TemplateNames));
|
||||||
}
|
}
|
||||||
|
if (filter.StartTime.HasValue)
|
||||||
|
{
|
||||||
|
logFilters.Add(logBuilder.Gte(x => x.CreatedTime, filter.StartTime.Value));
|
||||||
|
}
|
||||||
|
if (filter.EndTime.HasValue)
|
||||||
|
{
|
||||||
|
logFilters.Add(logBuilder.Lte(x => x.CreatedTime, filter.EndTime.Value));
|
||||||
|
}
|
||||||
|
|
||||||
// Filter states
|
// Filter states
|
||||||
if (filter != null && !filter.States.IsNullOrEmpty())
|
if (filter != null && !filter.States.IsNullOrEmpty())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue