edit searchPopular comment

This commit is contained in:
perennial
2024-10-25 22:53:36 +11:00
parent bc8c55f5a4
commit e43d227a79
+12 -8
View File
@@ -108,19 +108,23 @@ func fetchResultsForSuffix(ctx context.Context, auditor *audit.Auditor, r *http.
return nil
}
// searchPopular performs a search for popular artworks.
// searchPopular performs a search for popular artworks using a descending popularity threshold strategy.
//
// The search strategy is as follows:
//
// 1. First checks the highest popularity threshold (100000 users)
// 1. Starts by checking the highest popularity threshold (100000 users).
// - If results are found at the highest threshold, it stores these results.
// - Continues checking lower thresholds in descending order (e.g., 50000, 30000, etc.),
// adding results until the resultsLimit is reached.
//
// 2. If results are found at highest threshold:
// - Continues checking lower thresholds in descending order until resultsLimit is reached
// 2. If no results are found at the highest threshold:
// - Temporarily stores results from the lowest threshold (50 users).
// - Then, checks all intermediate thresholds (50000 down to 100 users).
// - Uses the temporarily stored lowest threshold results only if the resultsLimit
// cannot be reached with results from higher thresholds.
//
// 3. If no results at highest threshold:
// - Temporarily stores results from lowest threshold (50 users)
// - Checks all intermediate thresholds (50000 down to 100 users)
// - Only uses lowest threshold results if resultsLimit cannot be reached with higher thresholds
// 3. Assembles the final list of results in descending order of popularity thresholds,
// stopping when the total number of results reaches resultsLimit.
func searchPopular(ctx context.Context, auditor *audit.Auditor, r *http.Request, settings SearchPageSettings, headers http.Header) (SearchArtworks, error) {
auditor.SugaredLogger.Debugw("Starting popular search", "query", settings.Name, "mode", settings.Category)
suffixes := []string{"100000", "50000", "30000", "10000", "5000", "1000", "500", "100", "50"}