mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Merge pull request #2534 from pixelfed/staging
Update Profile, fix status count
This commit is contained in:
commit
c8f73c3dd9
6 changed files with 82 additions and 15 deletions
|
@ -146,6 +146,8 @@
|
|||
- Updated antispam bouncer, change recent from 1 week to 3 months. ([7d818197](https://github.com/pixelfed/pixelfed/commit/7d818197))
|
||||
- Updated Post components, fix remote post and profile urls. ([cfcf17f3](https://github.com/pixelfed/pixelfed/commit/cfcf17f3))
|
||||
- Update migrations, fix broken oauth change. ([4a885c88](https://github.com/pixelfed/pixelfed/commit/4a885c88))
|
||||
- Update LikeController, store status_profile_id and is_comment attributes. ([799a4cba](https://github.com/pixelfed/pixelfed/commit/799a4cba))
|
||||
- Updated Profile, fix status count. ([6dcd472b](https://github.com/pixelfed/pixelfed/commit/6dcd472b))
|
||||
|
||||
## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
|
||||
### Added
|
||||
|
|
56
app/Console/Commands/FixStatusCount.php
Normal file
56
app/Console/Commands/FixStatusCount.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Profile;
|
||||
|
||||
class FixStatusCount extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'fix:statuscount';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'fix profile status count';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Profile::whereNull('domain')
|
||||
->chunk(50, function($profiles) {
|
||||
foreach($profiles as $profile) {
|
||||
$profile->status_count = $profile->statuses()
|
||||
->getQuery()
|
||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||
->whereNull('in_reply_to_id')
|
||||
->whereNull('reblog_of_id')
|
||||
->count();
|
||||
$profile->save();
|
||||
}
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -210,6 +210,7 @@ class StatusController extends Controller
|
|||
}
|
||||
|
||||
Cache::forget('_api:statuses:recent_9:' . $status->profile_id);
|
||||
Cache::forget('profile:status_count:' . $status->profile_id);
|
||||
if ($status->profile_id == $user->profile->id || $user->is_admin == true) {
|
||||
Cache::forget('profile:status_count:'.$status->profile_id);
|
||||
StatusDelete::dispatch($status);
|
||||
|
|
|
@ -56,6 +56,17 @@ class StatusDelete implements ShouldQueue
|
|||
public function handle()
|
||||
{
|
||||
$status = $this->status;
|
||||
$profile = $this->status->profile;
|
||||
|
||||
$count = $profile->statuses()
|
||||
->getQuery()
|
||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||
->whereNull('in_reply_to_id')
|
||||
->whereNull('reblog_of_id')
|
||||
->count();
|
||||
|
||||
$profile->status_count = ($count - 1);
|
||||
$profile->save();
|
||||
|
||||
if(config('federation.activitypub.enabled') == true) {
|
||||
$this->fanoutDelete($status);
|
||||
|
|
|
@ -52,6 +52,17 @@ class StatusEntityLexer implements ShouldQueue
|
|||
public function handle()
|
||||
{
|
||||
$profile = $this->status->profile;
|
||||
|
||||
$count = $profile->statuses()
|
||||
->getQuery()
|
||||
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
||||
->whereNull('in_reply_to_id')
|
||||
->whereNull('reblog_of_id')
|
||||
->count();
|
||||
|
||||
$profile->status_count = $count;
|
||||
$profile->save();
|
||||
|
||||
if($profile->no_autolink == false) {
|
||||
$this->parseEntities();
|
||||
}
|
||||
|
|
|
@ -91,21 +91,7 @@ class Profile extends Model
|
|||
|
||||
public function statusCount()
|
||||
{
|
||||
return Cache::remember('profile:status_count:'.$this->id, now()->addMonths(1), function() {
|
||||
$count = $this->status_count;
|
||||
if($count) {
|
||||
return $count;
|
||||
}
|
||||
$count = $this->statuses()
|
||||
->getQuery()
|
||||
->whereHas('media')
|
||||
->whereNull('in_reply_to_id')
|
||||
->whereNull('reblog_of_id')
|
||||
->count();
|
||||
$this->status_count = $count;
|
||||
$this->save();
|
||||
return $count;
|
||||
});
|
||||
return $this->status_count;
|
||||
}
|
||||
|
||||
public function following()
|
||||
|
|
Loading…
Reference in a new issue