mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-09 13:50:44 +00:00
Merge pull request #1595 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
674971f67e
3 changed files with 70 additions and 4 deletions
62
app/Console/Commands/StatusDedupe.php
Normal file
62
app/Console/Commands/StatusDedupe.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use App\Status;
|
||||||
|
use DB;
|
||||||
|
use App\Jobs\StatusPipeline\StatusDelete;
|
||||||
|
|
||||||
|
class StatusDedupe extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'status:dedup';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Removes duplicate statuses from before unique uri migration';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
DB::table('statuses')
|
||||||
|
->selectRaw('id, uri, count(uri) as occurences')
|
||||||
|
->whereNotNull('uri')
|
||||||
|
->groupBy('uri')
|
||||||
|
->orderBy('created_at')
|
||||||
|
->having('occurences', '>', 1)
|
||||||
|
->chunk(50, function($statuses) {
|
||||||
|
foreach($statuses as $status) {
|
||||||
|
$this->info("Found duplicate: $status->uri");
|
||||||
|
Status::whereUri($status->uri)
|
||||||
|
->where('id', '!=', $status->id)
|
||||||
|
->get()
|
||||||
|
->map(function($status) {
|
||||||
|
$this->info("Deleting Duplicate ID: $status->id");
|
||||||
|
StatusDelete::dispatch($status);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -89,8 +89,12 @@ class FollowerController extends Controller
|
||||||
}
|
}
|
||||||
FollowPipeline::dispatch($follower);
|
FollowPipeline::dispatch($follower);
|
||||||
} else {
|
} else {
|
||||||
$follower = Follower::whereProfileId($user->id)->whereFollowingId($target->id)->firstOrFail();
|
$request = FollowRequest::whereFollowerId($user->id)->whereFollowingId($target->id)->exists();
|
||||||
if($remote == true) {
|
$follower = Follower::whereProfileId($user->id)->whereFollowingId($target->id)->exists();
|
||||||
|
if($remote == true && $request && !$follower) {
|
||||||
|
$this->sendFollow($user, $target);
|
||||||
|
}
|
||||||
|
if($remote == true && $follower) {
|
||||||
$this->sendUndoFollow($user, $target);
|
$this->sendUndoFollow($user, $target);
|
||||||
}
|
}
|
||||||
$follower->delete();
|
$follower->delete();
|
||||||
|
|
|
@ -220,7 +220,7 @@ class Helpers {
|
||||||
$id = (int) last(explode('/', $url));
|
$id = (int) last(explode('/', $url));
|
||||||
return Status::findOrFail($id);
|
return Status::findOrFail($id);
|
||||||
} else {
|
} else {
|
||||||
$cached = Status::whereUrl($url)->first();
|
$cached = Status::whereUri($url)->orWhere('url', $url)->first();
|
||||||
if($cached) {
|
if($cached) {
|
||||||
return $cached;
|
return $cached;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue