Hero: varianten op de achtergrond knippen; upload en opslaan antwoorden direct
Opslaan van 8 foto's met gewijzigde focus duurde 40 s op een snelle pc en ruim 3 minuten op de Pi (proxy-timeout 60 s gaf 504, hero niet bewaard). Upload bewaart het origineel en antwoordt; HeroRenderService knipt de set per afbeelding en schakelt over zodra de set compleet is (oude set blijft ondertussen live; afbeelding zonder set wordt niet gepubliceerd). Opslaan legt alleen de focus vast. Admin toont 'wordt verwerkt' en ververst zelf; Seed-Hero wacht tot alles klaar is. Metingen: HeroSaveTimingTests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,17 @@ $payload = [ordered]@{
|
||||
try {
|
||||
$saved = Invoke-RestMethod -Method Put -Uri "$api/hero" -Headers $headers -ContentType 'application/json; charset=utf-8' -Body ([Text.Encoding]::UTF8.GetBytes($payload))
|
||||
Write-Host "saved hero $($saved.id) with $($saved.slides.Count) slide(s); live: $($saved.isLive)"
|
||||
# The variants of the photos are cut in the background (about half a minute per photo on a Raspberry Pi); a photo goes
|
||||
# live as soon as its set is ready. Wait for them so the script ends when the site shows everything (at most 15 minutes).
|
||||
$deadline = (Get-Date).AddMinutes(15)
|
||||
do {
|
||||
$state = Invoke-RestMethod -Method Get -Uri "$api/hero/all" -Headers $headers
|
||||
$waiting = @($state.slides | Where-Object { $_.image.processing }).Count
|
||||
if ($waiting -eq 0) { break }
|
||||
Write-Host "wait $waiting photo(s) are still being prepared in the background"
|
||||
Start-Sleep -Seconds 15
|
||||
} while ((Get-Date) -lt $deadline)
|
||||
if ($waiting -eq 0) { Write-Host "ready all photos are prepared" } else { Write-Warning "$waiting photo(s) are still being prepared; they appear on the site by themselves." }
|
||||
}
|
||||
catch {
|
||||
Write-Error "Saving the hero failed: $($_.Exception.Message) $($_.ErrorDetails.Message)"
|
||||
|
||||
Reference in New Issue
Block a user