mirror of https://github.com/pixelfed/pixelfed.git
Update AdminApiController
This commit is contained in:
parent
0aafb863e8
commit
a9f24f85da
|
@ -2,39 +2,34 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use App\AccountInterstitial;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\AdminInstance;
|
||||||
|
use App\Http\Resources\AdminUser;
|
||||||
|
use App\Instance;
|
||||||
|
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
||||||
|
use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline;
|
||||||
use App\Jobs\StatusPipeline\StatusDelete;
|
use App\Jobs\StatusPipeline\StatusDelete;
|
||||||
use Auth, Cache, DB;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use App\{
|
|
||||||
AccountInterstitial,
|
|
||||||
Instance,
|
|
||||||
Like,
|
|
||||||
Notification,
|
|
||||||
Media,
|
|
||||||
Profile,
|
|
||||||
Report,
|
|
||||||
Status,
|
|
||||||
User
|
|
||||||
};
|
|
||||||
use App\Models\Conversation;
|
use App\Models\Conversation;
|
||||||
use App\Models\RemoteReport;
|
use App\Models\RemoteReport;
|
||||||
|
use App\Notification;
|
||||||
|
use App\Profile;
|
||||||
|
use App\Report;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
use App\Services\AdminStatsService;
|
use App\Services\AdminStatsService;
|
||||||
use App\Services\ConfigCacheService;
|
use App\Services\ConfigCacheService;
|
||||||
use App\Services\InstanceService;
|
use App\Services\InstanceService;
|
||||||
use App\Services\ModLogService;
|
use App\Services\ModLogService;
|
||||||
use App\Services\SnowflakeService;
|
|
||||||
use App\Services\StatusService;
|
|
||||||
use App\Services\PublicTimelineService;
|
|
||||||
use App\Services\NetworkTimelineService;
|
use App\Services\NetworkTimelineService;
|
||||||
use App\Services\NotificationService;
|
use App\Services\NotificationService;
|
||||||
use App\Http\Resources\AdminInstance;
|
use App\Services\PublicTimelineService;
|
||||||
use App\Http\Resources\AdminUser;
|
use App\Services\SnowflakeService;
|
||||||
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
use App\Services\StatusService;
|
||||||
use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline;
|
use App\Status;
|
||||||
use App\Jobs\DeletePipeline\DeleteRemoteStatusPipeline;
|
use App\User;
|
||||||
|
use Cache;
|
||||||
|
use DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class AdminApiController extends Controller
|
class AdminApiController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -59,6 +54,7 @@ class AdminApiController extends Controller
|
||||||
$res['autospam_count'] = AccountInterstitial::whereType('post.autospam')
|
$res['autospam_count'] = AccountInterstitial::whereType('post.autospam')
|
||||||
->whereNull('appeal_handled_at')
|
->whereNull('appeal_handled_at')
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +75,7 @@ class AdminApiController extends Controller
|
||||||
'type' => $report->type,
|
'type' => $report->type,
|
||||||
'item_id' => $report->item_id,
|
'item_id' => $report->item_id,
|
||||||
'item_type' => $report->item_type,
|
'item_type' => $report->item_type,
|
||||||
'created_at' => $report->created_at
|
'created_at' => $report->created_at,
|
||||||
];
|
];
|
||||||
if ($report->item_type === 'App\\Status') {
|
if ($report->item_type === 'App\\Status') {
|
||||||
$status = StatusService::get($report->item_id, false);
|
$status = StatusService::get($report->item_id, false);
|
||||||
|
@ -93,6 +89,7 @@ class AdminApiController extends Controller
|
||||||
$r['parent'] = StatusService::get($status['in_reply_to_id'], false);
|
$r['parent'] = StatusService::get($status['in_reply_to_id'], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -108,7 +105,7 @@ class AdminApiController extends Controller
|
||||||
|
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'action' => 'required|in:dismiss,approve,dismiss-all,approve-all,delete-post,delete-account',
|
'action' => 'required|in:dismiss,approve,dismiss-all,approve-all,delete-post,delete-account',
|
||||||
'id' => 'required'
|
'id' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$action = $request->input('action');
|
$action = $request->input('action');
|
||||||
|
@ -130,6 +127,7 @@ class AdminApiController extends Controller
|
||||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$profile->id);
|
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$profile->id);
|
||||||
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$profile->id);
|
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$profile->id);
|
||||||
Cache::forget('admin-dash:reports:spam-count');
|
Cache::forget('admin-dash:reports:spam-count');
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +146,7 @@ class AdminApiController extends Controller
|
||||||
PublicTimelineService::deleteByProfileId($profile->id);
|
PublicTimelineService::deleteByProfileId($profile->id);
|
||||||
StatusDelete::dispatch($appeal->status)->onQueue('high');
|
StatusDelete::dispatch($appeal->status)->onQueue('high');
|
||||||
Cache::forget('admin-dash:reports:spam-count');
|
Cache::forget('admin-dash:reports:spam-count');
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +166,7 @@ class AdminApiController extends Controller
|
||||||
PublicTimelineService::deleteByProfileId($profile->id);
|
PublicTimelineService::deleteByProfileId($profile->id);
|
||||||
DeleteAccountPipeline::dispatch($appeal->user)->onQueue('high');
|
DeleteAccountPipeline::dispatch($appeal->user)->onQueue('high');
|
||||||
Cache::forget('admin-dash:reports:spam-count');
|
Cache::forget('admin-dash:reports:spam-count');
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +179,7 @@ class AdminApiController extends Controller
|
||||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$appeal->user->profile_id);
|
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$appeal->user->profile_id);
|
||||||
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$appeal->user->profile_id);
|
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$appeal->user->profile_id);
|
||||||
Cache::forget('admin-dash:reports:spam-count');
|
Cache::forget('admin-dash:reports:spam-count');
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +207,7 @@ class AdminApiController extends Controller
|
||||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$appeal->user->profile_id);
|
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$appeal->user->profile_id);
|
||||||
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$appeal->user->profile_id);
|
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$appeal->user->profile_id);
|
||||||
Cache::forget('admin-dash:reports:spam-count');
|
Cache::forget('admin-dash:reports:spam-count');
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +241,7 @@ class AdminApiController extends Controller
|
||||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$appeal->user->profile_id);
|
Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$appeal->user->profile_id);
|
||||||
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$appeal->user->profile_id);
|
Cache::forget('pf:bouncer_v0:recent_by_pid:'.$appeal->user->profile_id);
|
||||||
Cache::forget('admin-dash:reports:spam-count');
|
Cache::forget('admin-dash:reports:spam-count');
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +265,7 @@ class AdminApiController extends Controller
|
||||||
'message' => $report->message,
|
'message' => $report->message,
|
||||||
'object_id' => $report->object_id,
|
'object_id' => $report->object_id,
|
||||||
'object_type' => $report->object_type,
|
'object_type' => $report->object_type,
|
||||||
'created_at' => $report->created_at
|
'created_at' => $report->created_at,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($report->profile_id) {
|
if ($report->profile_id) {
|
||||||
|
@ -283,11 +286,12 @@ class AdminApiController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($report->object_type === 'App\\Profile') {
|
if ($report->object_type === 'App\\Profile') {
|
||||||
$acct = AccountService::get($report->object_id, false);
|
$acct = AccountService::get($report->object_id, true);
|
||||||
if ($acct) {
|
if ($acct) {
|
||||||
$r['account'] = $acct;
|
$r['account'] = $acct;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
})
|
})
|
||||||
->filter()
|
->filter()
|
||||||
|
@ -305,7 +309,7 @@ class AdminApiController extends Controller
|
||||||
|
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'action' => 'required|string',
|
'action' => 'required|string',
|
||||||
'id' => 'required'
|
'id' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$action = $request->input('action');
|
$action = $request->input('action');
|
||||||
|
@ -314,7 +318,7 @@ class AdminApiController extends Controller
|
||||||
$actions = [
|
$actions = [
|
||||||
'ignore',
|
'ignore',
|
||||||
'cw',
|
'cw',
|
||||||
'unlist'
|
'unlist',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (! in_array($action, $actions)) {
|
if (! in_array($action, $actions)) {
|
||||||
|
@ -369,35 +373,36 @@ class AdminApiController extends Controller
|
||||||
[
|
[
|
||||||
'name' => 'ActivityPub Federation',
|
'name' => 'ActivityPub Federation',
|
||||||
'description' => 'Enable activitypub federation support, compatible with Pixelfed, Mastodon and other platforms.',
|
'description' => 'Enable activitypub federation support, compatible with Pixelfed, Mastodon and other platforms.',
|
||||||
'key' => 'federation.activitypub.enabled'
|
'key' => 'federation.activitypub.enabled',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'Open Registration',
|
'name' => 'Open Registration',
|
||||||
'description' => 'Allow new account registrations.',
|
'description' => 'Allow new account registrations.',
|
||||||
'key' => 'pixelfed.open_registration'
|
'key' => 'pixelfed.open_registration',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'Stories',
|
'name' => 'Stories',
|
||||||
'description' => 'Enable the ephemeral Stories feature.',
|
'description' => 'Enable the ephemeral Stories feature.',
|
||||||
'key' => 'instance.stories.enabled'
|
'key' => 'instance.stories.enabled',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'Require Email Verification',
|
'name' => 'Require Email Verification',
|
||||||
'description' => 'Require new accounts to verify their email address.',
|
'description' => 'Require new accounts to verify their email address.',
|
||||||
'key' => 'pixelfed.enforce_email_verification'
|
'key' => 'pixelfed.enforce_email_verification',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'AutoSpam Detection',
|
'name' => 'AutoSpam Detection',
|
||||||
'description' => 'Detect and remove spam from public timelines.',
|
'description' => 'Detect and remove spam from public timelines.',
|
||||||
'key' => 'pixelfed.bouncer.enabled'
|
'key' => 'pixelfed.bouncer.enabled',
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->map(function ($s) {
|
->map(function ($s) {
|
||||||
$s['state'] = (bool) config_cache($s['key']);
|
$s['state'] = (bool) config_cache($s['key']);
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -413,7 +418,7 @@ class AdminApiController extends Controller
|
||||||
|
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'key' => 'required',
|
'key' => 'required',
|
||||||
'value' => 'required'
|
'value' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$allowedKeys = [
|
$allowedKeys = [
|
||||||
|
@ -434,35 +439,36 @@ class AdminApiController extends Controller
|
||||||
[
|
[
|
||||||
'name' => 'ActivityPub Federation',
|
'name' => 'ActivityPub Federation',
|
||||||
'description' => 'Enable activitypub federation support, compatible with Pixelfed, Mastodon and other platforms.',
|
'description' => 'Enable activitypub federation support, compatible with Pixelfed, Mastodon and other platforms.',
|
||||||
'key' => 'federation.activitypub.enabled'
|
'key' => 'federation.activitypub.enabled',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'Open Registration',
|
'name' => 'Open Registration',
|
||||||
'description' => 'Allow new account registrations.',
|
'description' => 'Allow new account registrations.',
|
||||||
'key' => 'pixelfed.open_registration'
|
'key' => 'pixelfed.open_registration',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'Stories',
|
'name' => 'Stories',
|
||||||
'description' => 'Enable the ephemeral Stories feature.',
|
'description' => 'Enable the ephemeral Stories feature.',
|
||||||
'key' => 'instance.stories.enabled'
|
'key' => 'instance.stories.enabled',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'Require Email Verification',
|
'name' => 'Require Email Verification',
|
||||||
'description' => 'Require new accounts to verify their email address.',
|
'description' => 'Require new accounts to verify their email address.',
|
||||||
'key' => 'pixelfed.enforce_email_verification'
|
'key' => 'pixelfed.enforce_email_verification',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => 'AutoSpam Detection',
|
'name' => 'AutoSpam Detection',
|
||||||
'description' => 'Detect and remove spam from public timelines.',
|
'description' => 'Detect and remove spam from public timelines.',
|
||||||
'key' => 'pixelfed.bouncer.enabled'
|
'key' => 'pixelfed.bouncer.enabled',
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->map(function ($s) {
|
->map(function ($s) {
|
||||||
$s['state'] = (bool) config_cache($s['key']);
|
$s['state'] = (bool) config_cache($s['key']);
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -485,6 +491,7 @@ class AdminApiController extends Controller
|
||||||
})
|
})
|
||||||
->orderBy('id', $sort)
|
->orderBy('id', $sort)
|
||||||
->cursorPaginate(10);
|
->cursorPaginate(10);
|
||||||
|
|
||||||
return AdminUser::collection($res);
|
return AdminUser::collection($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +507,7 @@ class AdminApiController extends Controller
|
||||||
if ($request->has('refresh')) {
|
if ($request->has('refresh')) {
|
||||||
Cache::forget($key);
|
Cache::forget($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Cache::remember($key, 86400, function () use ($id) {
|
return Cache::remember($key, 86400, function () use ($id) {
|
||||||
$user = User::findOrFail($id);
|
$user = User::findOrFail($id);
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
|
@ -513,8 +521,8 @@ class AdminApiController extends Controller
|
||||||
'moderation' => [
|
'moderation' => [
|
||||||
'unlisted' => (bool) $profile->unlisted,
|
'unlisted' => (bool) $profile->unlisted,
|
||||||
'cw' => (bool) $profile->cw,
|
'cw' => (bool) $profile->cw,
|
||||||
'no_autolink' => (bool) $profile->no_autolink
|
'no_autolink' => (bool) $profile->no_autolink,
|
||||||
]
|
],
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -531,7 +539,7 @@ class AdminApiController extends Controller
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'id' => 'required',
|
'id' => 'required',
|
||||||
'action' => 'required|in:unlisted,cw,no_autolink,refresh_stats,verify_email,delete',
|
'action' => 'required|in:unlisted,cw,no_autolink,refresh_stats,verify_email,delete',
|
||||||
'value' => 'sometimes'
|
'value' => 'sometimes',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$id = $request->input('id');
|
$id = $request->input('id');
|
||||||
|
@ -589,6 +597,7 @@ class AdminApiController extends Controller
|
||||||
AccountService::del($profile->id);
|
AccountService::del($profile->id);
|
||||||
DeleteRemoteProfilePipeline::dispatch($profile)->onQueue('high');
|
DeleteRemoteProfilePipeline::dispatch($profile)->onQueue('high');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'status' => 200,
|
'status' => 200,
|
||||||
'msg' => 'deleted',
|
'msg' => 'deleted',
|
||||||
|
@ -615,7 +624,7 @@ class AdminApiController extends Controller
|
||||||
->action('admin.user.moderate')
|
->action('admin.user.moderate')
|
||||||
->metadata([
|
->metadata([
|
||||||
'action' => 'Manually verified email address',
|
'action' => 'Manually verified email address',
|
||||||
'message' => 'Success!'
|
'message' => 'Success!',
|
||||||
])
|
])
|
||||||
->accessLevel('admin')
|
->accessLevel('admin')
|
||||||
->save();
|
->save();
|
||||||
|
@ -628,7 +637,7 @@ class AdminApiController extends Controller
|
||||||
->action('admin.user.moderate')
|
->action('admin.user.moderate')
|
||||||
->metadata([
|
->metadata([
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'message' => 'Success!'
|
'message' => 'Success!',
|
||||||
])
|
])
|
||||||
->accessLevel('admin')
|
->accessLevel('admin')
|
||||||
->save();
|
->save();
|
||||||
|
@ -643,7 +652,7 @@ class AdminApiController extends Controller
|
||||||
->action('admin.user.moderate')
|
->action('admin.user.moderate')
|
||||||
->metadata([
|
->metadata([
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'message' => 'Success!'
|
'message' => 'Success!',
|
||||||
])
|
])
|
||||||
->accessLevel('admin')
|
->accessLevel('admin')
|
||||||
->save();
|
->save();
|
||||||
|
@ -658,7 +667,7 @@ class AdminApiController extends Controller
|
||||||
->action('admin.user.moderate')
|
->action('admin.user.moderate')
|
||||||
->metadata([
|
->metadata([
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'message' => 'Success!'
|
'message' => 'Success!',
|
||||||
])
|
])
|
||||||
->accessLevel('admin')
|
->accessLevel('admin')
|
||||||
->save();
|
->save();
|
||||||
|
@ -676,7 +685,7 @@ class AdminApiController extends Controller
|
||||||
->action('admin.user.moderate')
|
->action('admin.user.moderate')
|
||||||
->metadata([
|
->metadata([
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'message' => 'Success!'
|
'message' => 'Success!',
|
||||||
])
|
])
|
||||||
->accessLevel('admin')
|
->accessLevel('admin')
|
||||||
->save();
|
->save();
|
||||||
|
@ -690,8 +699,8 @@ class AdminApiController extends Controller
|
||||||
'moderation' => [
|
'moderation' => [
|
||||||
'unlisted' => (bool) $profile->unlisted,
|
'unlisted' => (bool) $profile->unlisted,
|
||||||
'cw' => (bool) $profile->cw,
|
'cw' => (bool) $profile->cw,
|
||||||
'no_autolink' => (bool) $profile->no_autolink
|
'no_autolink' => (bool) $profile->no_autolink,
|
||||||
]
|
],
|
||||||
]]);
|
]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,7 +767,7 @@ class AdminApiController extends Controller
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'id' => 'required',
|
'id' => 'required',
|
||||||
'key' => 'required|in:unlisted,auto_cw,banned',
|
'key' => 'required|in:unlisted,auto_cw,banned',
|
||||||
'value' => 'required'
|
'value' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$id = $request->input('id');
|
$id = $request->input('id');
|
||||||
|
@ -819,28 +828,28 @@ class AdminApiController extends Controller
|
||||||
'date' => now()->subDays($day)->format('M j Y'),
|
'date' => now()->subDays($day)->format('M j Y'),
|
||||||
'label_full' => $label,
|
'label_full' => $label,
|
||||||
'label' => $labelShort,
|
'label' => $labelShort,
|
||||||
'count' => User::whereDate('created_at', now()->subDays($day))->count()
|
'count' => User::whereDate('created_at', now()->subDays($day))->count(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$res['posts']['days'][] = [
|
$res['posts']['days'][] = [
|
||||||
'date' => now()->subDays($day)->format('M j Y'),
|
'date' => now()->subDays($day)->format('M j Y'),
|
||||||
'label_full' => $label,
|
'label_full' => $label,
|
||||||
'label' => $labelShort,
|
'label' => $labelShort,
|
||||||
'count' => Status::whereNull('uri')->where('id', '>', $minStatusId)->whereDate('created_at', now()->subDays($day))->count()
|
'count' => Status::whereNull('uri')->where('id', '>', $minStatusId)->whereDate('created_at', now()->subDays($day))->count(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$res['instances']['days'][] = [
|
$res['instances']['days'][] = [
|
||||||
'date' => now()->subDays($day)->format('M j Y'),
|
'date' => now()->subDays($day)->format('M j Y'),
|
||||||
'label_full' => $label,
|
'label_full' => $label,
|
||||||
'label' => $labelShort,
|
'label' => $labelShort,
|
||||||
'count' => Instance::whereDate('created_at', now()->subDays($day))->count()
|
'count' => Instance::whereDate('created_at', now()->subDays($day))->count(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$res['users']['total'] = DB::table('users')->count();
|
$res['users']['total'] = DB::table('users')->count();
|
||||||
$res['users']['min'] = collect($res['users']['days'])->min('count');
|
$res['users']['min'] = collect($res['users']['days'])->min('count');
|
||||||
$res['users']['max'] = collect($res['users']['days'])->max('count');
|
$res['users']['max'] = collect($res['users']['days'])->max('count');
|
||||||
$res['users']['change'] = collect($res['users']['days'])->sum('count');;
|
$res['users']['change'] = collect($res['users']['days'])->sum('count');
|
||||||
$res['posts']['total'] = DB::table('statuses')->whereNull('uri')->count();
|
$res['posts']['total'] = DB::table('statuses')->whereNull('uri')->count();
|
||||||
$res['posts']['min'] = collect($res['posts']['days'])->min('count');
|
$res['posts']['min'] = collect($res['posts']['days'])->min('count');
|
||||||
$res['posts']['max'] = collect($res['posts']['days'])->max('count');
|
$res['posts']['max'] = collect($res['posts']['days'])->max('count');
|
||||||
|
|
Loading…
Reference in New Issue