diff --git a/app/Jobs/CalculateUserSeedBonus.php b/app/Jobs/CalculateUserSeedBonus.php index eb4b351f..ff819862 100644 --- a/app/Jobs/CalculateUserSeedBonus.php +++ b/app/Jobs/CalculateUserSeedBonus.php @@ -46,7 +46,7 @@ class CalculateUserSeedBonus implements ShouldQueue public $tries = 1; - public $timeout = 600; + public $timeout = 3600; /** * Execute the job. diff --git a/app/Models/SearchBox.php b/app/Models/SearchBox.php index 08d0f241..dea7bd45 100644 --- a/app/Models/SearchBox.php +++ b/app/Models/SearchBox.php @@ -274,5 +274,21 @@ class SearchBox extends NexusModel return implode('', $options); } + public static function listCategoryId($searchBoxId, $glue = null): array|string|null + { + static $results = null; + if (is_null($results)) { + $results = []; + $res = genrelist($searchBoxId); + foreach ($res as $item) { + $results[] = $item['id']; + } + } + if (!is_null($glue)) { + $results = implode($glue, $results); + } + return $results; + } + } diff --git a/app/Repositories/ClaimRepository.php b/app/Repositories/ClaimRepository.php index 5476cf1f..b3040b26 100644 --- a/app/Repositories/ClaimRepository.php +++ b/app/Repositories/ClaimRepository.php @@ -126,6 +126,7 @@ class ClaimRepository extends BaseRepository $startOfThisMonth = Carbon::now()->startOfMonth(); $query = Claim::query() ->select(['uid']) + ->where("created_at", "<", $startOfThisMonth) ->where(function (Builder $query) use ($startOfThisMonth) { $query->where('last_settle_at', '<', $startOfThisMonth)->orWhereNull('last_settle_at'); }) diff --git a/database/migrations/2023_07_05_005825_add_index_to_field_created_at_of_claims_table.php b/database/migrations/2023_07_05_005825_add_index_to_field_created_at_of_claims_table.php new file mode 100644 index 00000000..35459019 --- /dev/null +++ b/database/migrations/2023_07_05_005825_add_index_to_field_created_at_of_claims_table.php @@ -0,0 +1,32 @@ +index("created_at", "idx_created_at"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('claims', function (Blueprint $table) { + $table->dropIndex("idx_created_at"); + }); + } +}; diff --git a/include/bittorrent_announce.php b/include/bittorrent_announce.php index 03069721..e4488a2a 100644 --- a/include/bittorrent_announce.php +++ b/include/bittorrent_announce.php @@ -9,4 +9,3 @@ require_once $rootpath . 'include/functions.php'; require_once $rootpath . 'vendor/autoload.php'; \Nexus\Nexus::boot(); - diff --git a/include/constants.php b/include/constants.php index 92377591..85dfe66c 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ 1) $wherecatin = implode(",",$wherecatina); elseif (count($wherecatina) == 1) @@ -918,10 +922,15 @@ if ($allsec == 1 || $enablespecial != 'yes') } else { - if ($where != "") - $where = "WHERE $where AND categories.mode = '$sectiontype'"; - else $where = "WHERE categories.mode = '$sectiontype'"; - $sql = "SELECT COUNT(*), categories.mode FROM torrents LEFT JOIN categories ON category = categories.id " . ($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "") . $tagFilter . $where . " GROUP BY categories.mode"; +// if ($where != "") +// $where = "WHERE $where AND categories.mode = '$sectiontype'"; +// else $where = "WHERE categories.mode = '$sectiontype'"; + + if ($where != "") + $where = "WHERE $where"; + else $where = ""; +// $sql = "SELECT COUNT(*), categories.mode FROM torrents LEFT JOIN categories ON category = categories.id " . ($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "") . $tagFilter . $where . " GROUP BY categories.mode"; + $sql = "SELECT COUNT(*) FROM torrents " . ($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "") . $tagFilter . $where; } if ($shouldUseMeili) { @@ -973,7 +982,8 @@ if ($count) // if ($allsec == 1 || $enablespecial != 'yes') { // $query = "SELECT $fieldsStr FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." $tagFilter $where $orderby $limit"; // } else { - $query = "SELECT $fieldsStr, categories.mode as search_box_id FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." LEFT JOIN categories ON torrents.category=categories.id $tagFilter $where $orderby $limit"; +// $query = "SELECT $fieldsStr, categories.mode as search_box_id FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." LEFT JOIN categories ON torrents.category=categories.id $tagFilter $where $orderby $limit"; + $query = "SELECT $fieldsStr, $sectiontype as search_box_id FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")."$tagFilter $where $orderby $limit"; // } do_log("[TORRENT_LIST_SQL] $query", 'debug'); if (!$shouldUseMeili) {