Merge pull request #3005 from pixelfed/staging

Staging
This commit is contained in:
daniel 2021-11-10 22:39:35 -07:00 committed by GitHub
commit ec4482b02d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 10 deletions

View file

@ -6,6 +6,7 @@ use Cache;
use DB;
use App\Util\Lexer\PrettyNumber;
use App\{
Avatar,
Contact,
FailedJob,
Hashtag,
@ -31,6 +32,43 @@ class AdminStatsService
);
}
public static function storage()
{
return Cache::remember('admin:dashboard:storage:stats', 120000, function() {
$res = [];
$res['last_updated'] = now()->format('c');
$avatars = Avatar::count();
$avatarsLocal = Avatar::whereNull('cdn_url')->count();
$res['avatar'] = [
'count' => $avatars,
'local_count' => $avatarsLocal,
'cloud_count' => ($avatars - $avatarsLocal),
'total_sum' => Avatar::sum('size')
];
$media = Media::count();
$mediaSum = Media::sum('size');
$mediaLocalSum = Media::whereNotNull('user_id')->sum('size');
$mediaLocal = Media::whereNotNull('user_id')->count();
$res['media'] = [
'count' => $media,
'local_count' => $mediaLocal,
'cloud_count' => ($media - $mediaLocal),
'total_sum' => $mediaSum,
'local_sum' => $mediaLocalSum,
'local_30d' => Media::whereNotNull('user_id')->where('created_at', '>', now()->subDays(30))->sum('size'),
'cloud_30d' => Media::whereNull('user_id')->where('created_at', '>', now()->subDays(30))->sum('size'),
'cloud_sum' => ($mediaSum - $mediaLocalSum),
'avg_size' => Media::avg('size'),
'avg_mime' => Media::groupBy('mime')->orderByRaw('COUNT(*) DESC')->first()->mime,
];
return $res;
});
}
protected static function recentData()
{
$day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day(';
@ -68,8 +106,8 @@ class AdminStatsService
{
$ttl = now()->addHours(12);
return Cache::remember('admin:dashboard:home:data-postsGraph:v0.1:24hr', $ttl, function() {
$gb = config('database.default') == 'pgsql' ? ['statuses.id', DB::raw('Date(created_at)')] : DB::raw('Date(created_at)');
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count, statuses.*')
$gb = config('database.default') == 'pgsql' ? ['statuses.id', 'created_at'] : DB::raw('Date(created_at)');
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count')
->where('created_at', '>=', now()->subWeek())
->groupBy($gb)
->orderBy('created_at', 'DESC')
@ -86,7 +124,7 @@ class AdminStatsService
$dates = collect($dates)->merge($s);
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count, statuses.*')
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count')
->where('created_at', '>=', now()->subWeeks(2))
->where('created_at', '<=', now()->subWeeks(1))
->groupBy($gb)

View file

@ -5,10 +5,10 @@
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="">
<div class="card-header bg-transparent p-3 text-center font-weight-bold">{{ __('Login') }}</div>
<div class="card-header bg-transparent p-3 text-center font-weight-bold h3">{{ __('Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('login') }}" class="px-5">
<form method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group row">
@ -42,7 +42,7 @@
<div class="checkbox">
<label>
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}>
<span class="font-weight-bold small ml-1 text-muted">
<span class="font-weight-bold ml-1 text-muted">
{{ __('Remember Me') }}
</span>
</label>
@ -58,7 +58,7 @@
<div class="form-group row mb-0">
<div class="col-md-12">
<button type="submit" class="btn btn-primary btn-block py-0 font-weight-bold">
<button type="submit" class="btn btn-primary btn-block btn-lg font-weight-bold">
{{ __('Login') }}
</button>
@ -68,7 +68,7 @@
<hr>
<p class="text-center small font-weight-bold mb-0">
<p class="text-center font-weight-bold">
<a href="{{ route('password.request') }}">
{{ __('Forgot Password') }}
</a>

View file

@ -8,8 +8,8 @@
<div class="collapse navbar-collapse">
@auth
<div class="navbar-nav d-none d-md-block mx-auto">
<form class="form-inline search-bar" method="get" action="/i/results">
<input class="form-control form-control-sm rounded-pill bg-light" name="q" placeholder="{{__('navmenu.search')}}" aria-label="search" autocomplete="off" required style="line-height: 0.6;width:200px" role="search">
<form class="form-inline search-bar" method="get" action="/i/results" role="search">
<input class="form-control form-control-sm rounded-pill bg-light" name="q" placeholder="{{__('navmenu.search')}}" aria-label="search" autocomplete="off" required style="line-height: 0.6;width:200px">
</form>
</div>
@endauth