<commit_before><?php

namespace Zeropingheroes\Lanager\Services;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Zeropingheroes\Lanager\Lan;

class GetLanAttendeeGamePicksService
{
    /**
     * @var Lan
     */
    private $lan;

    public function __construct(Lan $lan)
    {
        $this->lan = $lan;
    }

    /**
     * Get the games that are currently being played
     *
     * @return Collection
     */
    public function get(): Collection
    {
        $picks = $this->lan->attendeeGamePicks()->with('user', 'game')->get();

        if (empty($picks)) {
            return new Collection();
        }

        // Collect and combine picks for the same game
        $games = [];
        foreach ($picks as $pick) {
            $id = $pick->game_id_type.$pick->game_id;
            $games[$id]['name'] = $pick->game->name;
            $games[$id]['logo'] = $pick->game->logo();
            $games[$id]['url'] = $pick->game->url();
            $games[$id]['provider'] = 'steam_app';
            $games[$id]['id'] = $pick->game->id;
            if (Auth::user() && Auth::user()->id === $pick->user->id) {
                $games[$id]['auth_user_pick'] = $pick;
            }
            $games[$id]['picks'][] = $pick;
        }

        // Sort games array by number of picks, in descending order (removing key)
        usort(
            $games,<commit_msg>Fix "unsupported provider" when using + and - buttons<commit_after><?php

namespace Zeropingheroes\Lanager\Services;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Zeropingheroes\Lanager\Lan;
use Illuminate\Database\Eloquent\Relations\Relation;

class GetLanAttendeeGamePicksService
{
    /**
     * @var Lan
     */
    private $lan;

    public function __construct(Lan $lan)
    {
        $this->lan = $lan;
    }

    /**
     * Get the games that are currently being played
     *
     * @return Collection
     */
    public function get(): Collection
    {
        $picks = $this->lan->attendeeGamePicks()->with('user', 'game')->get();

        if (empty($picks)) {
            return new Collection();
        }

        // Collect and combine picks for the same game
        $games = [];
        foreach ($picks as $pick) {
            $id = $pick->game_id_type.$pick->game_id;
            $games[$id]['name'] = $pick->game->name;
            $games[$id]['logo'] = $pick->game->logo();
            $games[$id]['url'] = $pick->game->url();
            $games[$id]['provider'] = $pick->game_id_type;
            $games[$id]['id'] = $pick->game->id;
            if (Auth::user() && Auth::user()->id === $pick->user->id) {
                $games[$id]['auth_user_pick'] = $pick;
            }
            $games[$id]['picks'][] = $pick;
        }

        // Sort games array by number of picks, in descending order (removing key)
        usort(
            $games,
{'fraction_non_alphanumeric': 0.16914049016223678, 'fraction_numerical': 0.0, 'mean_word_length': 2.112781954887218, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5706038', 'n_tokens_mistral': 912, 'n_tokens_neox': 890, 'n_words': 187}