fix: history updates

Only update the history updated_at column on announces
This commit is contained in:
Roardom
2023-05-04 07:57:46 +00:00
parent 52ffba9a5f
commit 771994af31
7 changed files with 23 additions and 8 deletions
+8 -7
View File
@@ -17,6 +17,7 @@ use App\Models\History;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Exception;
use Illuminate\Support\Facades\DB;
/**
* @see \Tests\Unit\Console\Commands\AutoCorrectHistoryTest
@@ -44,13 +45,13 @@ class AutoCorrectHistory extends Command
*/
public function handle(): void
{
$carbon = new Carbon();
$history = History::select(['id', 'active', 'updated_at'])->where('active', '=', 1)->where('updated_at', '<', $carbon->copy()->subHours(2)->toDateTimeString())->get();
foreach ($history as $h) {
$h->active = false;
$h->save();
}
History::select(['id', 'active', 'updated_at'])
->where('active', '=', 1)
->where('updated_at', '<', Carbon::now()->subHours(2)->toDateTimeString())
->update([
'active' => 0,
'updated_at' => DB::raw('updated_at'),
]);
$this->comment('Automated History Record Correction Command Complete');
}
+1
View File
@@ -52,6 +52,7 @@ class AutoFlushPeers extends Command
$history = History::where('torrent_id', '=', $peer->torrent_id)->where('user_id', '=', $peer->user_id)->first();
if ($history) {
$history->active = false;
$history->timestamps = false;
$history->save();
}
+1
View File
@@ -79,6 +79,7 @@ class AutoPreWarning extends Command
// Set History Prewarn
$pre->prewarn = 1;
$pre->timestamps = false;
$pre->save();
}
}
+1
View File
@@ -85,6 +85,7 @@ class AutoWarning extends Command
// Send Notifications
$hr->user->notify(new UserWarning($hr->user, $hr->torrent));
$hr->timestamps = false;
$hr->save();
}
}
@@ -48,6 +48,7 @@ class FlushController extends Controller
$history = History::where('torrent_id', '=', $peer->torrent_id)->where('user_id', '=', $peer->user_id)->first();
if ($history) {
$history->active = false;
$history->timestamps = false;
$history->save();
}
+5 -1
View File
@@ -63,8 +63,12 @@ class PeerController extends Controller
->delete();
$user->history()
->where('active', '=', 1)
->where('updated_at', '<', $cutoff)
->update(['active' => false]);
->update([
'active' => 0,
'updated_at' => DB::raw('updated_at'),
]);
$user->own_flushes--;
@@ -48,6 +48,7 @@
<th>{{ __('common.download') }}</th>
<th>{{ __('common.added') }}</th>
<th>{{ __('torrent.last-update') }}</th>
<th>{{ __('torrent.completed_at') }}</th>
<th>{{ __('torrent.seedtime') }}</th>
</tr>
</thead>
@@ -98,6 +99,11 @@
{{ $history->updated_at ? $history->updated_at->diffForHumans() : 'N/A' }}
</time>
</td>
<td>
<time datetime="{{ $history->completed_at }}" title="{{ $history->completed_at }}">
{{ $history->completed_at ? $history->completed_at->diffForHumans() : 'N/A' }}
</time>
</td>
@if ($history->seedtime < config('hitrun.seedtime'))
<td class="text-red">{{ App\Helpers\StringHelper::timeElapsed($history->seedtime) }}</td>
@else