Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/BountyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function store(StoreTorrentRequestBountyRequest $request, TorrentRequest

$torrentRequest->increment('bounty', $request->integer('seedbonus'));

$torrentRequest->created_at = now();
$torrentRequest->last_bountied_at = now();
$torrentRequest->save();

if ($request->boolean('anon') == 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/TorrentRequestSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class TorrentRequestSearch extends Component
public int $perPage = 25;

#[Url(history: true)]
public string $sortField = 'created_at';
public string $sortField = 'last_bountied_at';

#[Url(history: true)]
public string $sortDirection = 'desc';
Expand Down
16 changes: 9 additions & 7 deletions app/Models/TorrentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @property bool $anon
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $last_bountied_at
* @property int|null $filled_by
* @property int|null $torrent_id
* @property \Illuminate\Support\Carbon|null $filled_when
Expand Down Expand Up @@ -86,13 +87,14 @@ class TorrentRequest extends Model
protected function casts(): array
{
return [
'filled_when' => 'datetime',
'approved_when' => 'datetime',
'tmdb_movie_id' => 'int',
'tmdb_tv_id' => 'int',
'igdb' => 'int',
'bounty' => 'decimal:2',
'anon' => 'bool',
'filled_when' => 'datetime',
'approved_when' => 'datetime',
'last_bountied_at' => 'datetime',
'tmdb_movie_id' => 'int',
'tmdb_tv_id' => 'int',
'igdb' => 'int',
'bounty' => 'decimal:2',
'anon' => 'bool',
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('requests', function (Blueprint $table): void {
$table->timestamp('last_bountied_at')->after('updated_at')->index();
});

DB::table('requests')
->join('request_bounty', 'requests_id', '=', 'requests.id')
->groupBy('requests.id')
->update([
'requests.created_at' => DB::raw('MIN(request_bounty.created_at)'),
'requests.last_bountied_at' => DB::raw('MAX(request_bounty.created_at)'),
]);
}
};
10 changes: 5 additions & 5 deletions resources/views/livewire/torrent-request-search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ class="form__button form__button--text"
<i class="{{ config('other.font-awesome') }} fa-coins"></i>
@include('livewire.includes._sort-icon', ['field' => 'bounty'])
</th>
<th wire:click="sortBy('created_at')" role="columnheader button">
<th wire:click="sortBy('last_bountied_at')" role="columnheader button">
{{ __('common.created_at') }}
@include('livewire.includes._sort-icon', ['field' => 'created_at'])
@include('livewire.includes._sort-icon', ['field' => 'last_bountied_at'])
</th>
<th>{{ __('common.status') }}</th>
</tr>
Expand Down Expand Up @@ -367,10 +367,10 @@ class="form__button form__button--text"
<td>{{ number_format($torrentRequest->bounty) }}</td>
<td>
<time
datetime="{{ $torrentRequest->created_at }}"
title="{{ $torrentRequest->created_at }}"
datetime="{{ $torrentRequest->last_bountied_at }}"
title="{{ $torrentRequest->last_bountied_at }}"
>
{{ $torrentRequest->created_at->diffForHumans() }}
{{ $torrentRequest->last_bountied_at->diffForHumans() }}
</time>
</td>
<td>
Expand Down
Loading