mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
fix: sqlite stats queue and admin login redirect
Some checks are pending
Docker Build and Publish / build (push) Waiting to run
Some checks are pending
Docker Build and Publish / build (push) Waiting to run
This commit is contained in:
parent
ed43ffc3f5
commit
70998d0c08
@ -52,21 +52,28 @@ class StatServerJob implements ShouldQueue
|
||||
$u += $traffic[0];
|
||||
$d += $traffic[1];
|
||||
}
|
||||
|
||||
// Update or create traffic stats
|
||||
DB::transaction(function () use ($u, $d, $recordAt) {
|
||||
StatServer::updateOrCreate(
|
||||
[
|
||||
$stat = StatServer::lockForUpdate()
|
||||
->where('record_at', $recordAt)
|
||||
->where('server_id', $this->server['id'])
|
||||
->where('server_type', $this->protocol)
|
||||
->where('record_type', $this->recordType)
|
||||
->first();
|
||||
|
||||
if ($stat) {
|
||||
$stat->u += $u;
|
||||
$stat->d += $d;
|
||||
$stat->save();
|
||||
} else {
|
||||
StatServer::create([
|
||||
'record_at' => $recordAt,
|
||||
'server_id' => $this->server['id'],
|
||||
'server_type' => $this->protocol,
|
||||
'record_type' => $this->recordType,
|
||||
],
|
||||
[
|
||||
'u' => DB::raw("COALESCE(u, 0) + $u"),
|
||||
'd' => DB::raw("COALESCE(d, 0) + $d"),
|
||||
]
|
||||
);
|
||||
'u' => $u,
|
||||
'd' => $d,
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -47,19 +47,30 @@ class StatUserJob implements ShouldQueue
|
||||
: strtotime(date('Y-m-d'));
|
||||
|
||||
foreach ($this->data as $uid => $v) {
|
||||
StatUser::updateOrCreate(
|
||||
[
|
||||
'user_id' => $uid,
|
||||
'server_rate' => $this->server['rate'],
|
||||
'record_at' => $recordAt,
|
||||
'record_type' => $this->recordType,
|
||||
],
|
||||
[
|
||||
'u' => DB::raw('COALESCE(u, 0) + ' . ($v[0] * $this->server['rate'])),
|
||||
'd' => DB::raw('COALESCE(d, 0) + ' . ($v[1] * $this->server['rate'])),
|
||||
't' => time(),
|
||||
]
|
||||
);
|
||||
DB::transaction(function () use ($uid, $v, $recordAt) {
|
||||
$stat = StatUser::lockForUpdate()
|
||||
->where('user_id', $uid)
|
||||
->where('server_rate', $this->server['rate'])
|
||||
->where('record_at', $recordAt)
|
||||
->where('record_type', $this->recordType)
|
||||
->first();
|
||||
if ($stat) {
|
||||
$stat->u += ($v[0] * $this->server['rate']);
|
||||
$stat->d += ($v[1] * $this->server['rate']);
|
||||
$stat->t = time();
|
||||
$stat->save();
|
||||
} else {
|
||||
StatUser::create([
|
||||
'user_id' => $uid,
|
||||
'server_rate' => $this->server['rate'],
|
||||
'record_at' => $recordAt,
|
||||
'record_type' => $this->recordType,
|
||||
'u' => ($v[0] * $this->server['rate']),
|
||||
'd' => ($v[1] * $this->server['rate']),
|
||||
't' => time(),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
2
public/assets/admin/assets/index.js
vendored
2
public/assets/admin/assets/index.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user