Rename groups table to usenet_groups as groups is a reserved word in mysql now

This commit is contained in:
DariusIII
2019-02-19 15:54:32 +01:00
parent d830b505f1
commit 40e7233727
45 changed files with 201 additions and 172 deletions
+6 -6
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Settings;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
@@ -108,9 +108,9 @@ class Backfill
public function backfillAllGroups($groupName = '', $articles = '', $type = ''): void
{
if ($groupName !== '') {
$grp[] = Group::getByName($groupName);
$grp[] = UsenetGroup::getByName($groupName);
} else {
$grp = Group::getActiveBackfill($type);
$grp = UsenetGroup::getActiveBackfill($type);
}
$groupCount = \count($grp);
@@ -231,7 +231,7 @@ class Backfill
', skipping it, consider disabling backfill on it.');
if ($this->_disableBackfillGroup) {
Group::updateGroupStatus($groupArr['id'], 'backfill', 0);
UsenetGroup::updateGroupStatus($groupArr['id'], 'backfill', 0);
}
if ($this->_echoCLI) {
@@ -296,7 +296,7 @@ class Backfill
DB::update(
sprintf(
'
UPDATE groups
UPDATE usenet_groups
SET first_record_postdate = FROM_UNIXTIME(%s), first_record = %s, last_updated = NOW()
WHERE id = %d',
$newdate,
@@ -334,7 +334,7 @@ class Backfill
*/
public function safeBackfill($articles = ''): void
{
$groupname = Group::query()
$groupname = UsenetGroup::query()
->whereBetween('first_record_postdate', [Carbon::createFromDate($this->_safeBackFillDate), now()])
->where('backfill', '=', 1)
->select(['name'])
+8 -8
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Settings;
use App\Models\Collection;
use Illuminate\Support\Str;
@@ -254,7 +254,7 @@ class Binaries
*/
public function updateAllGroups($maxHeaders = 100000): void
{
$groups = Group::getActive();
$groups = UsenetGroup::getActive();
$groupCount = \count($groups);
if ($groupCount > 0) {
@@ -322,7 +322,7 @@ class Binaries
$groupNNTP = $this->_nntp->dataError($this->_nntp, $groupMySQL['name']);
if (isset($groupNNTP['code']) && (int) $groupNNTP['code'] === 411) {
Group::disableIfNotExist($groupMySQL['id']);
UsenetGroup::disableIfNotExist($groupMySQL['id']);
}
if ($this->_nntp->isError($groupNNTP)) {
return;
@@ -348,7 +348,7 @@ class Binaries
// Generate postdate for first record, for those that upgraded.
if ($groupMySQL['first_record_postdate'] === null && (int) $groupMySQL['first_record'] !== 0) {
$groupMySQL['first_record_postdate'] = $this->postdate($groupMySQL['first_record'], $groupNNTP);
Group::query()->where('id', $groupMySQL['id'])->update(['first_record_postdate' => Carbon::createFromTimestamp($groupMySQL['first_record_postdate'])]);
UsenetGroup::query()->where('id', $groupMySQL['id'])->update(['first_record_postdate' => Carbon::createFromTimestamp($groupMySQL['first_record_postdate'])]);
}
// Get first article we want aka the oldest.
@@ -466,7 +466,7 @@ class Binaries
$groupMySQL['first_record_postdate'] = $this->postdate($groupMySQL['first_record'], $groupNNTP);
}
Group::query()
UsenetGroup::query()
->where('id', $groupMySQL['id'])
->update(
[
@@ -483,7 +483,7 @@ class Binaries
$scanSummary['lastArticleDate'] = $this->postdate($scanSummary['lastArticleNumber'], $groupNNTP);
}
Group::query()
UsenetGroup::query()
->where('id', $groupMySQL['id'])
->update(
[
@@ -494,7 +494,7 @@ class Binaries
);
} else {
// If we didn't fetch headers, update the record still.
Group::query()
UsenetGroup::query()
->where('id', $groupMySQL['id'])
->update(
[
@@ -1480,7 +1480,7 @@ class Binaries
bb.groupname AS groupname, bb.regex, g.id AS group_id, bb.msgcol,
bb.last_activity as last_activity
FROM binaryblacklist bb
LEFT OUTER JOIN groups g ON g.name %s bb.groupname
LEFT OUTER JOIN usenet_groups g ON g.name %s bb.groupname
WHERE 1=1 %s %s %s
ORDER BY coalesce(groupname,\'zzz\')',
($groupRegex ? 'REGEXP' : '='),
+1 -1
View File
@@ -206,7 +206,7 @@ class Books
g.name AS group_name,
rn.releases_id AS nfoid
FROM releases r
LEFT OUTER JOIN groups g ON g.id = r.groups_id
LEFT OUTER JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
INNER JOIN bookinfo boo ON boo.id = r.bookinfo_id
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Category;
use App\Models\Settings;
@@ -123,7 +123,7 @@ class Categorize
private function groupName(): string
{
if (! isset($this->ugroups[$this->groupid])) {
$group = Group::query()->where('id', $this->groupid)->first(['name']);
$group = UsenetGroup::query()->where('id', $this->groupid)->first(['name']);
$this->ugroups[$this->groupid] = ($group === null ? false : $group['name']);
}
+1 -1
View File
@@ -217,7 +217,7 @@ class Console
genres.title AS genre,
rn.releases_id AS nfoid
FROM releases r
LEFT OUTER JOIN groups g ON g.id = r.groups_id
LEFT OUTER JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
INNER JOIN consoleinfo con ON con.id = r.consoleinfo_id
+1 -1
View File
@@ -288,7 +288,7 @@ class Games
gi.*, YEAR (gi.releasedate) as year, r.gamesinfo_id,
rn.releases_id AS nfoid
FROM releases r
LEFT OUTER JOIN groups g ON g.id = r.groups_id
LEFT OUTER JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
INNER JOIN gamesinfo gi ON gi.id = r.gamesinfo_id
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Predb;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
@@ -456,7 +456,7 @@ class IRCScraper extends IRCClient
protected function _getGroupID($groupName)
{
if (! isset($this->_groupList[$groupName])) {
$group = Group::query()->where('name', $groupName)->first(['id']);
$group = UsenetGroup::query()->where('name', $groupName)->first(['id']);
$this->_groupList[$groupName] = $group !== null ? $group['id'] : '';
}
+1 -1
View File
@@ -303,7 +303,7 @@ class Movie
g.name AS group_name,
rn.releases_id AS nfoid
FROM releases r
LEFT OUTER JOIN groups g ON g.id = r.groups_id
LEFT OUTER JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
LEFT OUTER JOIN categories c ON c.id = r.categories_id
+1 -1
View File
@@ -205,7 +205,7 @@ class Music
g.name AS group_name,
rn.releases_id AS nfoid
FROM releases r
LEFT OUTER JOIN groups g ON g.id = r.groups_id
LEFT OUTER JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
INNER JOIN musicinfo m ON m.id = r.musicinfo_id
+1 -1
View File
@@ -132,7 +132,7 @@ class NZB
SELECT c.*, UNIX_TIMESTAMP(c.date) AS udate,
g.name AS groupname
FROM collections c
INNER JOIN groups g ON c.groups_id = g.id
INNER JOIN usenet_groups g ON c.groups_id = g.id
WHERE c.releases_id = ';
$this->_binariesQuery = '
SELECT b.id, b.name, b.totalparts
+3 -3
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use Blacklight\utility\Utility;
use Illuminate\Support\Facades\File;
@@ -117,14 +117,14 @@ class NZBExport
return $this->returnValue();
}
$groups = Group::query()->where('id', $params['3'])->select(['id', 'name'])->get();
$groups = UsenetGroup::query()->where('id', $params['3'])->select(['id', 'name'])->get();
if ($groups === null) {
$this->echoOut('The group ID is not in the DB: '.$params[3]);
return $this->returnValue();
}
} else {
$groups = Group::query()->select(['id', 'name'])->get();
$groups = UsenetGroup::query()->select(['id', 'name'])->get();
}
$exported = 0;
+4 -4
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Release;
use App\Models\Settings;
use Blacklight\utility\Utility;
@@ -280,9 +280,9 @@ class NZBImport
$groupName = $group;
}
} else {
$group = Group::isValidGroup($group);
$group = UsenetGroup::isValidGroup($group);
if ($group !== false) {
$groupID = Group::addGroup([
$groupID = UsenetGroup::addGroup([
'name' => $group,
'description' => 'Added by NZBimport script.',
'backfill_target' => 1,
@@ -440,7 +440,7 @@ class NZBImport
protected function getAllGroups(): bool
{
$this->allGroups = [];
$groups = Group::query()->get(['id', 'name']);
$groups = UsenetGroup::query()->get(['id', 'name']);
if ($groups instanceof \Traversable) {
foreach ($groups as $group) {
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Predb;
use App\Models\Release;
use App\Models\Category;
@@ -934,7 +934,7 @@ class NameFixer
$newName = preg_replace(['/^[-=_\.:\s]+/', '/[-=_\.:\s]+$/'], '', $newName[0]);
if ($this->echooutput && $show) {
$groupName = Group::getNameByID($release->groups_id);
$groupName = UsenetGroup::getNameByID($release->groups_id);
$oldCatName = Category::getNameByID($release->categories_id);
$newCatName = Category::getNameByID($determinedCategory['categories_id']);
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Release;
use App\Models\Settings;
use App\Models\ReleaseNfo;
@@ -330,7 +330,7 @@ class Nfo
$movie = new Movie(['Echo' => $this->echo]);
foreach ($res as $arr) {
$fetchedBinary = $nzbContents->getNfoFromNZB($arr['guid'], $arr['id'], $arr['groups_id'], Group::getNameByID($arr['groups_id']));
$fetchedBinary = $nzbContents->getNfoFromNZB($arr['guid'], $arr['id'], $arr['groups_id'], UsenetGroup::getNameByID($arr['groups_id']));
if ($fetchedBinary !== false) {
// Insert nfo into database.
+3 -3
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Release;
use App\Models\Category;
use Illuminate\Support\Arr;
@@ -185,7 +185,7 @@ class Regexes
*/
public function testCollectionRegex($groupName, $regex, $limit): array
{
$groupID = Group::getIDByName($groupName);
$groupID = UsenetGroup::getIDByName($groupName);
if (! $groupID) {
return [];
@@ -251,7 +251,7 @@ class Regexes
*/
public function testReleaseNamingRegex($groupName, $regex, $displayLimit, $queryLimit): array
{
$groupID = Group::getIDByName($groupName);
$groupID = UsenetGroup::getIDByName($groupName);
if (! $groupID) {
return [];
+2 -2
View File
@@ -132,7 +132,7 @@ class ReleaseCleaning
preg_match('/^(\d{4,6})-\d{1}\[/', $subject, $match) ||
preg_match('/(\d{4,6}) -/', $subject, $match)
) {
$title = Predb::query()->where(['predb.requestid'=> $match[1], 'g.name' => $groupName])->join('groups as g', 'g.id', '=', 'predb.groups_id')->first(['predb.title', 'predb.id']);
$title = Predb::query()->where(['predb.requestid'=> $match[1], 'g.name' => $groupName])->join('usenet_groups as g', 'g.id', '=', 'predb.groups_id')->first(['predb.title', 'predb.id']);
//check for predb title matches against other groups where it matches relative size / fromname
//known crossposted requests only atm
$reqGname = '';
@@ -156,7 +156,7 @@ class ReleaseCleaning
break;
}
if ($title === null && ! empty($reqGname)) {
$title = Predb::query()->where(['predb.requestid'=> $match[1], 'g.name' => $reqGname])->join('groups as g', 'g.id', '=', 'predb.groups_id')->first(['predb.title', 'predb.id']);
$title = Predb::query()->where(['predb.requestid'=> $match[1], 'g.name' => $reqGname])->join('usenet_groups as g', 'g.id', '=', 'predb.groups_id')->first(['predb.title', 'predb.id']);
}
// don't match against ab.teevee if title is for just the season
if ($groupName === 'alt.binaries.teevee' && preg_match('/\.S\d\d\./', $title['title'], $match)) {
+4 -4
View File
@@ -765,7 +765,7 @@ class ReleaseRemover
$groupID = '';
if (strtolower($regex->groupname) !== 'alt.binaries.*') {
$groupIDs = DB::select(
'SELECT id FROM groups WHERE name REGEXP '.
'SELECT id FROM usenet_groups WHERE name REGEXP '.
escapeString($regex->groupname)
);
@@ -875,7 +875,7 @@ class ReleaseRemover
$groupID = '';
if (strtolower($regex->groupname) !== 'alt.binaries.*') {
$groupIDs = DB::select(
'SELECT id FROM groups WHERE name REGEXP '.
'SELECT id FROM usenet_groups WHERE name REGEXP '.
escapeString($regex->groupname)
);
$groupIDCount = \count($groupIDs);
@@ -1138,7 +1138,7 @@ class ReleaseRemover
case 'groupname':
switch ($args[1]) {
case 'equals':
$group = DB::select('SELECT id FROM groups WHERE name = '.escapeString($args[2]));
$group = DB::select('SELECT id FROM usenet_groups WHERE name = '.escapeString($args[2]));
if (empty($group)) {
$this->error = 'This group was not found in your database: '.$args[2].PHP_EOL;
break;
@@ -1146,7 +1146,7 @@ class ReleaseRemover
return ' AND groups_id = '.$group[0]->id;
case 'like':
$groups = DB::select('SELECT id FROM groups WHERE name '.$this->formatLike($args[2], 'name'));
$groups = DB::select('SELECT id FROM usenet_groups WHERE name '.$this->formatLike($args[2], 'name'));
if (\count($groups) === 0) {
$this->error = 'No groups were found with this pattern in your database: '.$args[2].PHP_EOL;
break;
+15 -15
View File
@@ -2,7 +2,7 @@
namespace Blacklight;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Release;
use App\Models\Category;
use App\Models\Settings;
@@ -83,7 +83,7 @@ class Releases
(
SELECT r.*, g.name AS group_name
FROM releases r
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
%s
WHERE r.nzbstatus = %d
AND r.passwordstatus %s
@@ -150,7 +150,7 @@ class Releases
AND r.passwordstatus %s
%s
%s %s %s %s ',
($groupName !== -1 ? 'LEFT JOIN groups g ON g.id = r.groups_id' : ''),
($groupName !== -1 ? 'LEFT JOIN usenet_groups g ON g.id = r.groups_id' : ''),
! empty($tags) ? ' LEFT JOIN tagging_tagged tt ON tt.taggable_id = r.id' : '',
NZB::NZB_ADDED,
$this->showPasswords(),
@@ -269,7 +269,7 @@ class Releases
->from('releases as r')
->leftJoin('categories as c', 'c.id', '=', 'r.categories_id')
->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid')
->leftJoin('groups as g', 'g.id', '=', 'r.groups_id');
->leftJoin('usenet_groups as g', 'g.id', '=', 'r.groups_id');
if ($groupID !== '') {
$query->where('r.groups_id', $groupID);
@@ -330,7 +330,7 @@ class Releases
{
$groups = Release::query()
->selectRaw('DISTINCT g.id, g.name')
->leftJoin('groups as g', 'g.id', '=', 'releases.groups_id')
->leftJoin('usenet_groups as g', 'g.id', '=', 'releases.groups_id')
->get();
$temp_array = [];
@@ -393,13 +393,13 @@ class Releases
"SELECT r.*,
CONCAT(cp.title, '-', c.title) AS category_name,
%s AS category_ids,
groups.name AS group_name,
usenet_groups.name AS group_name,
rn.releases_id AS nfoid, re.releases_id AS reid,
tve.firstaired,
df.failed AS failed
FROM releases r
LEFT OUTER JOIN video_data re ON re.releases_id = r.id
LEFT JOIN groups ON groups.id = r.groups_id
LEFT JOIN usenet_groups ON usenet_groups.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN tv_episodes tve ON tve.videos_id = r.videos_id
LEFT JOIN categories c ON c.id = r.categories_id
@@ -635,7 +635,7 @@ class Releases
NZB::NZB_ADDED,
! empty($tags) ? " AND tt.tag_name IN ('".implode("','", $tags)."')" : '',
($maxAge > 0 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $maxAge) : ''),
((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', Group::getIDByName($groupName)) : ''),
((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', UsenetGroup::getIDByName($groupName)) : ''),
(array_key_exists($sizeFrom, $sizeRange) ? ' AND r.size > '.(104857600 * (int) $sizeRange[$sizeFrom]).' ' : ''),
(array_key_exists($sizeTo, $sizeRange) ? ' AND r.size < '.(104857600 * (int) $sizeRange[$sizeTo]).' ' : ''),
$catQuery,
@@ -661,7 +661,7 @@ class Releases
LEFT OUTER JOIN videos v ON r.videos_id = v.id
LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT JOIN categories c ON c.id = r.categories_id
LEFT JOIN categories cp ON cp.id = c.parentid
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
@@ -726,7 +726,7 @@ class Releases
NZB::NZB_ADDED,
! empty($tags) ? " AND tt.tag_name IN ('".implode("','", $tags)."')" : '',
($maxAge > 0 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $maxAge) : ''),
((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', Group::getIDByName($groupName)) : ''),
((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', UsenetGroup::getIDByName($groupName)) : ''),
$catQuery,
(\count($excludedCats) > 0 ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
(! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
@@ -744,7 +744,7 @@ class Releases
LEFT OUTER JOIN videos v ON r.videos_id = v.id
LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id
LEFT JOIN movieinfo m ON m.id = r.movieinfo_id
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT JOIN categories c ON c.id = r.categories_id
LEFT JOIN categories cp ON cp.id = c.parentid
%s %s",
@@ -895,7 +895,7 @@ class Releases
LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id
LEFT JOIN categories c ON c.id = r.categories_id
LEFT JOIN categories cp ON cp.id = c.parentid
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN video_data re ON re.releases_id = r.id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
%s %s",
@@ -1036,7 +1036,7 @@ class Releases
LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id
LEFT JOIN categories c ON c.id = r.categories_id
LEFT JOIN categories cp ON cp.id = c.parentid
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
%s %s",
$this->getConcatenatedCategoryIDs(),
! empty($tags) ? ' LEFT JOIN tagging_tagged tt ON tt.taggable_id = r.id' : '',
@@ -1108,7 +1108,7 @@ class Releases
FROM releases r
LEFT JOIN categories c ON c.id = r.categories_id
LEFT JOIN categories cp ON cp.id = c.parentid
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN releaseextrafull re ON re.releases_id = r.id
%s",
@@ -1185,7 +1185,7 @@ class Releases
rn.releases_id AS nfoid
FROM releases r
LEFT JOIN movieinfo m ON m.id = r.movieinfo_id
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT JOIN categories c ON c.id = r.categories_id
LEFT JOIN categories cp ON cp.id = c.parentid
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
+4 -4
View File
@@ -454,8 +454,8 @@ class Tmux
{$ppmaxString}
AND c.disablepreview = 0
) AS work,
(SELECT COUNT(id) FROM groups WHERE active = 1) AS active_groups,
(SELECT COUNT(id) FROM groups WHERE name IS NOT NULL) AS all_groups";
(SELECT COUNT(id) FROM usenet_groups WHERE active = 1) AS active_groups,
(SELECT COUNT(id) FROM usenet_groups WHERE name IS NOT NULL) AS all_groups";
case 4:
return sprintf(
@@ -467,10 +467,10 @@ class Tmux
(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'binaries' AND TABLE_SCHEMA = %1\$s) AS binaries_table,
(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'collections' AND TABLE_SCHEMA = %1\$s) AS collections_table,
(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'releases' AND TABLE_SCHEMA = %1\$s) AS releases,
(SELECT COUNT(id) FROM groups WHERE first_record IS NOT NULL AND backfill = 1
(SELECT COUNT(id) FROM usenet_groups WHERE first_record IS NOT NULL AND backfill = 1
AND (now() - INTERVAL backfill_target DAY) < first_record_postdate
) AS backfill_groups_days,
(SELECT COUNT(id) FROM groups WHERE first_record IS NOT NULL AND backfill = 1 AND (now() - INTERVAL datediff(curdate(),
(SELECT COUNT(id) FROM usenet_groups WHERE first_record IS NOT NULL AND backfill = 1 AND (now() - INTERVAL datediff(curdate(),
(SELECT VALUE FROM settings WHERE setting = 'safebackfilldate')) DAY) < first_record_postdate) AS backfill_groups_date",
escapeString($db_name)
);
+1 -1
View File
@@ -188,7 +188,7 @@ class XXX
g.name AS group_name,
rn.releases_id AS nfoid
FROM releases r
LEFT OUTER JOIN groups g ON g.id = r.groups_id
LEFT OUTER JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id
LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id
LEFT OUTER JOIN categories c ON c.id = r.categories_id
+4 -4
View File
@@ -119,7 +119,7 @@ class PreDb
$sql = <<<SQL_EXPORT
SELECT title, nfo, size, files, filename, nuked, nukereason, category, predate, source, requestid, g.name
FROM {$this->tableMain} p LEFT OUTER JOIN groups g ON p.groups_id = g.id {$limit}
FROM {$this->tableMain} p LEFT OUTER JOIN usenet_groups g ON p.groups_id = g.id {$limit}
INTO OUTFILE '{$options['path']}'
FIELDS TERMINATED BY '{$options['fields']}' {$enclosedby}
LINES TERMINATED BY '{$options['lines']}';
@@ -268,9 +268,9 @@ SQL_EXPORT;
protected function prepareSQLAddGroups(): void
{
$sql = <<<'SQL_ADD_GROUPS'
INSERT IGNORE INTO groups (name, description)
INSERT IGNORE INTO usenet_groups (name, description)
SELECT groupname, 'Added by predb import script'
FROM predb_imports AS pi LEFT JOIN groups AS g ON pi.groupname = g.name
FROM predb_imports AS pi LEFT JOIN usenet_groups AS g ON pi.groupname = g.name
WHERE pi.groupname IS NOT NULL AND g.name IS NULL
GROUP BY groupname;
SQL_ADD_GROUPS;
@@ -341,7 +341,7 @@ SQL_LOAD_DATA;
protected function prepareSQLUpdateGroupIDs(): void
{
$sql = 'UPDATE predb_imports AS pi SET groups_id = (SELECT id FROM groups WHERE name = pi.groupname) WHERE groupname IS NOT NULL';
$sql = 'UPDATE predb_imports AS pi SET groups_id = (SELECT id FROM usenet_groups WHERE name = pi.groupname) WHERE groupname IS NOT NULL';
$this->prepareSQLStatement($sql, 'UpdateGroupID');
}
}
+2 -2
View File
@@ -21,7 +21,7 @@
namespace Blacklight\http;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Category;
use App\Models\AudioData;
use Blacklight\utility\Utility;
@@ -121,7 +121,7 @@ class API extends Capabilities
{
$groupName = -1;
if (request()->has('group')) {
$group = Group::isValidGroup(request()->input('group'));
$group = UsenetGroup::isValidGroup(request()->input('group'));
if ($group !== false) {
$groupName = $group;
}
+3 -3
View File
@@ -85,7 +85,7 @@ class RSS extends Capabilities
FROM releases r
LEFT JOIN categories c ON c.id = r.categories_id
INNER JOIN categories cp ON cp.id = c.parentid
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN musicinfo mu ON mu.id = r.musicinfo_id
LEFT OUTER JOIN genres mug ON mug.id = mu.genres_id
LEFT OUTER JOIN consoleinfo co ON co.id = r.consoleinfo_id
@@ -140,7 +140,7 @@ class RSS extends Capabilities
FROM releases r
LEFT JOIN categories c ON c.id = r.categories_id
INNER JOIN categories cp ON cp.id = c.parentid
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT OUTER JOIN videos v ON v.id = r.videos_id
LEFT OUTER JOIN tv_episodes tve ON tve.id = r.tv_episodes_id
WHERE %s %s %s
@@ -204,7 +204,7 @@ class RSS extends Capabilities
FROM releases r
LEFT JOIN categories c ON c.id = r.categories_id
INNER JOIN categories cp ON cp.id = c.parentid
LEFT JOIN groups g ON g.id = r.groups_id
LEFT JOIN usenet_groups g ON g.id = r.groups_id
LEFT JOIN movieinfo mi ON mi.id = r.movieinfo_id
WHERE %s %s
AND r.nzbstatus = %d
+6 -6
View File
@@ -354,7 +354,7 @@ class Forking extends \fork_daemon
// The option for backFill is for doing up to x articles. Else it's done by date.
$this->work = DB::select(
sprintf(
'SELECT name %s FROM groups WHERE backfill = 1',
'SELECT name %s FROM usenet_groups WHERE backfill = 1',
($this->workTypeOptions[0] === false ? '' : (', '.$this->workTypeOptions[0].' AS max'))
)
);
@@ -425,7 +425,7 @@ class Forking extends \fork_daemon
g.first_record AS our_first,
MAX(a.first_record) AS their_first,
MAX(a.last_record) AS their_last
FROM groups g
FROM usenet_groups g
INNER JOIN short_groups a ON g.name = a.name
WHERE g.first_record IS NOT NULL
AND g.first_record_postdate IS NOT NULL
@@ -487,7 +487,7 @@ class Forking extends \fork_daemon
$this->register_child_run([0 => $this, 1 => 'binariesChildWorker']);
$this->work = DB::select(
sprintf(
'SELECT name, %d AS max FROM groups WHERE active = 1',
'SELECT name, %d AS max FROM usenet_groups WHERE active = 1',
$this->workTypeOptions[0]
)
);
@@ -524,7 +524,7 @@ class Forking extends \fork_daemon
'
SELECT g.name AS groupname, g.last_record AS our_last,
a.last_record AS their_last
FROM groups g
FROM usenet_groups g
INNER JOIN short_groups a ON g.active = 1 AND g.name = a.name
ORDER BY a.last_record DESC'
);
@@ -658,7 +658,7 @@ class Forking extends \fork_daemon
{
$this->register_child_run([0 => $this, 1 => 'releasesChildWorker']);
$groups = DB::select('SELECT id FROM groups WHERE (active = 1 OR backfill = 1)');
$groups = DB::select('SELECT id FROM usenet_groups WHERE (active = 1 OR backfill = 1)');
foreach ($groups as $group) {
try {
@@ -994,7 +994,7 @@ class Forking extends \fork_daemon
private function updatePerGroupMainMethod()
{
$this->register_child_run([0 => $this, 1 => 'updatePerGroupChildWorker']);
$this->work = DB::select('SELECT id FROM groups WHERE (active = 1 OR backfill = 1)');
$this->work = DB::select('SELECT id FROM usenet_groups WHERE (active = 1 OR backfill = 1)');
return (int) Settings::settingValue('..releasethreads');
}
+2 -2
View File
@@ -5,7 +5,7 @@ namespace Blacklight\processing;
use Blacklight\Nfo;
use Blacklight\XXX;
use Blacklight\NNTP;
use App\Models\Group;
use App\Models\UsenetGroup;
use Blacklight\Books;
use Blacklight\Games;
use Blacklight\Movie;
@@ -312,7 +312,7 @@ class PostProcess
}
// Get the PAR2 file.
$par2 = $nntp->getMessages(Group::getNameByID($groupID), $messageID, $this->alternateNNTP);
$par2 = $nntp->getMessages(UsenetGroup::getNameByID($groupID), $messageID, $this->alternateNNTP);
if ($nntp->isError($par2)) {
return false;
}
+11 -11
View File
@@ -4,7 +4,7 @@ namespace Blacklight\processing;
use Blacklight\NZB;
use Blacklight\NNTP;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Predb;
use Blacklight\Genres;
use App\Models\Release;
@@ -164,7 +164,7 @@ class ProcessReleases
$groupID = '';
if (! empty($groupName) && $groupName !== 'mgr') {
$groupInfo = Group::getByName($groupName);
$groupInfo = UsenetGroup::getByName($groupName);
if ($groupInfo !== null) {
$groupID = $groupInfo['id'];
}
@@ -377,7 +377,7 @@ class ProcessReleases
$this->colorCli->header('Process Releases -> Delete collections smaller/larger than minimum size/file count from group/site setting.');
}
$groupID === '' ? $groupIDs = Group::getActiveIDs() : $groupIDs = [['id' => $groupID]];
$groupID === '' ? $groupIDs = UsenetGroup::getActiveIDs() : $groupIDs = [['id' => $groupID]];
$minSizeDeleted = $maxSizeDeleted = $minFilesDeleted = 0;
@@ -388,7 +388,7 @@ class ProcessReleases
foreach ($groupIDs as $grpID) {
$groupMinSizeSetting = $groupMinFilesSetting = 0;
$groupMinimums = Group::getGroupByID($grpID['id']);
$groupMinimums = UsenetGroup::getGroupByID($grpID['id']);
if ($groupMinimums !== null) {
if (! empty($groupMinimums['minsizetoformrelease']) && $groupMinimums['minsizetoformrelease'] > 0) {
$groupMinSizeSetting = (int) $groupMinimums['minsizetoformrelease'];
@@ -480,7 +480,7 @@ class ProcessReleases
'
SELECT SQL_NO_CACHE c.*, g.name AS gname
FROM collections c
INNER JOIN groups g ON c.groups_id = g.id
INNER JOIN usenet_groups g ON c.groups_id = g.id
WHERE %s c.filecheck = %d
AND c.filesize > 0
LIMIT %d',
@@ -584,12 +584,12 @@ class ProcessReleases
if (preg_match_all('#(\S+):\S+#', $collection->xref, $matches)) {
foreach ($matches[1] as $grp) {
//check if the group name is in a valid format
$grpTmp = Group::isValidGroup($grp);
$grpTmp = UsenetGroup::isValidGroup($grp);
if ($grpTmp !== false) {
//check if the group already exists in database
$xrefGrpID = Group::getIDByName($grpTmp);
$xrefGrpID = UsenetGroup::getIDByName($grpTmp);
if ($xrefGrpID === '') {
$xrefGrpID = Group::addGroup(
$xrefGrpID = UsenetGroup::addGroup(
[
'name' => $grpTmp,
'description' => 'Added by Release processing',
@@ -1008,7 +1008,7 @@ class ProcessReleases
$this->colorCli->header('Process Releases -> Delete releases smaller/larger than minimum size/file count from group/site setting.');
}
$groupID === '' ? $groupIDs = Group::getActiveIDs() : $groupIDs = [['id' => $groupID]];
$groupID === '' ? $groupIDs = UsenetGroup::getActiveIDs() : $groupIDs = [['id' => $groupID]];
$maxSizeSetting = Settings::settingValue('.release.maxsizetoformrelease');
$minSizeSetting = Settings::settingValue('.release.minsizetoformrelease');
@@ -1020,7 +1020,7 @@ class ProcessReleases
'
SELECT SQL_NO_CACHE r.guid, r.id
FROM releases r
INNER JOIN groups g ON g.id = r.groups_id
INNER JOIN usenet_groups g ON g.id = r.groups_id
WHERE r.groups_id = %d
AND greatest(IFNULL(g.minsizetoformrelease, 0), %d) > 0
AND r.size < greatest(IFNULL(g.minsizetoformrelease, 0), %d)',
@@ -1057,7 +1057,7 @@ class ProcessReleases
'
SELECT SQL_NO_CACHE r.id, r.guid
FROM releases r
INNER JOIN groups g ON g.id = r.groups_id
INNER JOIN usenet_groups g ON g.id = r.groups_id
WHERE r.groups_id = %d
AND greatest(IFNULL(g.minfilestoformrelease, 0), %d) > 0
AND r.totalpart < greatest(IFNULL(g.minfilestoformrelease, 0), %d)',
@@ -7,7 +7,7 @@ use Blacklight\Nfo;
use Blacklight\NZB;
use FFMpeg\FFProbe;
use Blacklight\NNTP;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Release;
use App\Models\Category;
use App\Models\Settings;
@@ -2309,7 +2309,7 @@ class ProcessAdditional
$this->_passwordStatus = [Releases::PASSWD_NONE];
$this->_releaseHasPassword = false;
$this->_releaseGroupName = Group::getNameByID($this->_release->groups_id);
$this->_releaseGroupName = UsenetGroup::getNameByID($this->_release->groups_id);
$this->_releaseHasNoNFO = false;
// Make sure we don't already have an nfo.
+1
View File
@@ -1,4 +1,5 @@
2019-02-19 DariusIII
* Chg: Rename groups table to usenet_groups as groups is a reserved word in mysql now
* Chg: Move role expiration and verification checks into separate script and schedule them in Kernel.php
* CHg: Update archive handling regexes
* Chg: Update friendsofphp/php-cs-fixer (v2.14.1 => v2.14.2)
+2 -2
View File
@@ -16,7 +16,7 @@ class FixturesDown extends Command
'category_regexes',
'collection_regexes',
'content',
'groups',
'usenet_groups',
'menu',
'release_naming_regexes',
'settings',
@@ -42,7 +42,7 @@ class FixturesDown extends Command
category_regexes
collection_regexes
content
groups
usenet_groups
release_naming_regexes
settings
tmux';
+2 -2
View File
@@ -16,7 +16,7 @@ class FixturesUp extends Command
'category_regexes',
'collection_regexes',
'content',
'groups',
'usenet_groups',
'release_naming_regexes',
'settings',
'tmux',
@@ -41,7 +41,7 @@ class FixturesUp extends Command
category_regexes
collection_regexes
content
groups
usenet_groups
release_naming_regexes
settings
tmux';
+2 -2
View File
@@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Settings;
use Blacklight\SphinxSearch;
use Illuminate\Console\Command;
@@ -45,7 +45,7 @@ class NntmuxResetDb extends Command
DB::statement('SET FOREIGN_KEY_CHECKS = 0;');
Group::query()->update([
UsenetGroup::query()->update([
'first_record' => 0,
'first_record_postdate' => null,
'last_record' => 0,
+2 -2
View File
@@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Release;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -39,7 +39,7 @@ class NntmuxResetTruncate extends Command
*/
public function handle()
{
Group::query()->update(['first_record' => 0, 'first_record_postdate' => null, 'last_record' => 0, 'last_record_postdate' => null, 'last_updated' => null]);
UsenetGroup::query()->update(['first_record' => 0, 'first_record_postdate' => null, 'last_record' => 0, 'last_record_postdate' => null, 'last_updated' => null]);
$this->info('Reseting all groups completed.');
DB::statement('SET FOREIGN_KEY_CHECKS = 0;');
@@ -2,7 +2,7 @@
namespace App\Http\Controllers\Admin;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Sharing;
use Blacklight\Regexes;
use Blacklight\Binaries;
@@ -51,39 +51,39 @@ class AjaxController extends BasePageController
break;
case 'group_edit_purge_all':
Group::purge();
UsenetGroup::purge();
echo 'All groups purged.';
break;
case 'group_edit_reset_all':
Group::resetall();
UsenetGroup::resetall();
echo 'All groups reset.';
break;
case 'group_edit_purge_single':
$id = (int) $request->input('group_id');
Group::purge($id);
UsenetGroup::purge($id);
echo "Group $id purged.";
break;
case 'group_edit_reset_single':
$id = (int) $request->input('group_id');
Group::reset($id);
UsenetGroup::reset($id);
echo "Group $id reset.";
break;
case 'group_edit_delete_single':
$id = (int) $request->input('group_id');
Group::deleteGroup($id);
UsenetGroup::deleteGroup($id);
echo "Group $id deleted.";
break;
case 'toggle_group_active_status':
print Group::updateGroupStatus((int) $request->input('group_id'), 'active', ($request->has('group_status') ? (int) $request->input('group_status') : 0));
print UsenetGroup::updateGroupStatus((int) $request->input('group_id'), 'active', ($request->has('group_status') ? (int) $request->input('group_status') : 0));
break;
case 'toggle_group_backfill_status':
print Group::updateGroupStatus(
print UsenetGroup::updateGroupStatus(
(int) $request->input('group_id'),
'backfill',
($request->has('backfill_status') ? (int) $request->input('backfill_status') : 0)
@@ -2,7 +2,7 @@
namespace App\Http\Controllers\Admin;
use App\Models\Group;
use App\Models\UsenetGroup;
use Illuminate\Http\Request;
use App\Http\Controllers\BasePageController;
@@ -22,7 +22,7 @@ class GroupController extends BasePageController
$this->smarty->assign(
[
'groupname' => $groupName,
'grouplist' => Group::getGroupsRange($groupName),
'grouplist' => UsenetGroup::getGroupsRange($groupName),
]
);
@@ -48,7 +48,7 @@ class GroupController extends BasePageController
if ($action === 'submit') {
if ($request->has('groupfilter') && ! empty($request->input('groupfilter'))) {
$msgs = Group::addBulk($request->input('groupfilter'), $request->input('active'), $request->input('backfill'));
$msgs = UsenetGroup::addBulk($request->input('groupfilter'), $request->input('active'), $request->input('backfill'));
}
} else {
$msgs = '';
@@ -96,13 +96,13 @@ class GroupController extends BasePageController
case 'submit':
if (empty($request->input('id'))) {
// Add a new group.
$request->merge(['name' => Group::isValidGroup($request->input('name'))]);
$request->merge(['name' => UsenetGroup::isValidGroup($request->input('name'))]);
if ($request->input('name') !== false) {
Group::addGroup($request->all());
UsenetGroup::addGroup($request->all());
}
} else {
// Update an existing group.
Group::updateGroup($request->all());
UsenetGroup::updateGroup($request->all());
}
return redirect('admin/group-list');
@@ -114,7 +114,7 @@ class GroupController extends BasePageController
if ($request->has('id')) {
$meta_title = $title = 'Newsgroup Edit';
$id = $request->input('id');
$group = Group::getGroupByID($id);
$group = UsenetGroup::getGroupByID($id);
} else {
$meta_title = $title = 'Newsgroup Add';
}
@@ -150,7 +150,7 @@ class GroupController extends BasePageController
$this->smarty->assign('groupname', $groupname);
$grouplist = Group::getGroupsRange($gname, true);
$grouplist = UsenetGroup::getGroupsRange($gname, true);
$this->smarty->assign('grouplist', $grouplist);
@@ -180,7 +180,7 @@ class GroupController extends BasePageController
$this->smarty->assign('groupname', $groupname);
$grouplist = Group::getGroupsRange($gname, false);
$grouplist = UsenetGroup::getGroupsRange($gname, false);
$this->smarty->assign('grouplist', $grouplist);
@@ -2,7 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Group;
use App\Models\UsenetGroup;
class BrowseGroupController extends BasePageController
{
@@ -12,7 +12,7 @@ class BrowseGroupController extends BasePageController
public function show()
{
$this->setPrefs();
$groupList = Group::getGroupsRange('', true);
$groupList = UsenetGroup::getGroupsRange('', true);
$this->smarty->assign('results', $groupList);
$meta_title = 'Browse Groups';
+2 -2
View File
@@ -2,7 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Category;
use Blacklight\Releases;
use Illuminate\Http\Request;
@@ -179,7 +179,7 @@ class SearchController extends BasePageController
],
'results' => $results,
'sadvanced' => $searchType !== 'basic',
'grouplist' => Group::getGroupsForSelect(),
'grouplist' => UsenetGroup::getGroupsForSelect(),
'catlist' => Category::getForSelect(),
]
);
+16 -16
View File
@@ -63,19 +63,19 @@ use Illuminate\Database\Eloquent\Model;
* @property bool $proc_hash16k Has the release been hash16k
* processed
* @property mixed|null $nzb_guid
* @property-read \App\Models\Category $category
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleaseComment[] $comment
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserDownload[] $download
* @property-read \App\Models\TvEpisode $episode
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\DnzbFailure[] $failed
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleaseFile[] $file
* @property-read \App\Models\Group $group
* @property-read \App\Models\ReleaseNfo $nfo
* @property-read \App\Models\Predb $predb
* @property-read \App\Models\Category $category
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleaseComment[] $comment
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserDownload[] $download
* @property-read \App\Models\TvEpisode $episode
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\DnzbFailure[] $failed
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleaseFile[] $file
* @property-read \App\Models\UsenetGroup $group
* @property-read \App\Models\ReleaseNfo $nfo
* @property-read \App\Models\Predb $predb
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleaseExtraFull[] $releaseExtra
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleasesGroups[] $releaseGroup
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UsersRelease[] $userRelease
* @property-read \App\Models\Video $video
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ReleasesGroups[] $releaseGroup
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UsersRelease[] $userRelease
* @property-read \App\Models\Video $video
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Release whereAdddate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Release whereAnidbid($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Release whereAudiostatus($value)
@@ -151,7 +151,7 @@ class Release extends Model
*/
public function group()
{
return $this->belongsTo(Group::class, 'groups_id');
return $this->belongsTo(UsenetGroup::class, 'groups_id');
}
/**
@@ -421,7 +421,7 @@ class Release extends Model
->where('nzbstatus', '=', NZB::NZB_ADDED)
->select(['releases.*', 'g.name as group_name', 'c.title as category_name'])
->leftJoin('categories as c', 'c.id', '=', 'releases.categories_id')
->leftJoin('groups as g', 'g.id', '=', 'releases.groups_id')
->leftJoin('usenet_groups as g', 'g.id', '=', 'releases.groups_id')
->get();
}
@@ -497,14 +497,14 @@ class Release extends Model
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('usenet_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')
->leftJoin('videos as v', 'v.id', '=', 'releases.videos_id')
->leftJoin('tv_info as tvi', 'tvi.videos_id', '=', 'releases.videos_id')
->leftJoin('tv_episodes as tve', 'tve.id', '=', 'releases.tv_episodes_id')
->leftJoin('releases_groups as rg', 'rg.releases_id', '=', 'releases.id')
->leftJoin('groups as g2', 'rg.groups_id', '=', 'g2.id');
->leftJoin('usenet_groups as g2', 'rg.groups_id', '=', 'g2.id');
if (\is_array($guid)) {
$tempGuids = [];
@@ -27,22 +27,22 @@ use Illuminate\Database\Eloquent\Model;
* @property bool $backfill
* @property string|null $description
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Release[] $release
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereBackfill($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereBackfillTarget($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereFirstRecord($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereFirstRecordPostdate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereLastRecord($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereLastRecordPostdate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereLastUpdated($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereMinfilestoformrelease($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereMinsizetoformrelease($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Group whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereBackfill($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereBackfillTarget($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereFirstRecord($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereFirstRecordPostdate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereLastRecord($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereLastRecordPostdate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereLastUpdated($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereMinfilestoformrelease($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereMinsizetoformrelease($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UsenetGroup whereName($value)
* @mixin \Eloquent
*/
class Group extends Model
class UsenetGroup extends Model
{
/**
* @var bool
@@ -303,7 +303,7 @@ class Group extends Model
*/
public static function addGroup($group)
{
$checkOld = Group::query()->where('name', trim($group['name']))->first();
$checkOld = UsenetGroup::query()->where('name', trim($group['name']))->first();
if (empty($checkOld)) {
return self::query()->insertGetId([
'name' => trim($group['name']),
@@ -455,7 +455,7 @@ class Group extends Model
$nntp->doQuit();
if ($nntp->isError($groups)) {
return 'Problem fetching groups from usenet.';
return 'Problem fetching usenet_groups from usenet.';
}
$regFilter = '/'.$groupList.'/i';
+3 -3
View File
@@ -157,14 +157,14 @@ foreach ($data as $dir => $files) {
DB::delete('DELETE FROM predb_imports WHERE LENGTH(title) <= 8');
// Add any groups that do not currently exist
DB::insert("INSERT IGNORE INTO groups (name, description)
DB::insert("INSERT IGNORE INTO usenet_groups (name, description)
SELECT groupname, 'Added by predb import script'
FROM predb_imports AS pi LEFT JOIN groups AS g ON pi.groupname = g.name
FROM predb_imports AS pi LEFT JOIN usenet_groups AS g ON pi.groupname = g.name
WHERE pi.groupname IS NOT NULL AND g.name IS NULL
GROUP BY groupname");
// Fill the groups_id
DB::update('UPDATE predb_imports AS pi SET groups_id = (SELECT id FROM groups WHERE name = pi.groupname) WHERE groupname IS NOT NULL');
DB::update('UPDATE predb_imports AS pi SET groups_id = (SELECT id FROM usenet_groups WHERE name = pi.groupname) WHERE groupname IS NOT NULL');
$colorCli->info('Inserting records from temporary table into predb table');
$inserted = DB::insert("INSERT INTO predb (title, nfo, size, files, filename, nuked, nukereason, category, predate, SOURCE, requestid, groups_id)
@@ -0,0 +1,28 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RenameGroupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::rename('groups', 'usenet_groups');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
+2 -2
View File
@@ -12,9 +12,9 @@ class GroupsTableSeeder extends Seeder
*/
public function run()
{
\DB::table('groups')->delete();
\DB::table('usenet_groups')->delete();
\DB::table('groups')->insert([
\DB::table('usenet_groups')->insert([
0 =>
[
'id' => 1,
+1 -1
View File
@@ -37,7 +37,7 @@ if ($argv[3] === 'true') {
$pdo = DB::connection()->getPdo();
$group = DB::selectOne(sprintf('SELECT id FROM groups WHERE name = %s', escapeString($argv[1])));
$group = DB::selectOne(sprintf('SELECT id FROM usenet_groups WHERE name = %s', escapeString($argv[1])));
if ($group === false) {
exit('No group with name '.$argv[1].' found in the database.');
@@ -6,7 +6,7 @@ if (! isset($argv[1])) {
require_once dirname(__DIR__, 4) . DIRECTORY_SEPARATOR . 'bootstrap/autoload.php';
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Settings;
use Blacklight\processing\PostProcess;
use Blacklight\processing\ProcessReleases;
@@ -98,7 +98,7 @@ switch ($options[1]) {
} catch (Exception $e) {
echo $e->getMessage();
}
$groupMySQL = Group::getByName($options[3])->toArray();
$groupMySQL = UsenetGroup::getByName($options[3])->toArray();
try {
if ($nntp->isError($nntp->selectGroup($groupMySQL['name'])) && $nntp->isError($nntp->dataError($nntp, $groupMySQL['name']))) {
return;
@@ -135,7 +135,7 @@ switch ($options[1]) {
);
$columns[2] = sprintf('last_record = %s', $return['lastArticleNumber']);
$query = sprintf(
'UPDATE groups SET %s, %s, last_updated = NOW() WHERE id = %d AND last_record < %s',
'UPDATE usenet_groups SET %s, %s, last_updated = NOW() WHERE id = %d AND last_record < %s',
$columns[1],
$columns[2],
$groupMySQL['id'],
@@ -153,7 +153,7 @@ switch ($options[1]) {
);
$columns[2] = sprintf('first_record = %s', $return['firstArticleNumber']);
$query = sprintf(
'UPDATE groups SET %s, %s, last_updated = NOW() WHERE id = %d AND first_record > %s',
'UPDATE usenet_groups SET %s, %s, last_updated = NOW() WHERE id = %d AND first_record > %s',
$columns[1],
$columns[2],
$groupMySQL['id'],
@@ -171,7 +171,7 @@ switch ($options[1]) {
* $options[2] => (string) Group name.
*/
case 'part_repair':
$groupMySQL = Group::getByName($options[2])->toArray();
$groupMySQL = UsenetGroup::getByName($options[2])->toArray();
try {
$nntp = nntp();
} catch (Exception $e) {
@@ -254,7 +254,7 @@ switch ($options[1]) {
} catch (Exception $e) {
echo $e->getMessage();
}
$groupMySQL = Group::getByName($options[2])->toArray();
$groupMySQL = UsenetGroup::getByName($options[2])->toArray();
try {
(new Binaries(['NNTP' => $nntp]))->updateGroup($groupMySQL);
} catch (Exception $e) {
@@ -268,7 +268,7 @@ switch ($options[1]) {
case 'update_per_group':
if (is_numeric($options[2])) {
// Get the group info from MySQL.
$groupMySQL = Group::find($options[2])->toArray();
$groupMySQL = UsenetGroup::find($options[2])->toArray();
if ($groupMySQL === null) {
exit('ERROR: Group not found with id ' . $options[2] . PHP_EOL);
+2 -2
View File
@@ -3,7 +3,7 @@
require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use Blacklight\NNTP;
use App\Models\Group;
use App\Models\UsenetGroup;
use Blacklight\ColorCLI;
use App\Models\ShortGroup;
use Illuminate\Support\Arr;
@@ -33,7 +33,7 @@ $colorCli->header('Inserting new values into short_groups table.');
DB::statement('TRUNCATE TABLE short_groups');
// Put into an array all active groups
$result = Arr::pluck(Group::query()->where('active', '=', 1)->orWhere('backfill', '=', 1)->get(['name']), 'name');
$result = Arr::pluck(UsenetGroup::query()->where('active', '=', 1)->orWhere('backfill', '=', 1)->get(['name']), 'name');
foreach ($data as $newgroup) {
if (\in_array($newgroup['group'], $result, false)) {
+2 -2
View File
@@ -3,7 +3,7 @@
require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
use Blacklight\NNTP;
use App\Models\Group;
use App\Models\UsenetGroup;
use App\Models\Settings;
use Blacklight\Binaries;
use Blacklight\ColorCLI;
@@ -23,7 +23,7 @@ if (isset($argv[1]) && ! is_numeric($argv[1])) {
$groupName = $argv[1];
$colorCli->header("Updating group: $groupName");
$group = Group::getByName($groupName);
$group = UsenetGroup::getByName($groupName);
if (is_array($group)) {
$binaries->updateGroup(
$group,