fix: creation date argument in search events filters (#6855)

* fix: creation date filter in event queries

* fix: creation date with ordering filter

* simplify code

* simplify review

---------

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Elio Bischof
2023-11-03 15:52:48 +01:00
committed by GitHub
parent 9378e19090
commit 1b6e3dcf27
6 changed files with 47 additions and 8 deletions

View File

@@ -66,7 +66,13 @@ func filterAuditLogRetention(ctx context.Context, auditLogRetention time.Duratio
if callTime.IsZero() {
callTime = time.Now()
}
return builder.CreationDateAfter(callTime.Add(-auditLogRetention))
oldestAllowed := callTime.Add(-auditLogRetention)
// The audit log retention time should overwrite the creation date after query only if it is older
// For example API calls should still be able to restrict the creation date after to a more recent date
if builder.GetCreationDateAfter().Before(oldestAllowed) {
return builder.CreationDateAfter(oldestAllowed)
}
return builder
}
func (q *Queries) SearchEventTypes(ctx context.Context) []string {