# Most Downloaded

## Route

- URL: `GET /discover/most-downloaded`
- Controller: `App\Http\Controllers\Web\DiscoverController::mostDownloaded()`
- Service: `App\Services\ArtworkSearchService::discoverMostDownloaded()`

## What the page reads

This page is Meilisearch-ranked and then hydrated from MySQL.

## Search query

`discoverMostDownloaded()` uses:

- filter: `is_public = true AND is_approved = true`
- sort:
  - `downloads:desc`
  - `views:desc`

In the indexed document:

- `downloads` is sourced from `artwork_stats.downloads`
- `views` is sourced from `artwork_stats.views`

This is therefore an all-time leaderboard, not a rolling-window leaderboard.

## Where the download counts come from

Downloads are recorded in two places:

1. `artwork_downloads`
   - full event log of each tracked download
2. `artwork_stats.downloads`
   - all-time aggregate counter used by this page

The page sorts on the aggregate counter, not by counting the event log live.

## Background jobs and schedules

No dedicated page-specific cron exists.

Relevant active maintenance:

- `skinbase:flush-redis-stats` every 5 minutes
  - pushes deferred Redis counters into MySQL

Window reset commands exist too, but they maintain `downloads_24h` and `downloads_7d` rather than the all-time `downloads` column used by this page.

## Cache behavior

- Cache key: `discover.most-downloaded.{page}`
- TTL: 300 seconds

## Notes

- This page is separate from `Today Downloads`.
- If you need "what is hot today by download activity," use the dedicated `/downloads/today` page instead.