mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
perf: 优化节点后端获取用户用户列表接口响应速度,降低CPU使用资源
This commit is contained in:
parent
6d575649cf
commit
83957db37f
@ -163,7 +163,8 @@ class ServerService
|
||||
|
||||
public function getAvailableUsers($groupId)
|
||||
{
|
||||
return User::whereIn('group_id', $groupId)
|
||||
return \DB::table('v2_user')
|
||||
->whereIn('group_id', $groupId)
|
||||
->whereRaw('u + d < transfer_enable')
|
||||
->where(function ($query) {
|
||||
$query->where('expired_at', '>=', time())
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('v2_user', function (Blueprint $table) {
|
||||
$table->index(['u','d','expired_at','group_id','banned','transfer_enable']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('v2_user', function (Blueprint $table) {
|
||||
$table->dropIndex(['u','d','expired_at','group_id','banned','transfer_enable']);
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user