mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Add first wave of Release tagging capabilities
This commit is contained in:
+310
-158
File diff suppressed because it is too large
Load Diff
@@ -396,6 +396,7 @@ class NZBImport
|
||||
|
||||
if ($dupeCheck === null) {
|
||||
$escapedSearchName = $cleanName;
|
||||
$determinedCategory = $this->category->determineCategory($nzbDetails['groups_id'], $cleanName, $escapedFromName);
|
||||
// Insert the release into the DB.
|
||||
$relID = Release::insertRelease(
|
||||
[
|
||||
@@ -407,13 +408,16 @@ class NZBImport
|
||||
'postdate' => $nzbDetails['postDate'],
|
||||
'fromname' => $escapedFromName,
|
||||
'size' => $nzbDetails['totalSize'],
|
||||
'categories_id' => $this->category->determineCategory($nzbDetails['groups_id'], $cleanName, $escapedFromName),
|
||||
'categories_id' => $determinedCategory['categories_id'],
|
||||
'isrenamed' => $renamed,
|
||||
'reqidstatus' => 0,
|
||||
'predb_id' => 0,
|
||||
'nzbstatus' => NZB::NZB_ADDED,
|
||||
]
|
||||
);
|
||||
$release = Release::find($relID);
|
||||
$release->tag($determinedCategory['tags']);
|
||||
|
||||
} else {
|
||||
$this->echoOut('This release is already in our DB so skipping: '.$subject);
|
||||
|
||||
|
||||
@@ -871,7 +871,7 @@ class NameFixer
|
||||
if ($this->echooutput === true && $show === true) {
|
||||
$groupName = Group::getNameByID($release->groups_id);
|
||||
$oldCatName = Category::getNameByID($release->categories_id);
|
||||
$newCatName = Category::getNameByID($determinedCategory);
|
||||
$newCatName = Category::getNameByID($determinedCategory['categories_id']);
|
||||
|
||||
if ($type === 'PAR2, ') {
|
||||
echo PHP_EOL;
|
||||
@@ -953,7 +953,7 @@ class NameFixer
|
||||
'anidbid' => null,
|
||||
'predb_id' => $preId,
|
||||
'searchname' => $newTitle,
|
||||
'categories_id' => $determinedCategory,
|
||||
'categories_id' => $determinedCategory['categories_id'],
|
||||
];
|
||||
|
||||
if ($status !== '') {
|
||||
@@ -963,6 +963,7 @@ class NameFixer
|
||||
}
|
||||
|
||||
$release->update($updateColumns);
|
||||
$release->tag($determinedCategory['tags']);
|
||||
$this->sphinx->updateRelease($release->releases_id);
|
||||
} else {
|
||||
$newTitle = substr($newName, 0, 299);
|
||||
@@ -978,10 +979,11 @@ class NameFixer
|
||||
'anidbid' => null,
|
||||
'predb_id' => $preId,
|
||||
'searchname' => $newTitle,
|
||||
'categories_id' => $determinedCategory,
|
||||
'categories_id' => $determinedCategory['categories_id'],
|
||||
'iscategorized' => 1,
|
||||
]
|
||||
);
|
||||
$release->tag($determinedCategory['tags']);
|
||||
$this->sphinx->updateRelease($release->releases_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,8 @@ class ProcessReleases
|
||||
$total = \count($releases);
|
||||
foreach ($releases as $release) {
|
||||
$catId = $cat->determineCategory($release->groups_id, $release->{$type}, $release->fromname);
|
||||
Release::query()->where('id', $release->id)->update(['categories_id' => $catId, 'iscategorized' => 1]);
|
||||
Release::query()->where('id', $release->id)->update(['categories_id' => $catId['categories_id'], 'iscategorized' => 1]);
|
||||
$release->retag($catId['tags']);
|
||||
$categorized++;
|
||||
if ($this->echoCLI) {
|
||||
$this->consoleTools->overWritePrimary(
|
||||
@@ -596,6 +597,8 @@ class ProcessReleases
|
||||
}
|
||||
}
|
||||
|
||||
$determinedCategory = $categorize->determineCategory($collection->groups_id, $cleanedName);
|
||||
|
||||
$releaseID = Release::insertRelease(
|
||||
[
|
||||
'name' => $cleanRelName,
|
||||
@@ -606,12 +609,14 @@ class ProcessReleases
|
||||
'postdate' => $collection->date,
|
||||
'fromname' => $fromName,
|
||||
'size' => $collection->filesize,
|
||||
'categories_id' => $categorize->determineCategory($collection->groups_id, $cleanedName),
|
||||
'categories_id' => $determinedCategory['categories_id'],
|
||||
'isrenamed' => $properName === true ? 1 : 0,
|
||||
'predb_id' => $preID === false ? 0 : $preID,
|
||||
'nzbstatus' => NZB::NZB_NONE,
|
||||
]
|
||||
);
|
||||
$release = Release::find($releaseID);
|
||||
$release->retag($determinedCategory['tags']);
|
||||
|
||||
if ($releaseID !== null) {
|
||||
// Update collections table to say we inserted the release.
|
||||
|
||||
@@ -1750,10 +1750,12 @@ class ProcessAdditional
|
||||
SET searchname = %s, categories_id = %d, iscategorized = 1, isrenamed = 1, proc_pp = 1
|
||||
WHERE id = %d',
|
||||
$newTitle,
|
||||
$newCat,
|
||||
$newCat['categories_id'],
|
||||
$this->_release->id
|
||||
)
|
||||
);
|
||||
$release = Release::find($this->_release->id);
|
||||
$release->retag($newCat['tags']);
|
||||
$this->sphinx->updateRelease($this->_release->id);
|
||||
|
||||
// Echo the changed name.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
2018-11-01 DariusIII
|
||||
* Chg: Add first wave of Release tagging capabilities
|
||||
2018-10-31 DariusIII
|
||||
* Chg: Update NameFixer updateRelease function to use already provided release to update and skip doing unnecessary queries
|
||||
* Chg: Update symfony components to their latest versions
|
||||
|
||||
@@ -160,12 +160,10 @@ class Category extends Model
|
||||
];
|
||||
|
||||
/**
|
||||
* Temporary category while we sort through the name.
|
||||
* @var int
|
||||
* @var string
|
||||
*/
|
||||
protected $tmpCat = self::OTHER_MISC;
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Blacklight\NZB;
|
||||
use Blacklight\SphinxSearch;
|
||||
use Conner\Tagging\Taggable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Watson\Rememberable\Rememberable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -128,7 +129,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class Release extends Model
|
||||
{
|
||||
use Rememberable;
|
||||
use Rememberable, Taggable;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
</last>
|
||||
</scripts>
|
||||
<sql>
|
||||
<db>357</db>
|
||||
<file>357</file>
|
||||
<db>358</db>
|
||||
<file>358</file>
|
||||
</sql>
|
||||
</versions>
|
||||
</nntmux>
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
"predis/predis": "^1.1",
|
||||
"propaganistas/laravel-disposable-email": "^2.0",
|
||||
"ramsey/uuid": "^3.7",
|
||||
"rtconner/laravel-tagging": "^3.0",
|
||||
"smarty/smarty": "^3.1",
|
||||
"spatie/laravel-fractal": "^5.3",
|
||||
"spatie/laravel-permission": "^2.12",
|
||||
|
||||
Generated
+93
-16
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "b3a47d0324cda1a0b9b10734d9f34c27",
|
||||
"content-hash": "8799a7c6a870c9a9e1361e31def1aa02",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aharen/omdbapi",
|
||||
@@ -321,7 +321,8 @@
|
||||
"Gemfile.lock",
|
||||
"*.md"
|
||||
]
|
||||
}
|
||||
},
|
||||
"time": "2016-06-06T17:37:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/autosize",
|
||||
@@ -350,7 +351,8 @@
|
||||
"form",
|
||||
"textarea",
|
||||
"ui"
|
||||
]
|
||||
],
|
||||
"time": "2017-05-19T15:36:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/bootstrap",
|
||||
@@ -399,7 +401,8 @@
|
||||
"mobile-first",
|
||||
"responsive",
|
||||
"web"
|
||||
]
|
||||
],
|
||||
"time": "2016-07-25T15:51:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/bootstrap-datepicker",
|
||||
@@ -428,7 +431,8 @@
|
||||
},
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
]
|
||||
],
|
||||
"time": "2016-08-05T09:50:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/bootstrap-hover-dropdown",
|
||||
@@ -458,7 +462,8 @@
|
||||
"dropdowns",
|
||||
"hover",
|
||||
"twitter"
|
||||
]
|
||||
],
|
||||
"time": "2015-12-01T23:35:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/bootstrap-progressbar",
|
||||
@@ -492,7 +497,8 @@
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
]
|
||||
],
|
||||
"time": "2015-05-15T18:56:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/colorbox",
|
||||
@@ -533,7 +539,8 @@
|
||||
"modal",
|
||||
"popup",
|
||||
"ui"
|
||||
]
|
||||
],
|
||||
"time": "2016-05-10T22:21:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/datatables",
|
||||
@@ -648,7 +655,8 @@
|
||||
"tests",
|
||||
"examples"
|
||||
]
|
||||
}
|
||||
},
|
||||
"time": "2015-01-26T21:19:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/flexboxgrid",
|
||||
@@ -684,7 +692,8 @@
|
||||
"css",
|
||||
"flexbox",
|
||||
"grid"
|
||||
]
|
||||
],
|
||||
"time": "2016-08-14T16:43:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/font-awesome",
|
||||
@@ -750,7 +759,8 @@
|
||||
"replacement",
|
||||
"skins",
|
||||
"ui"
|
||||
]
|
||||
],
|
||||
"time": "2014-03-03T17:36:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/jquery",
|
||||
@@ -817,7 +827,8 @@
|
||||
"scroll",
|
||||
"scrolltop",
|
||||
"scrolltotop"
|
||||
]
|
||||
],
|
||||
"time": "2017-08-31T15:51:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/jquery-migrate",
|
||||
@@ -867,7 +878,8 @@
|
||||
"demo",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
},
|
||||
"time": "2016-03-01T20:38:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/multifile",
|
||||
@@ -983,7 +995,8 @@
|
||||
"progress",
|
||||
"progress",
|
||||
"spinner"
|
||||
]
|
||||
],
|
||||
"time": "2014-11-06T16:31:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/pnotify",
|
||||
@@ -1035,7 +1048,8 @@
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"description": "JavaScript notification plugin."
|
||||
"description": "JavaScript notification plugin.",
|
||||
"time": "2017-07-31T21:50:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/slimscroll",
|
||||
@@ -1076,7 +1090,8 @@
|
||||
"scrolling",
|
||||
"slimscroll",
|
||||
"ui"
|
||||
]
|
||||
],
|
||||
"time": "2016-06-11T09:19:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bower-asset/tinymce-dist",
|
||||
@@ -5438,6 +5453,68 @@
|
||||
],
|
||||
"time": "2018-07-19T23:38:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rtconner/laravel-tagging",
|
||||
"version": "3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rtconner/laravel-tagging.git",
|
||||
"reference": "6f58920a2146d520de34d858ad93fe9af2012256"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rtconner/laravel-tagging/zipball/6f58920a2146d520de34d858ad93fe9af2012256",
|
||||
"reference": "6f58920a2146d520de34d858ad93fe9af2012256",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/database": ">= 5.0",
|
||||
"illuminate/support": ">= 5.0",
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9",
|
||||
"orchestra/testbench": "~3.0",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"vlucas/phpdotenv": "~2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Conner\\Tagging\\Providers\\TaggingServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Conner\\Tagging\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Robert Conner",
|
||||
"email": "rtconner@smarter.bz"
|
||||
}
|
||||
],
|
||||
"description": "Use PHP traits to extend Laravel Eloquent Models to allow Tags. Models can be marked as Taggable.",
|
||||
"homepage": "https://smartersoftware.net/packages/laravel-tagging-taggable",
|
||||
"keywords": [
|
||||
"Taggable",
|
||||
"eloquent",
|
||||
"laravel",
|
||||
"laravel5",
|
||||
"tag",
|
||||
"tagged",
|
||||
"tagging",
|
||||
"tags"
|
||||
],
|
||||
"time": "2018-08-13T16:25:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rtheunissen/guzzle-log-middleware",
|
||||
"version": "v0.4.1",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
// Datatype for primary keys of your models.
|
||||
// used in migrations only
|
||||
'primary_keys_type' => 'integer', // 'string' or 'integer'
|
||||
|
||||
// Value of are passed through this before save of tags
|
||||
'normalizer' => '\Conner\Tagging\Util::slug',
|
||||
|
||||
// Display value of tags are passed through (for front end display)
|
||||
'displayer' => '\Illuminate\Support\Str::title',
|
||||
|
||||
// Database connection for Conner\Taggable\Tag model to use
|
||||
// 'connection' => 'mysql',
|
||||
|
||||
// When deleting a model, remove all the tags first
|
||||
'untag_on_delete' => true,
|
||||
|
||||
// Auto-delete unused tags from the 'tags' database table (when they are used zero times)
|
||||
'delete_unused_tags'=>true,
|
||||
|
||||
// Model to use to store the tags in the database
|
||||
'tag_model'=>'\Conner\Tagging\Model\Tag',
|
||||
|
||||
// Delimiter used within tags
|
||||
'delimiter' => '-',
|
||||
|
||||
// Model to use for the relation between tags and tagged records
|
||||
'tagged_model' => '\Conner\Tagging\Model\Tagged',
|
||||
];
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateTaggedTable extends Migration {
|
||||
|
||||
public function up() {
|
||||
Schema::create('tagging_tagged', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
if(config('tagging.primary_keys_type') == 'string') {
|
||||
$table->string('taggable_id', 36)->index();
|
||||
} else {
|
||||
$table->integer('taggable_id')->unsigned()->index();
|
||||
}
|
||||
$table->string('taggable_type', 125)->index();
|
||||
$table->string('tag_name', 125);
|
||||
$table->string('tag_slug', 125)->index();
|
||||
});
|
||||
}
|
||||
|
||||
public function down() {
|
||||
Schema::drop('tagging_tagged');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateTagsTable extends Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tagging_tags', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('slug', 125)->index();
|
||||
$table->string('name', 125);
|
||||
$table->boolean('suggest')->default(false);
|
||||
$table->integer('count')->unsigned()->default(0); // count of how many times this tag was used
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('tagging_tags');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateTagGroupsTable extends Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tagging_tag_groups', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('slug', 125)->index();
|
||||
$table->string('name', 125);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('tagging_tag_groups');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class UpdateTagsTable extends Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::table('tagging_tags', function ($table) {
|
||||
$table->integer('tag_group_id')->unsigned()->nullable()->after('id');
|
||||
$table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('tagging_tags', function ($table) {
|
||||
$table->dropForeign('tagging_tags_tag_group_id_foreign');
|
||||
$table->dropColumn('tag_group_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Release;
|
||||
use Blacklight\ColorCLI;
|
||||
use Blacklight\Categorize;
|
||||
use Blacklight\ConsoleTools;
|
||||
@@ -97,10 +98,12 @@ function categorizeRelease($where, $update = true, $echooutput = false)
|
||||
xxxinfo_id = 0,
|
||||
categories_id = %d
|
||||
WHERE id = %d',
|
||||
$catId,
|
||||
$catId['categories_id'],
|
||||
$rowrel->id
|
||||
)
|
||||
);
|
||||
$release = Release::find($rowrel->id);
|
||||
$release->retag($catId['tags']);
|
||||
}
|
||||
$chgcount++;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# Add tables related to tagging releases
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
DROP TABLE IF EXISTS tagging_tag_groups;
|
||||
create table tagging_tag_groups
|
||||
(
|
||||
id int unsigned auto_increment primary key,
|
||||
slug varchar(125) not null,
|
||||
name varchar(125) not null
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci
|
||||
ROW_FORMAT=DYNAMIC;
|
||||
|
||||
create index tagging_tag_groups_slug_index on tagging_tag_groups (slug);
|
||||
|
||||
DROP TABLE IF EXISTS tagging_tagged;
|
||||
create table tagging_tagged
|
||||
(
|
||||
id int unsigned auto_increment primary key,
|
||||
taggable_id int unsigned not null,
|
||||
taggable_type varchar(125) not null,
|
||||
tag_name varchar(125) not null,
|
||||
tag_slug varchar(125) not null
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci
|
||||
ROW_FORMAT=DYNAMIC;
|
||||
|
||||
create index tagging_tagged_tag_slug_index on tagging_tagged (tag_slug);
|
||||
|
||||
create index tagging_tagged_taggable_id_index on tagging_tagged (taggable_id);
|
||||
|
||||
create index tagging_tagged_taggable_type_index on tagging_tagged (taggable_type);
|
||||
|
||||
DROP TABLE IF EXISTS tagging_tags;
|
||||
create table tagging_tags
|
||||
(
|
||||
id int unsigned auto_increment
|
||||
primary key,
|
||||
tag_group_id int unsigned null,
|
||||
slug varchar(125) not null,
|
||||
name varchar(125) not null,
|
||||
suggest tinyint(1) default 0 not null,
|
||||
count int unsigned default 0 not null,
|
||||
constraint tagging_tags_tag_group_id_foreign foreign key (tag_group_id) references tagging_tag_groups (id)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci
|
||||
ROW_FORMAT=DYNAMIC;
|
||||
|
||||
create index tagging_tags_slug_index on tagging_tags (slug);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
Reference in New Issue
Block a user