Skip to content
Snippets Groups Projects
Commit e1f35d8a authored by Cédric Anne's avatar Cédric Anne
Browse files

Used indexed field on count/groupby operations

parent b0ddab3c
No related branches found
No related tags found
No related merge requests found
......@@ -111,10 +111,10 @@ class Plugin extends Model {
public function scopeTrendingTop($query) {
$query->select(['plugin.id', 'plugin.name', 'plugin.key', 'plugin.download_count',
DB::raw('COUNT(name) as recent_downloads')])
DB::raw('COUNT(plugin.id) as recent_downloads')])
->join('plugin_download', 'plugin.id', '=', 'plugin_download.plugin_id')
->where('downloaded_at', '>', DB::raw('NOW() - INTERVAL 1 MONTH'))
->groupBy('plugin.name')
->groupBy('plugin.id')
->orderBy('recent_downloads', 'DESC');
return $query;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment