forked from HDInnovations/UNIT3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoUnbookmarkCompletedTorrents.php
52 lines (43 loc) · 1.38 KB
/
AutoUnbookmarkCompletedTorrents.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?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 <roardom@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Console\Commands;
use App\Models\Bookmark;
use Illuminate\Console\Command;
class AutoUnbookmarkCompletedTorrents extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'auto:unbookmark_completed_torrents';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Unbookmark user torrents automatically upon completion';
/**
* Execute the console command.
*/
final public function handle(): void
{
$start = now();
$affected = Bookmark::query()
->whereRelation('userSetting', 'unbookmark_torrents_on_completion', '=', true)
->whereRelation('history', 'completed_at', '>', now()->subDay())
->delete();
$this->comment($affected.' bookmarks unbookmarked on torrent completion in '.now()->floatDiffInSeconds($start).' seconds.');
}
}