|
|
|
@ -125,7 +125,7 @@ class Profile extends Model
|
|
|
|
|
|
|
|
|
|
public function avatarUrl()
|
|
|
|
|
{
|
|
|
|
|
$url = Cache::remember("avatar:{$this->id}", now()->addYears(1), function () {
|
|
|
|
|
$url = Cache::remember('avatar:'.$this->id, now()->addYears(1), function () {
|
|
|
|
|
$avatar = $this->avatar;
|
|
|
|
|
$path = $avatar->media_path;
|
|
|
|
|
$version = hash('sha256', $avatar->change_count);
|
|
|
|
@ -139,36 +139,20 @@ class Profile extends Model
|
|
|
|
|
|
|
|
|
|
public function statusCount()
|
|
|
|
|
{
|
|
|
|
|
return $this->statuses()
|
|
|
|
|
->getQuery()
|
|
|
|
|
->whereHas('media')
|
|
|
|
|
->whereNull('in_reply_to_id')
|
|
|
|
|
->whereNull('reblog_of_id')
|
|
|
|
|
->count();
|
|
|
|
|
return Cache::remember('profile:status_count:'.$this->id, now()->addMonths(1), function() {
|
|
|
|
|
return $this->statuses()
|
|
|
|
|
->getQuery()
|
|
|
|
|
->whereHas('media')
|
|
|
|
|
->whereNull('in_reply_to_id')
|
|
|
|
|
->whereNull('reblog_of_id')
|
|
|
|
|
->count();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// deprecated
|
|
|
|
|
public function recommendFollowers()
|
|
|
|
|
{
|
|
|
|
|
$follows = $this->following()->pluck('followers.id');
|
|
|
|
|
$following = $this->following()
|
|
|
|
|
->orderByRaw('rand()')
|
|
|
|
|
->take(3)
|
|
|
|
|
->pluck('following_id');
|
|
|
|
|
$following->push(Auth::id());
|
|
|
|
|
$following = Follower::whereNotIn('profile_id', $follows)
|
|
|
|
|
->whereNotIn('following_id', $following)
|
|
|
|
|
->whereNotIn('following_id', $follows)
|
|
|
|
|
->whereIn('profile_id', $following)
|
|
|
|
|
->orderByRaw('rand()')
|
|
|
|
|
->distinct('id')
|
|
|
|
|
->limit(3)
|
|
|
|
|
->pluck('following_id');
|
|
|
|
|
$recommended = [];
|
|
|
|
|
foreach ($following as $follow) {
|
|
|
|
|
$recommended[] = self::findOrFail($follow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $recommended;
|
|
|
|
|
return collect([]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function keyId()
|
|
|
|
|