feature: main page - ranking list
This commit is contained in:
@@ -115,8 +115,13 @@ class UserService implements UserServiceInterface
|
||||
->whereColumn('msnv', 'user.msnv')
|
||||
->whereBetween('date', [$startOfMonth, $endOfMonth])
|
||||
])
|
||||
->orderByDesc('score')
|
||||
->get();
|
||||
->get()
|
||||
->filter(fn($u) => $u->score > 0)
|
||||
->sortBy([
|
||||
['score', 'desc'],
|
||||
['msnv', 'asc']
|
||||
])
|
||||
->values();
|
||||
|
||||
$currentRank = 0;
|
||||
$prevScore = null;
|
||||
@@ -157,8 +162,13 @@ class UserService implements UserServiceInterface
|
||||
->whereColumn('msnv', 'user.msnv')
|
||||
->whereBetween('date', [$startOfMonth, $endOfMonth])
|
||||
])
|
||||
->orderByDesc('score')
|
||||
->get();
|
||||
->get()
|
||||
->filter(fn($u) => $u->score > 0)
|
||||
->sortBy([
|
||||
['score', 'desc'],
|
||||
['msnv', 'asc']
|
||||
])
|
||||
->values();
|
||||
|
||||
$prevScore = null;
|
||||
$rank = 1;
|
||||
@@ -181,15 +191,23 @@ class UserService implements UserServiceInterface
|
||||
$currentUserRankItem = $userItem;
|
||||
}
|
||||
|
||||
if ($index < 5) {
|
||||
if ($index < 4) {
|
||||
$rankers[] = $userItem;
|
||||
}
|
||||
$rank++;
|
||||
}
|
||||
|
||||
$showCurrentUserAtBottom = false;
|
||||
if ($currentUserRankItem) {
|
||||
$currentUserIndex = $users->search(fn($u) => $u->msnv == $currentUser->msnv);
|
||||
if ($currentUserIndex !== false && $currentUserIndex >= 4) {
|
||||
$showCurrentUserAtBottom = true;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'rankers' => $rankers,
|
||||
'currentUserRankItem' => $currentUserRankItem
|
||||
'currentUserRankItem' => $showCurrentUserAtBottom ? $currentUserRankItem : null
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user