Skip to content

Instantly share code, notes, and snippets.

@SlyNet
Created April 3, 2015 13:16
Show Gist options
  • Save SlyNet/2978ca3208dd2b0904d6 to your computer and use it in GitHub Desktop.
Save SlyNet/2978ca3208dd2b0904d6 to your computer and use it in GitHub Desktop.
$batchSize = 128
$questionnaireId = '205d67e524-e29b-4641-b581-f6d460ac4f22'
$databaseUrl = 'http://localhost:8080/databases/HeadquartersViews'
$eventStoreUrl = 'http://127.0.0.1:2114/streams'
$skip = 0
do {
$interviewsBatch = Invoke-RestMethod "$databaseUrl/indexes/InterviewsSearchIndex?query=QuestionnaireId%3A%$questionnaireId&start=$skip&pageSize=$batchSize"
$skip = $interviewsBatch.Results.Count
foreach ($interview in $interviewsBatch.Results) {
$interviewId = [System.Guid]::Parse($interview.InterviewId)
$streamId = $interviewId.ToString("N")
$eventStream = Invoke-RestMethod "$eventStoreUrl/WB-$streamId/head/backward/150" -Headers @{Accept = "application/json"}
$changedStatusEventUrl = $eventStream.entries | ? {$_.summary -eq 'interviewStatusChanged' } | % { $_.id } | select -First 1
$eventData = Invoke-RestMethod $changedStatusEventUrl -Headers @{Accept = "application/json"}
if ($eventData.status -ne $interview.Status){
Write-Host $streamId " Raven:" $interview.Status "Events: " $eventData.status
}
}
} while($interviewsBatch.Results.Count -ne 0 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment