Trim heavy search stages to avoid 504
build-push / docker (push) Successful in 4m2s

This commit is contained in:
AI Assistant
2026-03-16 13:55:10 +09:00
parent c92ef97c98
commit a37e02aea9
4 changed files with 18 additions and 7 deletions
+11
View File
@@ -341,6 +341,17 @@
- [ ] full browser-level validation was not fully reproducible in this environment
## Recent Change Log
- Date: `2026-03-16`
- What changed:
- Reduced the heaviest search-stage caps slightly: fewer query variants per request, smaller per-source result caps, lower enrichment scope, and a bounded Gemini candidate set.
- Why it changed:
- The widened search configuration was pushing the request past the reverse-proxy timeout and surfacing `504 Gateway Time-out`.
- How it was verified:
- `go test ./...`
- `bash scripts/selftest.sh`
- What is still risky or incomplete:
- Search coverage is still broader than the original baseline, but there is now an explicit tradeoff between result volume and request latency.
- Date: `2026-03-16`
- What changed:
- Increased collector result caps and widened source-specific search query templates for Envato, Artgrid, and Google Video.
+3 -3
View File
@@ -64,9 +64,9 @@ func (s *SearchService) SearchMedia(queries []string, enabledPlatforms map[strin
results := make([]SearchResult, 0, 90)
var lastErr error
baseQueries := limitQueries(queries, 10)
baseQueries := limitQueries(queries, 8)
shuffleStrings(baseQueries)
primaryQueries := baseQueries[:minInt(len(baseQueries), 5)]
primaryQueries := baseQueries[:minInt(len(baseQueries), 4)]
runSearchPass := func(bases []string, onlyMissing bool) {
for _, base := range bases {
base = strings.TrimSpace(base)
@@ -127,7 +127,7 @@ func (s *SearchService) SearchMedia(queries []string, enabledPlatforms map[strin
}
func (s *SearchService) EnrichResults(results []SearchResult) []SearchResult {
limit := minInt(len(results), 18)
limit := minInt(len(results), 12)
if limit == 0 {
return results
}
+1 -1
View File
@@ -87,7 +87,7 @@ func RankSearchResults(query string, results []SearchResult) []SearchResult {
}
func GeminiCandidateLimit(total int) int {
return total
return min(total, 12)
}
func EvaluateAllCandidatesWithGemini(service *GeminiService, query string, ranked []SearchResult) ([]AIRecommendation, GeminiBatchStats, error) {
+3 -3
View File
@@ -15,7 +15,7 @@ type searchCollector interface {
type envatoCollector struct{}
func (envatoCollector) Name() string { return "Envato" }
func (envatoCollector) MaxResults() int { return 14 }
func (envatoCollector) MaxResults() int { return 10 }
func (envatoCollector) Enabled(enabledPlatforms map[string]bool) bool {
return len(enabledPlatforms) == 0 || enabledPlatforms["envato"]
}
@@ -31,7 +31,7 @@ func (envatoCollector) Enrich(searcher *SearchService, result SearchResult) Sear
type artgridCollector struct{}
func (artgridCollector) Name() string { return "Artgrid" }
func (artgridCollector) MaxResults() int { return 14 }
func (artgridCollector) MaxResults() int { return 10 }
func (artgridCollector) Enabled(enabledPlatforms map[string]bool) bool {
return len(enabledPlatforms) == 0 || enabledPlatforms["artgrid"]
}
@@ -47,7 +47,7 @@ func (artgridCollector) Enrich(searcher *SearchService, result SearchResult) Sea
type googleVideoCollector struct{}
func (googleVideoCollector) Name() string { return "Google Video" }
func (googleVideoCollector) MaxResults() int { return 10 }
func (googleVideoCollector) MaxResults() int { return 8 }
func (googleVideoCollector) Enabled(enabledPlatforms map[string]bool) bool {
return len(enabledPlatforms) == 0 || enabledPlatforms["google video"]
}