mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-24 08:44:02 +00:00
Fix custom emoji admin dashboard bug
This commit is contained in:
parent
46d5f12590
commit
1e00c431a8
1 changed files with 18 additions and 5 deletions
|
@ -369,9 +369,15 @@ class AdminController extends Controller
|
||||||
return redirect(route('admin.custom-emoji'));
|
return redirect(route('admin.custom-emoji'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$emojis = CustomEmoji::when($sort, function($query, $sort) use($request) {
|
$pg = config('database.default') == 'pgsql';
|
||||||
|
|
||||||
|
$emojis = CustomEmoji::when($sort, function($query, $sort) use($request, $pg) {
|
||||||
if($sort == 'all') {
|
if($sort == 'all') {
|
||||||
return $query->groupBy('shortcode')->latest();
|
if($pg) {
|
||||||
|
return $query->latest();
|
||||||
|
} else {
|
||||||
|
return $query->groupBy('shortcode')->latest();
|
||||||
|
}
|
||||||
} else if($sort == 'local') {
|
} else if($sort == 'local') {
|
||||||
return $query->latest()->where('domain', '=', config('pixelfed.domain.app'));
|
return $query->latest()->where('domain', '=', config('pixelfed.domain.app'));
|
||||||
} else if($sort == 'remote') {
|
} else if($sort == 'remote') {
|
||||||
|
@ -394,13 +400,20 @@ class AdminController extends Controller
|
||||||
->simplePaginate(10)
|
->simplePaginate(10)
|
||||||
->withQueryString();
|
->withQueryString();
|
||||||
|
|
||||||
$stats = Cache::remember('pf:admin:custom_emoji:stats', 43200, function() {
|
$stats = Cache::remember('pf:admin:custom_emoji:stats', 43200, function() use($pg) {
|
||||||
return [
|
$res = [
|
||||||
'total' => CustomEmoji::count(),
|
'total' => CustomEmoji::count(),
|
||||||
'active' => CustomEmoji::whereDisabled(false)->count(),
|
'active' => CustomEmoji::whereDisabled(false)->count(),
|
||||||
'remote' => CustomEmoji::where('domain', '!=', config('pixelfed.domain.app'))->count(),
|
'remote' => CustomEmoji::where('domain', '!=', config('pixelfed.domain.app'))->count(),
|
||||||
'duplicate' => CustomEmoji::groupBy('shortcode')->havingRaw('count(*) > 1')->count()
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if($pg) {
|
||||||
|
$res['duplicate'] = CustomEmoji::select('shortcode')->groupBy('shortcode')->havingRaw('count(*) > 1')->count();
|
||||||
|
} else {
|
||||||
|
$res['duplicate'] = CustomEmoji::groupBy('shortcode')->havingRaw('count(*) > 1')->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
});
|
});
|
||||||
|
|
||||||
return view('admin.custom-emoji.home', compact('emojis', 'sort', 'stats'));
|
return view('admin.custom-emoji.home', compact('emojis', 'sort', 'stats'));
|
||||||
|
|
Loading…
Reference in a new issue