mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 04:53:17 +00:00
commit
9533d77b07
2 changed files with 39 additions and 6 deletions
|
@ -56,12 +56,13 @@ class MediaS3GarbageCollector extends Command
|
||||||
$limit = $this->option('limit');
|
$limit = $this->option('limit');
|
||||||
$minId = Media::orderByDesc('id')->where('created_at', '<', now()->subHours(12))->first()->id;
|
$minId = Media::orderByDesc('id')->where('created_at', '<', now()->subHours(12))->first()->id;
|
||||||
|
|
||||||
$gc = Media::whereNotNull(['status_id', 'cdn_url', 'replicated_at'])
|
$gc = Media::whereRemoteMedia(false)
|
||||||
->whereNot('version', '4')
|
->whereNotNull(['status_id', 'cdn_url', 'replicated_at'])
|
||||||
->where('id', '<', $minId)
|
->whereNot('version', '4')
|
||||||
->inRandomOrder()
|
->where('id', '<', $minId)
|
||||||
->take($limit)
|
->inRandomOrder()
|
||||||
->get();
|
->take($limit)
|
||||||
|
->get();
|
||||||
|
|
||||||
$totalSize = 0;
|
$totalSize = 0;
|
||||||
$bar = $this->output->createProgressBar($gc->count());
|
$bar = $this->output->createProgressBar($gc->count());
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('media', function (Blueprint $table) {
|
||||||
|
$table->index('remote_media');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('media', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('media_remote_media_index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue