move cleanup: seed bonus and seeding leeching time to job

This commit is contained in:
xiaomlove
2022-10-28 14:17:10 +08:00
parent 410aed39cf
commit a61d1b0900
19 changed files with 404 additions and 110 deletions

View File

@@ -111,42 +111,8 @@ class SearchBoxRepository extends BaseRepository
*/
public function migrateToModeRelated()
{
$secondIconTable = 'secondicons';
$normalId = Setting::get('main.browsecat');
$specialId = Setting::get('main.specialcat');
$searchBoxList = SearchBox::query()->get();
$tables = array_values(SearchBox::$taxonomies);
foreach ($searchBoxList as $searchBox) {
// if ($searchBox->id == $normalId) {
// //all sub categories add `mode` field
// foreach ($tables as $table) {
// NexusDB::table($table)->update(['mode' => $normalId]);
// do_log("update table $table mode = $normalId");
// }
// //also second icons
// NexusDB::table($secondIconTable)->update(['mode' => $normalId]);
// do_log("update table $secondIconTable mode = $normalId");
// } elseif ($searchBox->id == $specialId && $specialId != $normalId) {
// //copy from normal section
// foreach ($tables as $table) {
// $sql = sprintf(
// "insert into `%s` (name, sort_index, mode) select name, sort_index, '%s' from `%s`",
// $table, $specialId, $table
// );
// NexusDB::statement($sql);
// do_log("copy table $table, $sql");
// }
// $fields = array_keys(SearchBox::$taxonomies);
// $fields = array_merge($fields, ['name', 'class_name', 'image']);
// $fieldStr = implode(', ', $fields);
// $sql = sprintf(
// "insert into `%s` (%s, mode) select %s, '%s' from `%s`",
// $secondIconTable, $fieldStr, $fieldStr, $specialId, $secondIconTable
// );
// NexusDB::statement($sql);
// do_log("copy table $secondIconTable, $sql");
// }
$taxonomies = [];
foreach (SearchBox::$taxonomies as $torrentField => $taxonomyTable) {
$searchBoxField = "show" . $torrentField;
@@ -164,6 +130,7 @@ class SearchBoxRepository extends BaseRepository
if (!empty($taxonomies)) {
$searchBox->update(["extra->" . SearchBox::EXTRA_TAXONOMY_LABELS => $taxonomies]);
}
clear_search_box_cache($searchBox->id);
}
}