mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-30 17:58:59 +00:00
Rearrange pagination queries
This commit is contained in:
@@ -144,26 +144,24 @@ class AniDB
|
||||
* Retrieves a range of Anime titles for site display.
|
||||
*
|
||||
*
|
||||
* @param $page
|
||||
* @param string $animetitle
|
||||
*
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public function getAnimeRange($page, $animetitle = '')
|
||||
public function getAnimeRange($animetitle = '')
|
||||
{
|
||||
$query = AnidbTitle::query()
|
||||
->select(['at.anidbid', DB::raw("GROUP_CONCAT(at.title SEPARATOR ', ') AS title"), 'ai.description'])
|
||||
->from('anidb_titles as at')
|
||||
->leftJoin('anidb_info as ai', 'ai.anidbid', '=', 'at.anidbid')
|
||||
->where('at.lang', '=', 'en');
|
||||
if ($animetitle !== '') {
|
||||
$query->where('at.title', 'LIKE', '%'.$animetitle.'%');
|
||||
}
|
||||
$query->select(['at.anidbid', DB::raw("GROUP_CONCAT(at.title SEPARATOR ', ') AS title"), 'ai.description'])
|
||||
->from('anidb_titles as at')
|
||||
->leftJoin('anidb_info as ai', 'ai.anidbid', '=', 'at.anidbid')
|
||||
->groupBy('at.anidbid')
|
||||
->orderByDesc('at.anidbid');
|
||||
|
||||
$query->groupBy('at.anidbid')
|
||||
->orderByDesc('at.anidbid');
|
||||
|
||||
return $query->simplePaginate(config('nntmux.items_per_page'));
|
||||
return $query->paginate(config('nntmux.items_per_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+20
-18
@@ -152,7 +152,18 @@ class Books
|
||||
$order = $this->getBookOrder($orderBy);
|
||||
|
||||
$sql = Release::query()
|
||||
->select(
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('b.title', '!=', '')
|
||||
->where('b.cover', '=', 1);
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedCats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedCats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
$sql->select(
|
||||
[
|
||||
'b.*',
|
||||
'r.bookinfo_id',
|
||||
@@ -179,19 +190,7 @@ class Books
|
||||
->leftJoin('release_nfos as rn', 'rn.releases_id', '=', 'r.id')
|
||||
->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id')
|
||||
->join('bookinfo as b', 'b.id', '=', 'r.bookinfo_id')
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('b.title', '!=', '')
|
||||
->where('b.cover', '=', 1);
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedCats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedCats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
|
||||
$sql->groupBy('b.id')
|
||||
->groupBy('b.id')
|
||||
->orderBy($order[0], $order[1]);
|
||||
|
||||
$return = Cache::get(md5($page.implode('.', $cat).implode('.', $order).implode('.', $excludedCats)));
|
||||
@@ -199,7 +198,7 @@ class Books
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return = $sql->simplePaginate(config('nntmux.items_per_cover_page'));
|
||||
$return = $sql->paginate(config('nntmux.items_per_cover_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
|
||||
Cache::put(md5($page.implode('.', $cat).implode('.', $order).implode('.', $excludedCats)), $return, $expiresAt);
|
||||
@@ -464,7 +463,8 @@ class Books
|
||||
if (preg_match('/^([a-z0-9] )+$|ArtofUsenet|ekiosk|(ebook|mobi).+collection|erotica|Full Video|ImwithJamie|linkoff org|Mega.+pack|^[a-z0-9]+ (?!((January|February|March|April|May|June|July|August|September|O(c|k)tober|November|De(c|z)ember)))[a-z]+( (ebooks?|The))?$|NY Times|(Book|Massive) Dump|Sexual/i', $releasename)) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver('Changing category to misc books: ').ColorCLI::primary($releasename), true
|
||||
ColorCLI::headerOver('Changing category to misc books: ').ColorCLI::primary($releasename),
|
||||
true
|
||||
);
|
||||
}
|
||||
Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_UNKNOWN]);
|
||||
@@ -475,7 +475,8 @@ class Books
|
||||
if (preg_match('/^([a-z0-9ü!]+ ){1,2}(N|Vol)?\d{1,4}(a|b|c)?$|^([a-z0-9]+ ){1,2}(Jan( |unar|$)|Feb( |ruary|$)|Mar( |ch|$)|Apr( |il|$)|May(?![a-z0-9])|Jun( |e|$)|Jul( |y|$)|Aug( |ust|$)|Sep( |tember|$)|O(c|k)t( |ober|$)|Nov( |ember|$)|De(c|z)( |ember|$))/ui', $releasename) && ! preg_match('/Part \d+/i', $releasename)) {
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver('Changing category to magazines: ').ColorCLI::primary($releasename), true
|
||||
ColorCLI::headerOver('Changing category to magazines: ').ColorCLI::primary($releasename),
|
||||
true
|
||||
);
|
||||
}
|
||||
Release::query()->where('id', $releaseID)->update(['categories_id' => Category::BOOKS_MAGAZINES]);
|
||||
@@ -651,7 +652,8 @@ class Books
|
||||
ColorCLI::header('Nothing to update: ').
|
||||
ColorCLI::header($book['author'].
|
||||
' - '.
|
||||
$book['title']), true
|
||||
$book['title']),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ class Console
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return = $sql->simplePaginate(config('nntmux.items_per_cover_page'));
|
||||
$return = $sql->paginate(config('nntmux.items_per_cover_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
|
||||
Cache::put(md5($page.implode('.', $cat).implode('.', $excludedcats)), $return, $expiresAt);
|
||||
|
||||
+21
-19
@@ -194,7 +194,7 @@ class Games
|
||||
->from('gamesinfo as gi')
|
||||
->join('genres as g', 'gi.genres_id', '=', 'g.id')
|
||||
->orderByDesc('created_at')
|
||||
->simplePaginate(config('nntmux.items_per_page'));
|
||||
->paginate(config('nntmux.items_per_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,7 +218,18 @@ class Games
|
||||
public function getGamesRange($page, $cat, array $excludedcats = [])
|
||||
{
|
||||
$sql = Release::query()
|
||||
->select(
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('gi.title', '!=', '')
|
||||
->where('gi.cover', '=', 1);
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
$sql->select(
|
||||
[
|
||||
'gi.*',
|
||||
'r.gamesinfo_id',
|
||||
@@ -247,19 +258,7 @@ class Games
|
||||
->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id')
|
||||
->join('gamesinfo as gi', 'gi.id', '=', 'r.gamesinfo_id')
|
||||
->join('genres as gn', 'gi.genres_id', '=', 'gn.id')
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('gi.title', '!=', '')
|
||||
->where('gi.cover', '=', 1);
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
|
||||
$sql->groupBy('gi.id')
|
||||
->groupBy('gi.id')
|
||||
->orderBy('r.postdate', 'desc');
|
||||
|
||||
$return = Cache::get(md5($page.implode('.', $cat).implode('.', $excludedcats)));
|
||||
@@ -267,7 +266,7 @@ class Games
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return = $sql->simplePaginate(config('nntmux.items_per_cover_page'));
|
||||
$return = $sql->paginate(config('nntmux.items_per_cover_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
|
||||
Cache::put(md5($page.implode('.', $cat).implode('.', $excludedcats)), $return, $expiresAt);
|
||||
@@ -633,7 +632,8 @@ class Games
|
||||
ColorCLI::alternateOver(' Title: ').
|
||||
ColorCLI::primary($game['title']).
|
||||
ColorCLI::alternateOver(' Source: ').
|
||||
ColorCLI::primary($this->_classUsed), true
|
||||
ColorCLI::primary($this->_classUsed),
|
||||
true
|
||||
);
|
||||
}
|
||||
if ($game['cover'] === 1) {
|
||||
@@ -646,7 +646,8 @@ class Games
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver('Nothing to update: ').
|
||||
ColorCLI::primary($game['title'].' (PC)'), true
|
||||
ColorCLI::primary($game['title'].' (PC)'),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -689,7 +690,8 @@ class Games
|
||||
if ($this->echoOutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver('Looking up: ').
|
||||
ColorCLI::primary($gameInfo['title'].' (PC)'), true
|
||||
ColorCLI::primary($gameInfo['title'].' (PC)'),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -228,7 +228,18 @@ class Movie
|
||||
public function getMovieRange($page, $cat, array $excludedcats = [])
|
||||
{
|
||||
$sql = Release::query()
|
||||
->select(
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('m.title', '<>', '')
|
||||
->where('m.imdbid', '<>', '0000000');
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
$sql->select(
|
||||
[
|
||||
'm.*',
|
||||
'g.name as group_name',
|
||||
@@ -257,19 +268,7 @@ class Movie
|
||||
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
|
||||
->join('movieinfo as m', 'm.imdbid', '=', 'r.imdbid')
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('m.title', '<>', '')
|
||||
->where('m.imdbid', '<>', '0000000');
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
|
||||
$sql->groupBy('m.imdbid')
|
||||
->groupBy('m.imdbid')
|
||||
->orderBy('r.postdate', 'desc');
|
||||
|
||||
$return = Cache::get(md5($page.implode('.', $cat).implode('.', $excludedcats)));
|
||||
@@ -277,7 +276,7 @@ class Movie
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return = $sql->simplePaginate(config('nntmux.items_per_cover_page'));
|
||||
$return = $sql->paginate(config('nntmux.items_per_cover_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
|
||||
Cache::put(md5($page.implode('.', $cat).implode('.', $excludedcats)), $return, $expiresAt);
|
||||
@@ -665,7 +664,8 @@ class Movie
|
||||
$mov['year'].
|
||||
') - '.
|
||||
$mov['imdbid']
|
||||
), true
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+20
-18
@@ -148,7 +148,18 @@ class Music
|
||||
public function getMusicRange($page, $cat, array $excludedcats = [])
|
||||
{
|
||||
$sql = Release::query()
|
||||
->select(
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('m.title', '!=', '')
|
||||
->where('m.cover', '=', 1);
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
$sql->select(
|
||||
[
|
||||
'm.*',
|
||||
'r.musicinfo_id',
|
||||
@@ -177,19 +188,7 @@ class Music
|
||||
->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id')
|
||||
->join('musicinfo as m', 'm.id', '=', 'r.musicinfo_id')
|
||||
->join('genres as gn', 'm.genres_id', '=', 'gn.id')
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('m.title', '!=', '')
|
||||
->where('m.cover', '=', 1);
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
|
||||
$sql->groupBy('m.id')
|
||||
->groupBy('m.id')
|
||||
->orderBy('r.postdate', 'desc');
|
||||
|
||||
$return = Cache::get(md5($page.implode('.', $cat).implode('.', $excludedcats)));
|
||||
@@ -197,7 +196,7 @@ class Music
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return = $sql->simplePaginate(config('nntmux.items_per_cover_page'));
|
||||
$return = $sql->paginate(config('nntmux.items_per_cover_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
|
||||
Cache::put(md5($page.implode('.', $cat).implode('.', $excludedcats)), $return, $expiresAt);
|
||||
@@ -489,7 +488,8 @@ class Music
|
||||
ColorCLI::alternateOver(' Title: ').
|
||||
ColorCLI::primary($mus['title']).
|
||||
ColorCLI::alternateOver(' Year: ').
|
||||
ColorCLI::primary($mus['year']), true
|
||||
ColorCLI::primary($mus['year']),
|
||||
true
|
||||
);
|
||||
}
|
||||
$mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250);
|
||||
@@ -508,7 +508,8 @@ class Music
|
||||
' ('.
|
||||
$mus['year'].
|
||||
')'
|
||||
), true
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -621,7 +622,8 @@ class Music
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::header(
|
||||
'Processing '.$res->count().' music release(s).'
|
||||
), true
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class Regexes
|
||||
}
|
||||
$result->orderBy('id');
|
||||
|
||||
return $result->simplePaginate(config('nntmux.items_per_page'));
|
||||
return $result->paginate(config('nntmux.items_per_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+56
-72
@@ -66,15 +66,14 @@ class Releases
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $page
|
||||
* @param $page
|
||||
* @param array $cat
|
||||
* @param $orderBy
|
||||
* @param int $maxAge
|
||||
* @param $orderBy
|
||||
* @param int $maxAge
|
||||
* @param array $excludedCats
|
||||
* @param int $groupName
|
||||
* @param int $minSize
|
||||
*
|
||||
* @return \Illuminate\Contracts\Pagination\Paginator|mixed
|
||||
* @param int $groupName
|
||||
* @param int $minSize
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getBrowseRange($page, array $cat, $orderBy, $maxAge = -1, array $excludedCats = [], $groupName = -1, $minSize = 0)
|
||||
@@ -113,28 +112,12 @@ class Releases
|
||||
->leftJoin('release_nfos as rn', 're.releases_id', '=', 'r.id')
|
||||
->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id')
|
||||
->orderBy($orderBy[0], $orderBy[1]);
|
||||
self::showPasswords($qry, true);
|
||||
if ($cat !== [-1]) {
|
||||
Category::getCategorySearch($cat, $qry, true);
|
||||
}
|
||||
if ($maxAge > 0) {
|
||||
$qry->where('r.postdate', '>', Carbon::now()->subDays($maxAge));
|
||||
}
|
||||
if (\count($excludedCats) > 0) {
|
||||
$qry->whereNotIn('r.categories_id', $excludedCats);
|
||||
}
|
||||
if ($groupName !== -1) {
|
||||
$qry->where('g.name', $groupName);
|
||||
}
|
||||
if ($minSize > 0) {
|
||||
$qry->where('r.size', '>=', $minSize);
|
||||
}
|
||||
$releases = Cache::get(md5(implode('.', $cat).implode('.', $orderBy).$maxAge.implode('.', $excludedCats).$minSize.$groupName.$page));
|
||||
if ($releases !== null) {
|
||||
return $releases;
|
||||
}
|
||||
|
||||
$sql = $qry->simplePaginate(config('nntmux.items_per_page'));
|
||||
$sql = $qry->paginate(config('nntmux.items_per_page'));
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
|
||||
Cache::put(md5(implode('.', $cat).implode('.', $orderBy).$maxAge.implode('.', $excludedCats).$minSize.$groupName.$page), $sql, $expiresAt);
|
||||
|
||||
@@ -381,22 +364,7 @@ class Releases
|
||||
{
|
||||
$sql = Release::query()
|
||||
->with('group as g', 'nfo as rn', 'category as c', 'failed as df', 'episode as tve')
|
||||
->select(
|
||||
[
|
||||
'r.*',
|
||||
DB::raw("CONCAT(cp.title, '-', c.title) AS category_name"),
|
||||
'g.name as group_name',
|
||||
'rn.releases_id as nfoid',
|
||||
're.releases_id as reid',
|
||||
'tve.firstaired',
|
||||
'df.failed as failed',
|
||||
]
|
||||
)
|
||||
->from('releases as r')
|
||||
->leftJoin('video_data as re', 're.releases_id', '=', 'r.id')
|
||||
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
|
||||
->whereBetween('r.categories_id', [5000, 5999])
|
||||
->whereBetween('r.categories_id', [Category::TV_ROOT, Category::TV_OTHER])
|
||||
->where('r.nzbstatus', NZB::NZB_ADDED);
|
||||
self::showPasswords($sql, true);
|
||||
if (! empty($userShows)) {
|
||||
@@ -420,13 +388,29 @@ class Releases
|
||||
if ($maxAge > 0) {
|
||||
$sql->where('r.postdate', '>', Carbon::now()->subDays($maxAge));
|
||||
}
|
||||
$sql->select(
|
||||
[
|
||||
'r.*',
|
||||
DB::raw("CONCAT(cp.title, '-', c.title) AS category_name"),
|
||||
'g.name as group_name',
|
||||
'rn.releases_id as nfoid',
|
||||
're.releases_id as reid',
|
||||
'tve.firstaired',
|
||||
'df.failed as failed',
|
||||
]
|
||||
)
|
||||
->from('releases as r')
|
||||
->leftJoin('video_data as re', 're.releases_id', '=', 'r.id')
|
||||
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid');
|
||||
|
||||
|
||||
if ($orderBy !== '') {
|
||||
$order = $this->getBrowseOrder($orderBy);
|
||||
$sql->orderBy($order[0], $order[1]);
|
||||
}
|
||||
|
||||
return $sql->simplePaginate(config('nntmux.items_per_page'));
|
||||
return $sql->paginate(config('nntmux.items_per_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,18 +575,6 @@ class Releases
|
||||
|
||||
$sql = Release::query()
|
||||
->fromSub(function ($query) use ($maxAge, $groupName, $sizeFrom, $sizeRange, $sizeTo, $hasNfo, $hasComments, $cat, $excludedCats, $type, $daysNew, $daysOld, $searchOptions, $minSize) {
|
||||
$query->select(['r.*', 'r.categories_id AS category_ids', 'df.failed as failed', 'g.name as group_name', 'rn.releases_id as nfoid', 're.releases_id as reid', 'cp.id as categoryparentid', 'v.tvdb', 'v.trakt', 'v.tvrage', 'v.tvmaze', 'v.imdb', 'v.tmdb', 'tve.firstaired'])
|
||||
->selectRaw("CONCAT(cp.title, ' > ', c.title) AS category_name")
|
||||
->from('releases as r')
|
||||
->leftJoin('video_data as re', 're.releases_id', '=', 'r.id')
|
||||
->leftJoin('videos as v', 'v.id', '=', 'r.videos_id')
|
||||
->leftJoin('tv_episodes as tve', 'tve.id', '=', 'r.tv_episodes_id')
|
||||
->leftJoin('release_nfos as rn', 'rn.releases_id', '=', 'r.id')
|
||||
->leftJoin('groups as g', 'g.id', '=', 'r.groups_id')
|
||||
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
|
||||
->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id')
|
||||
->join('releases_se as rse', 'rse.id', '=', 'r.id');
|
||||
self::showPasswords($query, true);
|
||||
$query->where('r.nzbstatus', '=', NZB::NZB_ADDED);
|
||||
|
||||
@@ -651,6 +623,17 @@ class Releases
|
||||
if ($minSize > 0) {
|
||||
$query->where('r.size', '>=', $minSize);
|
||||
}
|
||||
$query->select(['r.*', 'r.categories_id AS category_ids', 'df.failed as failed', 'g.name as group_name', 'rn.releases_id as nfoid', 're.releases_id as reid', 'cp.id as categoryparentid', 'v.tvdb', 'v.trakt', 'v.tvrage', 'v.tvmaze', 'v.imdb', 'v.tmdb', 'tve.firstaired', DB::raw("CONCAT(cp.title, ' > ', c.title) AS category_name")])
|
||||
->from('releases as r')
|
||||
->leftJoin('video_data as re', 're.releases_id', '=', 'r.id')
|
||||
->leftJoin('videos as v', 'v.id', '=', 'r.videos_id')
|
||||
->leftJoin('tv_episodes as tve', 'tve.id', '=', 'r.tv_episodes_id')
|
||||
->leftJoin('release_nfos as rn', 'rn.releases_id', '=', 'r.id')
|
||||
->leftJoin('groups as g', 'g.id', '=', 'r.groups_id')
|
||||
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
|
||||
->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id')
|
||||
->join('releases_se as rse', 'rse.id', '=', 'r.id');
|
||||
}, 'r')
|
||||
->orderBy('r.'.$orderBy[0], $orderBy[1]);
|
||||
|
||||
@@ -659,7 +642,7 @@ class Releases
|
||||
return $releases;
|
||||
}
|
||||
|
||||
$releases = $sql->simplePaginate(config('nntmux.items_per_page'));
|
||||
$releases = $sql->paginate(config('nntmux.items_per_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
|
||||
Cache::put(md5($searchName.$usenetName.$posterName.$fileName.$groupName.$sizeFrom.$sizeTo.$hasNfo.$hasComments.$daysNew.$daysOld.implode('.', $orderBy).$maxAge.implode('.', $excludedCats).$type.implode('.', $cat).$minSize), $releases, $expiresAt);
|
||||
@@ -726,7 +709,20 @@ class Releases
|
||||
}
|
||||
|
||||
$query = Release::query()
|
||||
->select(
|
||||
->where('r.nzbstatus', NZB::NZB_ADDED);
|
||||
self::showPasswords($query, true);
|
||||
if ($show !== null) {
|
||||
if ((! empty($series) || ! empty($episode) || ! empty($airdate)) && \strlen((string) $show['episodes']) > 0) {
|
||||
$query->whereIn('r.tv_episodes_id', $show['episodes']);
|
||||
} elseif ((int) $show['video'] > 0) {
|
||||
$query->where('r.videos_id', $show['video']);
|
||||
// If $series is set but episode is not, return Season Packs only
|
||||
if (! empty($series) && empty($episode)) {
|
||||
$query->where('r.tv_epsiodes_id', '=', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
$query->select(
|
||||
[
|
||||
'r.*',
|
||||
'v.title',
|
||||
@@ -765,20 +761,8 @@ class Releases
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
|
||||
->leftJoin('groups as g', 'g.id', '=', 'r.groups_id')
|
||||
->leftJoin('video_data as re', 're.releases_id', '=', 'r.id')
|
||||
->leftJoin('release_nfos as rn', 'rn.releases_id', '=', 'r.id')
|
||||
->where('r.nzbstatus', NZB::NZB_ADDED);
|
||||
self::showPasswords($query, true);
|
||||
if ($show !== null) {
|
||||
if ((! empty($series) || ! empty($episode) || ! empty($airdate)) && \strlen((string) $show['episodes']) > 0) {
|
||||
$query->whereIn('r.tv_episodes_id', $show['episodes']);
|
||||
} elseif ((int) $show['video'] > 0) {
|
||||
$query->where('r.videos_id', $show['video']);
|
||||
// If $series is set but episode is not, return Season Packs only
|
||||
if (! empty($series) && empty($episode)) {
|
||||
$query->where('r.tv_epsiodes_id', '=', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
->leftJoin('release_nfos as rn', 'rn.releases_id', '=', 'r.id');
|
||||
|
||||
|
||||
if ($name !== '') {
|
||||
$this->releaseSearch->getSearchSQL(['searchname' => $name], $query, true);
|
||||
@@ -801,7 +785,7 @@ class Releases
|
||||
return $releases;
|
||||
}
|
||||
|
||||
$releases = $query->simplePaginate(config('nntmux.items_per_page'));
|
||||
$releases = $query->paginate(config('nntmux.items_per_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
|
||||
Cache::put(md5($page.implode('.', $siteIdArr).$series.$episode.$airdate.$limit.$name.implode('.', $cat).$maxAge.$minSize), $releases, $expiresAt);
|
||||
@@ -861,7 +845,7 @@ class Releases
|
||||
return $releases;
|
||||
}
|
||||
|
||||
$releases = $query->simplePaginate(config('nntmux.items_per_page'));
|
||||
$releases = $query->paginate(config('nntmux.items_per_page'));
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
|
||||
Cache::put(md5($aniDbID.$limit.$name.implode('.', $cat).$maxAge), $releases, $expiresAt);
|
||||
|
||||
@@ -924,7 +908,7 @@ class Releases
|
||||
return $releases;
|
||||
}
|
||||
|
||||
$releases = $query->simplePaginate(config('nntmux.items_per_page'));
|
||||
$releases = $query->paginate(config('nntmux.items_per_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium'));
|
||||
Cache::put(md5($imDbId.$limit.$name.implode('.', $cat).$maxAge.$minSize), $releases, $expiresAt);
|
||||
|
||||
+16
-15
@@ -122,7 +122,17 @@ class XXX
|
||||
$order = $this->getXXXOrder($orderBy);
|
||||
|
||||
$sql = Release::query()
|
||||
->select(
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('xxx.title', '!=', '');
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
$sql->select(
|
||||
[
|
||||
'xxx.*',
|
||||
DB::raw('UNCOMPRESS(xxx.plot) AS plot'),
|
||||
@@ -152,18 +162,7 @@ class XXX
|
||||
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
|
||||
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
|
||||
->join('xxxinfo as xxx', 'xxx.id', '=', 'r.xxxinfo_id')
|
||||
->where('r.nzbstatus', '=', 1)
|
||||
->where('xxx.title', '!=', '');
|
||||
Releases::showPasswords($sql, true);
|
||||
if (\count($excludedcats) > 0) {
|
||||
$sql->whereNotIn('r.categories_id', $excludedcats);
|
||||
}
|
||||
|
||||
if (\count($cat) > 0 && $cat[0] !== -1) {
|
||||
Category::getCategorySearch($cat, $sql, true);
|
||||
}
|
||||
|
||||
$sql->groupBy('xxx.id')
|
||||
->groupBy('xxx.id')
|
||||
->orderBy($order[0], $order[1]);
|
||||
|
||||
$return = Cache::get(md5($page.implode('.', $cat).implode('.', $excludedcats)));
|
||||
@@ -171,7 +170,7 @@ class XXX
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return = $sql->simplePaginate(config('nntmux.items_per_cover_page'));
|
||||
$return = $sql->paginate(config('nntmux.items_per_cover_page'));
|
||||
|
||||
$expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_long'));
|
||||
Cache::put(md5($page.implode('.', $cat).implode('.', $excludedcats)), $return, $expiresAt);
|
||||
@@ -563,7 +562,9 @@ class XXX
|
||||
|
||||
if ($this->echooutput) {
|
||||
ColorCLI::doEcho(
|
||||
ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: '.ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: '.ColorCLI::primary($mov['title']))), true);
|
||||
ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: '.ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: '.ColorCLI::primary($mov['title']))),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return $xxxID;
|
||||
|
||||
@@ -981,7 +981,7 @@ class Utility
|
||||
$range->selectRaw('UNCOMPRESS(plot) AS plot');
|
||||
}
|
||||
|
||||
return $range->orderByDesc('created_at')->simplePaginate(config('nntmux.items_per_page'));
|
||||
return $range->orderByDesc('created_at')->paginate(config('nntmux.items_per_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user