Skip to content

Commit

Permalink
performance increase
Browse files Browse the repository at this point in the history
  • Loading branch information
th0rn0 committed May 21, 2024
1 parent 93f6549 commit a976fa3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 68 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- "host.docker.internal:host-gateway"

db:
image: mysql:5.6
image: mysql:5.7
volumes:
- db:/var/lib/mysql
env_file: $PWD/src/.env
Expand Down
2 changes: 1 addition & 1 deletion src/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ DISCORD_SCOPE=
## SEO

SEO_DESCRIPTION=
SEO_KEYWORDS=
SEO_KEYWORDS=
29 changes: 0 additions & 29 deletions src/app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
namespace App\Http\Controllers;

use DB;
use Auth;

use App\Models\Event;
use App\Models\NewsArticle;
use App\Models\EventTimetableData;
use App\Models\EventParticipant;

class HomeController extends Controller
{
Expand All @@ -18,30 +15,6 @@ class HomeController extends Controller
*/
public function index()
{
$topAttendees = array();
foreach (EventParticipant::groupBy('user_id', 'event_id')->get() as $attendee) {
if ($attendee->event && $attendee->event->status == 'PUBLISHED' && $attendee->event->end < \Carbon\Carbon::today()) {
$recent = false;
if (!$attendee->user->admin && array_key_exists($attendee->user->id, $topAttendees)) {
$topAttendees[$attendee->user->id]->event_count++;
$recent = true;
}
if (!$attendee->user->admin && !$recent) {
$attendee->user->event_count = 1;
$topAttendees[$attendee->user->id] = $attendee->user;
}
}
}
usort($topAttendees, function ($a, $b) {
return $b['event_count'] <=> $a['event_count'];
});

$topWinners = array();

usort($topWinners, function ($a, $b) {
return $b['win_count'] <=> $a['win_count'];
});

// TODO - TEMP FIX
// Setup Slider Images
$sliderImages = array(
Expand All @@ -58,8 +31,6 @@ public function index()
Event::where('end', '>=', \Carbon\Carbon::now())
->orderBy(DB::raw('ABS(DATEDIFF(events.end, NOW()))'))->first()
)
->withTopAttendees(array_slice($topAttendees, 0, 5))
->withTopWinners(array_slice($topWinners, 0, 5))
->withNewsArticles(NewsArticle::limit(4)->orderBy('created_at', 'desc')->get())
->withEvents(Event::all())
->withSliderImages(json_decode(json_encode($sliderImages), FALSE))
Expand Down
38 changes: 1 addition & 37 deletions src/resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,43 +132,7 @@
<h3>The {{ config('app.name') }} Fam</h3>
</div>
@if (config('app.discord_id'))
<iframe class="hidden-md" src="https://discordapp.com/widget?id={{ config('app.discord_id') }}&theme=light" width="100%" height="500" allowtransparency="true" frameborder="0"></iframe>
@endif
@if (count($topAttendees) > 0)
<div class="page-header">
<h5>Top 5 Attendees</h5>
</div>
@foreach ($topAttendees as $attendee)
<div class="row">
<div class="col-xs-12 col-sm-3">
<img class="img-rounded img-responsive" alt="{{ $attendee->username }}'s Avatar" src="{{ $attendee->avatar }}">
</div>
<div class="col-xs-12 col-sm-9">
<p>
{{ $attendee->username }}<br>
<small> {{ $attendee->event_count }} Events Attended</small>
</p>
</div>
</div>
@endforeach
@endif
@if (count($topWinners) > 0)
<div class="page-header">
<h5>Top 5 Winners</h5>
</div>
@foreach ($topWinners as $winner)
<div class="row">
<div class="col-xs-12 col-sm-3">
<img class="img-rounded img-responsive" alt="{{ $winner->username }}'s Avatar" src="{{ $winner->avatar }}">
</div>
<div class="col-xs-12 col-sm-9">
<p>
{{ $winner->username }}<br>
<small> {{ $winner->win_count }} Wins</small>
</p>
</div>
</div>
@endforeach
<iframe class="hidden-md" src="https://discordapp.com/widget?id={{ config('app.discord_id') }}&theme=light" width="100%" height="1000" allowtransparency="true" frameborder="0"></iframe>
@endif
</div>
</div>
Expand Down

0 comments on commit a976fa3

Please sign in to comment.