Update Release model getByGuid function

This commit is contained in:
DariusIII
2018-07-27 14:47:04 +02:00
parent 0d2cbe7703
commit 2701ac9600
2 changed files with 24 additions and 6 deletions
+1
View File
@@ -1,4 +1,5 @@
2018-07-27 DariusIII
* Chg: Update Release model getByGuid function
* Chg: Use now() helper in ProcessAdditional class
* Chg: Use human_filesize helper function in ProcessAdditional class
* Chg: Update phpunit.xml, move install test to front of testsuite block
+23 -6
View File
@@ -471,8 +471,26 @@ class Release extends Model
public static function getByGuid($guid)
{
$sql = self::query()
->remember(config('nntmux.cache_expiry_short'))
->select(['releases.*', 'g.name as group_name', 'v.title as showtitle', 'v.tvdb', 'v.trakt', 'v.tvrage', 'v.tvmaze', 'v.source', 'tvi.summary', 'tvi.image', 'tve.title', 'tve.firstaired', 'tve.se_complete', 'cp.title as parent_category', 'c.title as sub_category', DB::raw("CONCAT(cp.title, ' > ', c.title) AS category_name, CONCAT(cp.id, ',', c.id) AS category_ids,GROUP_CONCAT(g2.name ORDER BY g2.name ASC SEPARATOR ',') AS group_names")])
->select(
[
'releases.*',
'g.name as group_name',
'v.title as showtitle',
'v.tvdb',
'v.trakt',
'v.tvrage',
'v.tvmaze',
'v.source',
'tvi.summary',
'tvi.image',
'tve.title',
'tve.firstaired',
'tve.se_complete',
'cp.title as parent_category',
'c.title as sub_category',
DB::raw("CONCAT(cp.title, ' > ', c.title) AS category_name, CONCAT(cp.id, ',', c.id) AS category_ids,GROUP_CONCAT(g2.name ORDER BY g2.name ASC SEPARATOR ',') AS group_names")
]
)
->leftJoin('groups as g', 'g.id', '=', 'releases.groups_id')
->leftJoin('categories as c', 'c.id', '=', 'releases.categories_id')
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
@@ -489,12 +507,11 @@ class Release extends Model
}
$sql->whereIn('releases.guid', $tempGuids);
} else {
$sql->where('releases.guid', '=', $guid);
$sql->where('releases.guid', $guid);
}
$sql->groupBy('releases.id');
$result = \is_array($guid) ? $sql->groupBy('releases.id')->get() : $sql->groupBy('releases.id')->first();
return $result;
return \is_array($guid) ? $sql->get() : $sql->first();
}
/**