Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: put top 100 into pagination #862

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function schedule(Schedule $schedule)

$schedule->command(RefreshAnalytics::class, ['MostXpPlayer'])
->withoutOverlapping()
->everyFifteenMinutes()
->everyThirtyMinutes()
->timezone('America/New_York');

$schedule->command('horizon:snapshot')
Expand Down
13 changes: 10 additions & 3 deletions app/Http/Livewire/TopTenLeaderboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,26 @@
use App\Support\Schedule\ScheduleTimerInterface;
use Illuminate\View\View;
use Livewire\Component;
use Livewire\WithPagination;

class TopTenLeaderboard extends Component
{
use WithPagination;

public function paginationView(): string
{
return 'pagination::bulma';
}

public string $analyticKey;

public function render(): View
{
$topTen = Analytic::query()
->with(['player', 'game', 'map'])
->where('key', $this->analyticKey)
->orderByDesc('value')
->limit(10)
->get();
->orderBy('place')
->paginate(10);

$analyticEnumKey = AnalyticKey::tryFrom($this->analyticKey);

Expand Down
10 changes: 5 additions & 5 deletions app/Jobs/ProcessAnalytic.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ public function handle(): void

switch ($this->analytic->type()) {
case AnalyticType::PLAYER():
$this->handleServiceRecordResults($topThousand);
$this->handleServiceRecordResults($topHundred);
break;
case AnalyticType::GAME():
$this->handleGamePlayerResults($topThousand);
$this->handleGamePlayerResults($topHundred);
break;
case AnalyticType::ONLY_GAME():
$this->handleGameResults($topThousand);
$this->handleGameResults($topHundred);
break;
case AnalyticType::MAP():
$this->handleMapResults($topThousand);
$this->handleMapResults($topHundred);
break;
case AnalyticType::ONLY_PLAYER():
$this->handleOnlyPlayerResults($topThousand);
$this->handleOnlyPlayerResults($topHundred);
break;
}

Expand Down
13 changes: 7 additions & 6 deletions resources/views/livewire/top-ten-leaderboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@foreach ($results as $result)
<tr>
<td>
@th($loop->iteration)
@th($result->place)
</td>
@if ($analyticClass->type()->notIn([AnalyticType::ONLY_GAME(), AnalyticType::MAP()]))
<td>
Expand Down Expand Up @@ -82,11 +82,12 @@
@endforeach
</tbody>
</table>
<div class="notification is-light is-hidden-mobile mt-2">
export to csv: <a href="{{ $analyticClass->displayExportUrl(10) }}" rel="nofollow">top 10</a>,
<a href="{{ $analyticClass->displayExportUrl(100) }}" rel="nofollow">top 100</a> or
<a href="{{ $analyticClass->displayExportUrl(1000) }}" rel="nofollow">top 1,000</a>.
</div>
</div>
{{ $results->links() }}
<div class="notification is-light is-hidden-mobile mt-2">
export to csv: <a href="{{ $analyticClass->displayExportUrl(10) }}" rel="nofollow">top 10</a>,
<a href="{{ $analyticClass->displayExportUrl(100) }}" rel="nofollow">top 100</a> or
<a href="{{ $analyticClass->displayExportUrl(1000) }}" rel="nofollow">top 1,000</a>.
</div>
@endif
</div>
Expand Down