mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
meilisearch search descr field configurable
This commit is contained in:
@@ -146,6 +146,12 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
||||
->label(__('label.setting.system.meilisearch_enabled'))
|
||||
->helperText(__('label.setting.system.meilisearch_enabled_help'))
|
||||
,
|
||||
Forms\Components\Radio::make('system.meilisearch_search_description')
|
||||
->options(self::$yesOrNo)
|
||||
->inline(true)
|
||||
->label(__('label.setting.system.meilisearch_search_description'))
|
||||
->helperText(__('label.setting.system.meilisearch_search_description_help'))
|
||||
,
|
||||
])->columns(2);
|
||||
|
||||
$tabs = apply_filter('nexus_setting_tabs', $tabs);
|
||||
|
||||
@@ -65,8 +65,6 @@ class MeiliSearchRepository extends BaseRepository
|
||||
'9' => 'owner',
|
||||
];
|
||||
|
||||
private static array $searchableAttributes = ["name", "small_descr", "descr", "url"];
|
||||
|
||||
private static array $filterableAttributes = [
|
||||
"id", "category", "source", "medium", "codec", "standard", "processing", "team", "audiocodec", "owner",
|
||||
"sp_state", "visible", "banned", "approval_status", "size", "leechers", "seeders", "times_completed", "added",
|
||||
@@ -157,7 +155,7 @@ class MeiliSearchRepository extends BaseRepository
|
||||
$settings = [
|
||||
"distinctAttribute" => "id",
|
||||
"displayedAttributes" => $this->getRequiredFields(),
|
||||
"searchableAttributes" => self::$searchableAttributes,
|
||||
"searchableAttributes" => $this->getSearchableAttributes(),
|
||||
"filterableAttributes" => self::$filterableAttributes,
|
||||
"sortableAttributes" => self::$sortableAttributes,
|
||||
"rankingRules" => [
|
||||
@@ -178,7 +176,7 @@ class MeiliSearchRepository extends BaseRepository
|
||||
public function getRequiredFields(): array
|
||||
{
|
||||
return array_values(array_unique(array_merge(
|
||||
self::$filterableAttributes, self::$searchableAttributes, self::$sortableAttributes
|
||||
self::$filterableAttributes, self::$sortableAttributes, $this->getSearchableAttributes()
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -554,6 +552,15 @@ class MeiliSearchRepository extends BaseRepository
|
||||
return ['*'];
|
||||
}
|
||||
|
||||
private function getSearchableAttributes(): array
|
||||
{
|
||||
$attributes = ["name", "small_descr", "url"];
|
||||
if (Setting::get("system.meilisearch_search_description") == 'yes') {
|
||||
$attributes[] = "descr";
|
||||
}
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -439,4 +439,55 @@ class ToolRepository extends BaseRepository
|
||||
return $this->generateUniqueInviteHash($hashArr, $total, $total - count($hashArr), ++$deep);
|
||||
|
||||
}
|
||||
|
||||
public function removeDuplicateSnatch()
|
||||
{
|
||||
$size = 2000;
|
||||
$stickyPromotionParticipatorsTable = 'sticky_promotion_participators';
|
||||
$stickyPromotionExists = NexusDB::hasTable($stickyPromotionParticipatorsTable);
|
||||
while (true) {
|
||||
$snatchRes = NexusDB::select("select userid, torrentid, group_concat(id) as ids from snatched group by userid, torrentid having(count(*)) > 1 limit $size");
|
||||
if (empty($snatchRes)) {
|
||||
break;
|
||||
}
|
||||
do_log("[DELETE_DUPLICATED_SNATCH], count: " . count($snatchRes));
|
||||
foreach ($snatchRes as $snatchRow) {
|
||||
$torrentId = $snatchRow['torrentid'];
|
||||
$userId = $snatchRow['userid'];
|
||||
$idArr = explode(',', $snatchRow['ids']);
|
||||
sort($idArr, SORT_NUMERIC);
|
||||
$remainId = array_pop($idArr);
|
||||
$delIdStr = implode(',', $idArr);
|
||||
do_log("[DELETE_DUPLICATED_SNATCH], torrent: $torrentId, user: $userId, snatchIdStr: $delIdStr");
|
||||
NexusDB::statement("delete from snatched where id in ($delIdStr)");
|
||||
NexusDB::statement("update claims set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
NexusDB::statement("update hit_and_runs set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
if ($stickyPromotionExists) {
|
||||
NexusDB::statement("update $stickyPromotionParticipatorsTable set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeDuplicatePeer()
|
||||
{
|
||||
$size = 2000;
|
||||
while (true) {
|
||||
$results = NexusDB::select("select torrent, peer_id, userid, group_concat(id) as ids from peers group by torrent, peer_id, userid having(count(*)) > 1 limit $size");
|
||||
if (empty($results)) {
|
||||
break;
|
||||
}
|
||||
do_log("[DELETE_DUPLICATED_PEERS], count: " . count($results));
|
||||
foreach ($results as $row) {
|
||||
$torrentId = $row['torrent'];
|
||||
$userId = $row['userid'];
|
||||
$idArr = explode(',', $row['ids']);
|
||||
sort($idArr, SORT_NUMERIC);
|
||||
$remainId = array_pop($idArr);
|
||||
$delIdStr = implode(',', $idArr);
|
||||
do_log("[DELETE_DUPLICATED_PEERS], torrent: $torrentId, user: $userId, snatchIdStr: $delIdStr");
|
||||
NexusDB::statement("delete from peers where id in ($delIdStr)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,34 +703,7 @@ HTML;
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function removeDuplicateSnatch()
|
||||
{
|
||||
$size = 2000;
|
||||
$stickyPromotionParticipatorsTable = 'sticky_promotion_participators';
|
||||
$stickyPromotionExists = NexusDB::hasTable($stickyPromotionParticipatorsTable);
|
||||
while (true) {
|
||||
$snatchRes = NexusDB::select("select userid, torrentid, group_concat(id) as ids from snatched group by userid, torrentid having(count(*)) > 1 limit $size");
|
||||
if (empty($snatchRes)) {
|
||||
break;
|
||||
}
|
||||
do_log("[DELETE_DUPLICATED_SNATCH], count: " . count($snatchRes));
|
||||
foreach ($snatchRes as $snatchRow) {
|
||||
$torrentId = $snatchRow['torrentid'];
|
||||
$userId = $snatchRow['userid'];
|
||||
$idArr = explode(',', $snatchRow['ids']);
|
||||
sort($idArr, SORT_NUMERIC);
|
||||
$remainId = array_pop($idArr);
|
||||
$delIdStr = implode(',', $idArr);
|
||||
do_log("[DELETE_DUPLICATED_SNATCH], torrent: $torrentId, user: $userId, snatchIdStr: $delIdStr");
|
||||
NexusDB::statement("delete from snatched where id in ($delIdStr)");
|
||||
NexusDB::statement("update claims set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
NexusDB::statement("update hit_and_runs set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
if ($stickyPromotionExists) {
|
||||
NexusDB::statement("update $stickyPromotionParticipatorsTable set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getPaidIcon(array $torrentInfo, $size = 16, $verticalAlign = 'sub')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user