del h&R when del torrent

This commit is contained in:
xiaomlove
2022-05-03 00:38:50 +08:00
parent 07bd1f724b
commit 17339bda67
5 changed files with 12 additions and 9 deletions

View File

@@ -150,7 +150,7 @@ class User extends Authenticatable
*/
protected $fillable = [
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'modcomment', 'enabled', 'status',
'leechwarn', 'leechwarnuntil', 'page', 'class', 'uploaded', 'downloaded', 'clientselect', 'showclienterror',
'leechwarn', 'leechwarnuntil', 'page', 'class', 'uploaded', 'downloaded', 'clientselect', 'showclienterror', 'last_home',
];
/**

View File

@@ -7,6 +7,7 @@ use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Nexus\Database\NexusDB;
class SettingRepository extends BaseRepository
{
@@ -49,6 +50,8 @@ class SettingRepository extends BaseRepository
);
$result = DB::insert($sql);
do_log("sql: $sql, result: $result");
NexusDB::cache_del("nexus_settings_in_laravel");
NexusDB::cache_del("nexus_settings_in_nexus");
return $result;
}

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.7');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-30');
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.8');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-05-03');
defined('IN_TRACKER') || define('IN_TRACKER', true);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -2952,6 +2952,7 @@ function deletetorrent($id) {
foreach(array("peers", "files", "comments") as $x) {
sql_query("DELETE FROM $x WHERE torrent = ".mysql_real_escape_string($id));
}
sql_query("DELETE FROM hit_and_runs WHERE torrent_id = ".mysql_real_escape_string($id));
unlink(getFullDirectory("$torrent_dir/$id.torrent"));
}

View File

@@ -38,7 +38,8 @@ begin_main_frame("", true);
print $filterForm;
$rescount = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status)->count();
$baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status);
$rescount = (clone $baseQuery)->count();
list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, "?status=$status");
print("<table width='100%'>");
print("<tr>
@@ -54,9 +55,7 @@ print("<tr>
</tr>");
if ($rescount) {
$query = \App\Models\HitAndRun::query()
->where('uid', $userid)
->where('status', $status)
$query = (clone $baseQuery)
->with([
'torrent' => function ($query) {$query->select(['id', 'size', 'name']);},
'snatch',
@@ -74,12 +73,12 @@ if ($rescount) {
foreach($list as $row) {
print("<tr>
<td class='rowfollow nowrap' align='center'>" . $row->id . "</td>
<td class='rowfollow' align='left'><a href='details.php?id=" . $row->torrent_id . "'>" . $row->torrent->name . "</a></td>
<td class='rowfollow' align='left'><a href='details.php?id=" . $row->torrent_id . "'>" . optional($row->torrent)->name . "</a></td>
<td class='rowfollow nowrap' align='center'>" . mksize($row->snatch->uploaded) . "</td>
<td class='rowfollow nowrap' align='center'>" . mksize($row->snatch->downloaded) . "</td>
<td class='rowfollow nowrap' align='center'>" . get_hr_ratio($row->snatch->uploaded, $row->snatch->downloaded) . "</td>
<td class='rowfollow nowrap' align='center'>" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(3600 * get_setting('hr.seed_time_minimum') - $row->snatch->seedtime) : '---') . "</td>
<td class='rowfollow nowrap' align='center'>" . $row->snatch->completedat->toDateTimeString() . "</td>
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->snatch->completedat) . "</td>
<td class='rowfollow nowrap' align='center' >" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(\Carbon\Carbon::now()->diffInSeconds($row->snatch->completedat->addHours(get_setting('hr.inspect_time')))) : '---') . "</td>
<td class='rowfollow nowrap' align='left' style='padding-left: 10px'>" . nl2br($row->comment) . "</td>
</tr>");