mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-17 20:28:31 +02:00
feat: implement API router for catalogue and enseigne management with filtering and pagination
This commit is contained in:
1 parent
3d3d7c18c1
commit
b224c4988a
2 files changed
+50
-160
No files matched your search
@@ -0,0 +1,50 @@
|
||||
# Script to manually clean up catalogs and trigger scraping
|
||||
# Usage: ./scripts/manual_cleanup_and_scrape.ps1
|
||||
|
||||
$BaseUrl = "http://localhost:8555/api"
|
||||
$Username = "admin"
|
||||
$Password = "admin"
|
||||
|
||||
Write-Host "1. Logging in as $Username..." -ForegroundColor Cyan
|
||||
try {
|
||||
$LoginBody = @{
|
||||
username = $Username
|
||||
password = $Password
|
||||
} | ConvertTo-Json
|
||||
|
||||
$LoginResponse = Invoke-RestMethod -Method Post -Uri "$BaseUrl/auth/login" -Body $LoginBody -ContentType "application/json"
|
||||
$Token = $LoginResponse.token
|
||||
Write-Host " Success! Token received." -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host " Login failed. Please check if the server is running." -ForegroundColor Red
|
||||
Write-Error $_
|
||||
exit
|
||||
}
|
||||
|
||||
$Headers = @{
|
||||
Authorization = "Bearer $Token"
|
||||
}
|
||||
|
||||
Write-Host "`n2. Running Cleanup (Deleting invalid catalogs)..." -ForegroundColor Cyan
|
||||
try {
|
||||
$CleanupResponse = Invoke-RestMethod -Method Post -Uri "$BaseUrl/catalogues/admin/cleanup" -Headers $Headers
|
||||
Write-Host " $($CleanupResponse.message)" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host " Cleanup failed." -ForegroundColor Red
|
||||
Write-Error $_
|
||||
}
|
||||
|
||||
Write-Host "`n3. Triggering Scraping for Gifi (ID: 1)..." -ForegroundColor Cyan
|
||||
try {
|
||||
$ScrapeResponse = Invoke-RestMethod -Method Post -Uri "$BaseUrl/catalogues/admin/scraping/trigger?enseigne_id=1" -Headers $Headers
|
||||
Write-Host " $($ScrapeResponse.message)" -ForegroundColor Green
|
||||
Write-Host " Check logs at: $BaseUrl/catalogues/admin/scraping/logs" -ForegroundColor Yellow
|
||||
}
|
||||
catch {
|
||||
Write-Host " Scraping trigger failed." -ForegroundColor Red
|
||||
Write-Error $_
|
||||
}
|
||||
|
||||
Write-Host "`nDone." -ForegroundColor Cyan
|
||||
Reference in new issue
Block a user