mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Move stat functions to SiteStat model
This commit is contained in:
@@ -333,56 +333,6 @@ class Release extends Model
|
||||
return self::whereAnidbid($anidbID)->update(['anidbid' => -1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[]
|
||||
*/
|
||||
public static function getTopDownloads()
|
||||
{
|
||||
$expiresAt = now()->addMinutes(config('nntmux.cache_expiry_long'));
|
||||
$releases = Cache::get(md5('topDownloads'));
|
||||
if ($releases !== null) {
|
||||
return $releases;
|
||||
}
|
||||
$releases = self::query()
|
||||
->where('grabs', '>', 0)
|
||||
->select(['id', 'searchname', 'guid', 'adddate'])
|
||||
->selectRaw('SUM(grabs) as grabs')
|
||||
->groupBy('id', 'searchname', 'adddate')
|
||||
->havingRaw('SUM(grabs) > 0')
|
||||
->orderByDesc('grabs')
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
Cache::put(md5('topDownloads'), $releases, $expiresAt);
|
||||
|
||||
return $releases;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[]
|
||||
*/
|
||||
public static function getTopComments()
|
||||
{
|
||||
$expiresAt = now()->addMinutes(config('nntmux.cache_expiry_long'));
|
||||
$releases = Cache::get(md5('topComments'));
|
||||
if ($releases !== null) {
|
||||
return $releases;
|
||||
}
|
||||
$releases = self::query()
|
||||
->where('comments', '>', 0)
|
||||
->select(['id', 'guid', 'searchname'])
|
||||
->selectRaw('SUM(comments) AS comments')
|
||||
->groupBy('id', 'searchname', 'adddate')
|
||||
->havingRaw('SUM(comments) > 0')
|
||||
->orderByDesc('comments')
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
Cache::put(md5('topComments'), $releases, $expiresAt);
|
||||
|
||||
return $releases;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user