Skip to content

Commit 1b1e1c7

Browse files
committed
Simplify log date range filter in Invoke-ListLogs
Replaced the loop generating multiple partition key filters with a single filter using 'PartitionKey ge' and 'PartitionKey le' for date ranges. This streamlines the query and improves readability.
1 parent e96a91e commit 1b1e1c7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Modules/CIPPCore/Public/Entrypoints/Invoke-ListLogs.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,8 @@ function Invoke-ListLogs {
9292
$EndDate = $Request.Query.EndDate ?? $Request.Query.DateFilter
9393

9494
if ($StartDate -and $EndDate) {
95-
# Collect logs for each partition key date in range
96-
$PartitionKeys = for ($Date = [datetime]::ParseExact($StartDate, 'yyyyMMdd', $null); $Date -le [datetime]::ParseExact($EndDate, 'yyyyMMdd', $null); $Date = $Date.AddDays(1)) {
97-
$PartitionKey = $Date.ToString('yyyyMMdd')
98-
"PartitionKey eq '$PartitionKey'"
99-
}
100-
$Filter = $PartitionKeys -join ' or '
95+
# Collect logs for date range
96+
$Filter = "PartitionKey ge '$StartDate' and PartitionKey le '$EndDate'"
10197
} elseif ($StartDate) {
10298
$Filter = "PartitionKey eq '{0}'" -f $StartDate
10399
} else {

0 commit comments

Comments
 (0)