mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 00:01:21 +00:00
Update search, update matching
This commit is contained in:
@@ -289,7 +289,7 @@ class IRCScraper extends IRCClient
|
||||
*/
|
||||
protected function _insertNewPre()
|
||||
{
|
||||
$sphinxData = $this->sphinxsearch->searchIndexes($this->_curPre['title'], ['title'], 'predb_rt');
|
||||
$sphinxData = $this->sphinxsearch->searchIndexes('predb_rt', $this->_curPre['title'], ['title']);
|
||||
if (! empty($sphinxData) || empty($this->_curPre['title'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1268,7 +1268,7 @@ class NameFixer
|
||||
$this->_cleanMatchFiles();
|
||||
$preMatch = $this->preMatch($this->_fileName);
|
||||
if ($preMatch[0] === true) {
|
||||
$results = $this->sphinx->searchIndexes($preMatch[1], ['filename', 'title'], 'predb_rt');
|
||||
$results = $this->sphinx->searchIndexes('predb_rt', $preMatch[1], ['filename', 'title']);
|
||||
if (! empty($results)) {
|
||||
foreach ($results as $result) {
|
||||
if (! empty($result)) {
|
||||
@@ -2443,7 +2443,7 @@ class NameFixer
|
||||
$this->_cleanMatchFiles();
|
||||
|
||||
if (! empty($this->_fileName)) {
|
||||
foreach ($this->sphinx->searchIndexes($this->_fileName, ['filename', 'title'], 'predb_rt') as $match) {
|
||||
foreach ($this->sphinx->searchIndexes('predb_rt', $this->_fileName, ['filename', 'title']) as $match) {
|
||||
if (! empty($match)) {
|
||||
$this->updateRelease($release, $match['title'], 'PreDb: Filename match', $echo, $type, $nameStatus, $show, $match['id']);
|
||||
|
||||
@@ -2470,7 +2470,7 @@ class NameFixer
|
||||
$this->_cleanMatchFiles();
|
||||
$this->cleanFileNames();
|
||||
if (! empty($this->_fileName)) {
|
||||
foreach ($this->sphinx->searchIndexes($this->_fileName, 'title', 'predb_rt') as $match) {
|
||||
foreach ($this->sphinx->searchIndexes('predb_rt', $this->_fileName, 'title') as $match) {
|
||||
if (! empty($match)) {
|
||||
$this->updateRelease($release, $match['title'], 'PreDb: Title match', $echo, $type, $nameStatus, $show, $match['id']);
|
||||
|
||||
|
||||
+13
-11
@@ -619,21 +619,23 @@ class Releases
|
||||
$orderBy = $this->getBrowseOrder($orderBy);
|
||||
}
|
||||
|
||||
$query = $this->sphinxSearch->sphinxQL->select()->from('releases_rt')->option('max_matches', 10000);
|
||||
$searchFields = [];
|
||||
if ($searchName !== -1) {
|
||||
$query->match('searchname', $searchName);
|
||||
$searchFields['searchname'] = $searchName;
|
||||
}
|
||||
if ($usenetName !== -1) {
|
||||
$query->match('name', $usenetName);
|
||||
$searchFields['name'] = $usenetName;
|
||||
}
|
||||
if ($posterName !== -1) {
|
||||
$query->match('fromname', $posterName);
|
||||
$searchFields['fromname'] = $posterName;
|
||||
}
|
||||
if ($fileName !== -1) {
|
||||
$query->match('filename', $fileName);
|
||||
$searchFields['filename'] = $fileName;
|
||||
}
|
||||
|
||||
$results = $query->execute()->fetchAllAssoc() ?? [];
|
||||
|
||||
|
||||
$results = $this->sphinxSearch->searchIndexes('releases_rt', '', '', $searchFields);
|
||||
|
||||
$searchResult = array_pluck($results, 'id');
|
||||
|
||||
@@ -731,7 +733,7 @@ class Releases
|
||||
public function apiSearch($searchName, $groupName, $offset = 0, $limit = 1000, $maxAge = -1, array $excludedCats = [], array $cat = [-1], $minSize = 0, array $tags = [])
|
||||
{
|
||||
if ($searchName !== -1) {
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes($searchName, ['searchname'], 'releases_rt'), 'id');
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $searchName, ['searchname']), 'id');
|
||||
}
|
||||
|
||||
$catQuery = Category::getCategorySearch($cat);
|
||||
@@ -871,7 +873,7 @@ class Releases
|
||||
}
|
||||
|
||||
if (! empty($name)) {
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes($name, ['searchname'], 'releases_rt'), 'id');
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id');
|
||||
}
|
||||
|
||||
$whereSql = sprintf(
|
||||
@@ -1016,7 +1018,7 @@ class Releases
|
||||
}
|
||||
|
||||
if (! empty($name)) {
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes($name, ['searchname'], 'releases_rt'), 'id');
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id');
|
||||
}
|
||||
|
||||
$whereSql = sprintf(
|
||||
@@ -1093,7 +1095,7 @@ class Releases
|
||||
public function animeSearch($aniDbID, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, array $excludedCategories = [])
|
||||
{
|
||||
if (! empty($name)) {
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes($name, ['searchname'], 'releases_rt'), 'id');
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id');
|
||||
}
|
||||
|
||||
$whereSql = sprintf(
|
||||
@@ -1167,7 +1169,7 @@ class Releases
|
||||
public function moviesSearch($imDbId = -1, $tmDbId = -1, $traktId = -1, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0, array $excludedCategories = [], array $tags = [])
|
||||
{
|
||||
if (! empty($name)) {
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes($name, ['searchname'], 'releases_rt'), 'id');
|
||||
$searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id');
|
||||
}
|
||||
|
||||
$whereSql = sprintf(
|
||||
|
||||
@@ -187,12 +187,22 @@ class SphinxSearch
|
||||
|
||||
/**
|
||||
* @param string $searchString (what are we looking for?)
|
||||
* @param string|array $column (one or multiple columns from the columns that exist in indexes)
|
||||
* @param string $rt_index (releases_rt or predb_rt)
|
||||
* @param array $column (one or multiple columns from the columns that exist in indexes)
|
||||
* @param string $rt_index (releases_rt or predb_rt)
|
||||
* @param array $searchArray
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function searchIndexes(string $searchString, $column, string $rt_index): array
|
||||
public function searchIndexes(string $rt_index, $searchString = '', $column = [], array $searchArray = []): array
|
||||
{
|
||||
return $this->sphinxQL->select()->from($rt_index)->match($column, $searchString)->option('max_matches', 10000)->execute()->fetchAllAssoc() ?? [];
|
||||
$query = $this->sphinxQL->select()->from($rt_index)->option('max_matches', 10000)->option('ranker', 'matchany')->limit(0, 10000)->orderBy('weight()', 'desc');
|
||||
if (! empty($searchArray)) {
|
||||
foreach ($searchArray as $key => $value) {
|
||||
$query->match($key, $value);
|
||||
}
|
||||
return $query->execute()->fetchAllAssoc() ?? [];
|
||||
}
|
||||
|
||||
return $query->match($column, $searchString)->execute()->fetchAllAssoc() ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
2019-01-21 DariusIII
|
||||
* Chg: Update search, update matching
|
||||
2019-01-20 DariusIII
|
||||
* Chg: Update rest of the cover checking files
|
||||
* Fix: Fix misc/tesing/PostProc/updateXXXImages.php script error (fixes issue #852)
|
||||
|
||||
@@ -19,7 +19,7 @@ class PredbController extends BasePageController
|
||||
|
||||
if ($request->has('presearch')) {
|
||||
$lastSearch = $request->input('presearch');
|
||||
$parr = Predb::getAll($request->input('presearch'));
|
||||
$parr = Predb::getAll(array_wrap($request->input('presearch')));
|
||||
} else {
|
||||
$lastSearch = '';
|
||||
$parr = Predb::getAll();
|
||||
|
||||
@@ -173,16 +173,17 @@ class Predb extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
* @param array $search
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getAll($search = '')
|
||||
public static function getAll($search = [])
|
||||
{
|
||||
$sql = self::query()->remember(config('nntmux.cache_expiry_medium'))->leftJoin('releases', 'releases.predb_id', '=', 'predb.id')->orderByDesc('predb.predate');
|
||||
if ($search !== '') {
|
||||
if (! empty($search)) {
|
||||
$sphinx = new SphinxSearch();
|
||||
$ids = array_pluck($sphinx->searchIndexes($search, 'title', 'predb_rt'), 'id');
|
||||
$ids = array_pluck($sphinx->searchIndexes('predb_rt', $search, 'title'), 'id');
|
||||
$sql->whereIn('predb.id', $ids);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user