This commit is contained in:
+57
-23
@@ -81,14 +81,17 @@ type PreviewResponse struct {
|
||||
}
|
||||
|
||||
type searchDebugSummary struct {
|
||||
Total int `json:"total"`
|
||||
BySource map[string]int `json:"bySource"`
|
||||
WithPreview int `json:"withPreview"`
|
||||
WithThumbnail int `json:"withThumbnail"`
|
||||
Top []map[string]any `json:"top"`
|
||||
Warning string `json:"warning,omitempty"`
|
||||
DurationMS int64 `json:"durationMs,omitempty"`
|
||||
GeminiCandidateCap int `json:"geminiCandidateCap,omitempty"`
|
||||
Total int `json:"total"`
|
||||
BySource map[string]int `json:"bySource"`
|
||||
WithPreview int `json:"withPreview"`
|
||||
WithThumbnail int `json:"withThumbnail"`
|
||||
WithUsableThumbnail int `json:"withUsableThumbnail,omitempty"`
|
||||
WithLowValueThumbnail int `json:"withLowValueThumbnail,omitempty"`
|
||||
WithEmbedURL int `json:"withEmbedUrl,omitempty"`
|
||||
Top []map[string]any `json:"top"`
|
||||
Warning string `json:"warning,omitempty"`
|
||||
DurationMS int64 `json:"durationMs,omitempty"`
|
||||
GeminiCandidateCap int `json:"geminiCandidateCap,omitempty"`
|
||||
}
|
||||
|
||||
type debugResponseWriter struct {
|
||||
@@ -484,6 +487,9 @@ func (a *App) searchMedia(c *gin.Context) {
|
||||
)
|
||||
}
|
||||
merged = services.RandomizeTopRecommendations(merged, 8)
|
||||
for idx := range merged {
|
||||
merged[idx] = services.DecorateRecommendationMedia(merged[idx])
|
||||
}
|
||||
warning := ""
|
||||
if geminiErr != nil {
|
||||
warning = geminiErr.Error()
|
||||
@@ -628,6 +634,8 @@ func summarizeSearchResults(results []services.SearchResult, duration time.Durat
|
||||
bySource := map[string]int{}
|
||||
withPreview := 0
|
||||
withThumbnail := 0
|
||||
withUsableThumbnail := 0
|
||||
withLowValueThumbnail := 0
|
||||
top := make([]map[string]any, 0, min(6, len(results)))
|
||||
for idx, item := range results {
|
||||
bySource[item.Source]++
|
||||
@@ -636,6 +644,12 @@ func summarizeSearchResults(results []services.SearchResult, duration time.Durat
|
||||
}
|
||||
if strings.TrimSpace(item.ThumbnailURL) != "" {
|
||||
withThumbnail++
|
||||
if services.HasUsableThumbnail(item.ThumbnailURL) {
|
||||
withUsableThumbnail++
|
||||
}
|
||||
if services.IsLowValueThumbnail(item.ThumbnailURL) {
|
||||
withLowValueThumbnail++
|
||||
}
|
||||
}
|
||||
if idx < 6 {
|
||||
top = append(top, map[string]any{
|
||||
@@ -643,20 +657,23 @@ func summarizeSearchResults(results []services.SearchResult, duration time.Durat
|
||||
"source": item.Source,
|
||||
"hasPreview": item.PreviewVideoURL != "",
|
||||
"hasThumbnail": item.ThumbnailURL != "",
|
||||
"usableThumb": services.HasUsableThumbnail(item.ThumbnailURL),
|
||||
"displayLink": item.DisplayLink,
|
||||
"snippetSample": truncateText(item.Snippet, 160),
|
||||
})
|
||||
}
|
||||
}
|
||||
return searchDebugSummary{
|
||||
Total: len(results),
|
||||
BySource: bySource,
|
||||
WithPreview: withPreview,
|
||||
WithThumbnail: withThumbnail,
|
||||
Top: top,
|
||||
Warning: warning,
|
||||
DurationMS: duration.Milliseconds(),
|
||||
GeminiCandidateCap: geminiCap,
|
||||
Total: len(results),
|
||||
BySource: bySource,
|
||||
WithPreview: withPreview,
|
||||
WithThumbnail: withThumbnail,
|
||||
WithUsableThumbnail: withUsableThumbnail,
|
||||
WithLowValueThumbnail: withLowValueThumbnail,
|
||||
Top: top,
|
||||
Warning: warning,
|
||||
DurationMS: duration.Milliseconds(),
|
||||
GeminiCandidateCap: geminiCap,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,6 +681,9 @@ func summarizeRecommendationResults(results []services.AIRecommendation, duratio
|
||||
bySource := map[string]int{}
|
||||
withPreview := 0
|
||||
withThumbnail := 0
|
||||
withUsableThumbnail := 0
|
||||
withLowValueThumbnail := 0
|
||||
withEmbedURL := 0
|
||||
top := make([]map[string]any, 0, min(6, len(results)))
|
||||
for idx, item := range results {
|
||||
bySource[item.Source]++
|
||||
@@ -672,6 +692,15 @@ func summarizeRecommendationResults(results []services.AIRecommendation, duratio
|
||||
}
|
||||
if strings.TrimSpace(item.ThumbnailURL) != "" {
|
||||
withThumbnail++
|
||||
if services.HasUsableThumbnail(item.ThumbnailURL) {
|
||||
withUsableThumbnail++
|
||||
}
|
||||
if services.IsLowValueThumbnail(item.ThumbnailURL) {
|
||||
withLowValueThumbnail++
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(item.EmbedURL) != "" {
|
||||
withEmbedURL++
|
||||
}
|
||||
if idx < 6 {
|
||||
top = append(top, map[string]any{
|
||||
@@ -679,19 +708,24 @@ func summarizeRecommendationResults(results []services.AIRecommendation, duratio
|
||||
"source": item.Source,
|
||||
"hasPreview": item.PreviewVideoURL != "",
|
||||
"hasThumbnail": item.ThumbnailURL != "",
|
||||
"hasEmbed": item.EmbedURL != "",
|
||||
"mediaMode": item.MediaMode,
|
||||
"reasonSample": truncateText(item.Reason, 120),
|
||||
"snippetSample": truncateText(item.Snippet, 160),
|
||||
})
|
||||
}
|
||||
}
|
||||
return searchDebugSummary{
|
||||
Total: len(results),
|
||||
BySource: bySource,
|
||||
WithPreview: withPreview,
|
||||
WithThumbnail: withThumbnail,
|
||||
Top: top,
|
||||
Warning: warning,
|
||||
DurationMS: duration.Milliseconds(),
|
||||
Total: len(results),
|
||||
BySource: bySource,
|
||||
WithPreview: withPreview,
|
||||
WithThumbnail: withThumbnail,
|
||||
WithUsableThumbnail: withUsableThumbnail,
|
||||
WithLowValueThumbnail: withLowValueThumbnail,
|
||||
WithEmbedURL: withEmbedURL,
|
||||
Top: top,
|
||||
Warning: warning,
|
||||
DurationMS: duration.Milliseconds(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user