Skip to content

Commit f47963c

Browse files
authored
Merge pull request #905 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 4904426 + 94663e3 commit f47963c

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-OrchestratorBatchItems.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function Push-OrchestratorBatchItems {
1414
$Item = $_.BatchItem | ConvertFrom-Json
1515
$BatchItems.Add($Item)
1616
}
17-
Remove-AzDataTableEntity @Table -Entity $Entities -Force
1817
Write-Information "Retrieved $($BatchItems.Count) batch items for BatchId: $($Item.Parameters.BatchId)"
1918
} else {
2019
$BatchItems = [system.Collections.Generic.List[object]]::new()

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogProcessingBatch.ps1

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,29 @@ function Push-AuditLogProcessingBatch {
2828

2929
do {
3030
# Fetch only the properties needed to determine claim status and build the batch
31-
$WebhookCache = Get-CIPPAzDataTableEntity @WebhookCacheTable -First $PageSize -Skip $Skip -Property @('PartitionKey', 'RowKey', 'ETag', 'CippProcessing', 'CippProcessingStarted')
31+
$WebhookCache = Get-CIPPAzDataTableEntity @WebhookCacheTable -First $PageSize -Skip $Skip -Property @('PartitionKey', 'RowKey', 'ETag', 'Timestamp', 'CippProcessing')
3232
$PageCount = $WebhookCache.Count
3333

3434
# Filter client-side: skip rows actively claimed unless the claim is stale (> 4 hours old)
3535
$TenantGroups = $WebhookCache | Where-Object {
3636
-not $_.CippProcessing -or
37-
(-not $_.CippProcessingStarted) -or
38-
([datetime]$_.CippProcessingStarted -lt $StaleThreshold)
37+
($_.Timestamp -and $_.Timestamp.UtcDateTime -lt $StaleThreshold)
3938
} | Group-Object -Property PartitionKey
4039
$WebhookCache = $null
4140

4241
if ($TenantGroups) {
43-
$ProcessingTimestamp = $NowUtc.ToString('yyyy-MM-ddTHH:mm:ssZ')
4442
foreach ($TenantGroup in $TenantGroups) {
4543
$TenantFilter = $TenantGroup.Name
4644
$Rows = @($TenantGroup.Group)
4745
$RowIds = @($Rows.RowKey)
4846

4947
# Claim these rows so subsequent timer runs skip them (UpsertMerge preserves JSON and other fields)
48+
# The entity Timestamp is updated automatically on write and used for stale detection.
5049
foreach ($Row in $Rows) {
5150
$ClaimEntity = [PSCustomObject]@{
52-
PartitionKey = $Row.PartitionKey
53-
RowKey = $Row.RowKey
54-
CippProcessing = $true
55-
CippProcessingStarted = $ProcessingTimestamp
51+
PartitionKey = $Row.PartitionKey
52+
RowKey = $Row.RowKey
53+
CippProcessing = $true
5654
}
5755
Add-CIPPAzDataTableEntity @WebhookCacheTable -Entity $ClaimEntity -OperationType UpsertMerge
5856
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Alerts/Invoke-ListAuditLogs.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ function Invoke-ListAuditLogs {
99
param($Request, $TriggerMetadata)
1010
# Interact with query parameters or the body of the request.
1111
$TenantFilter = ConvertTo-CIPPODataFilterValue -Value $Request.Query.tenantFilter -Type 'String'
12-
$LogID = ConvertTo-CIPPODataFilterValue -Value $Request.Query.LogId -Type 'Guid'
12+
13+
if ($Request.Query.LogId) {
14+
$LogID = ConvertTo-CIPPODataFilterValue -Value $Request.Query.LogId -Type 'Guid'
15+
}
1316
$StartDate = $Request.Query.StartDate
1417
$EndDate = $Request.Query.EndDate
1518
$RelativeTime = $Request.Query.RelativeTime

Modules/CIPPCore/Public/Entrypoints/Timer Functions/Start-TableCleanup.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ function Start-TableCleanup {
8585
Property = @('PartitionKey', 'RowKey', 'ETag')
8686
}
8787
}
88+
@{
89+
FunctionName = 'TableCleanupTask'
90+
Type = 'CleanupRule'
91+
TableName = 'CippOrchestratorBatch'
92+
DataTableProps = @{
93+
Filter = "Timestamp lt datetime'$((Get-Date).AddHours(-24).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ'))'"
94+
First = 10000
95+
Property = @('PartitionKey', 'RowKey', 'ETag')
96+
}
97+
}
8898
@{
8999
FunctionName = 'TableCleanupTask'
90100
Type = 'DeleteTable'

0 commit comments

Comments
 (0)