<commit_before><?php

namespace Northstar\Http\Controllers;

use Illuminate\Http\Request;
use Northstar\Models\User;
use Northstar\Services\Phoenix;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Auth;

class SignupController extends Controller
{
    /**
     * Phoenix Drupal API wrapper.
     * @var Phoenix
     */
    protected $phoenix;

    /**
     * Make a new Signup controller, inject dependencies,
     * and set middleware for this controller's methods.
     * @param Phoenix $phoenix
     */
    public function __construct(Phoenix $phoenix)
    {
        $this->phoenix = $phoenix;

        $this->middleware('key:user', ['only' => ['profile', 'store']]);
        $this->middleware('auth', ['only' => ['profile', 'store']]);
    }

    /**
     * Displays the (optionally filtered) index of signups.
     * GET /signups
     *
     * @see Phoenix /api/v1/signups endpoint
     * <https://github.com/DoSomething/phoenix/wiki/API#retrieve-a-signup-collection>
     *
     * @param Request $request
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $options = $request->query();

        // Transform user into users.
        if (! empty($options['user'])) {
            $options['users'] = $options['user'];
        }

        // If a user is specified, turn Northstar ID into Drupal ID
        if (! empty($options['users'])) {
            $usersQuery = explode(',', $options['users']);
            $options['users'] = User::drupalIDForNorthstarId($usersQuery);
        }

        return $this->phoenix->getSignupIndex($options);
    }

    /**
     * Displays the currently authenticated user's signups.
     * GET /profile/signups
     *
     * @see Phoenix /api/v1/signups endpoint
     * <https://github.com/DoSomething/phoenix/wiki/API#retrieve-a-signup-collection>
     *
     * @param Request $request
     * @return \Illuminate\Http\Response
     */
    public function profile(Request $request)
    {
        // Get the currently authenticated Northstar user.
        $user = Auth::user();
<commit_msg>adds all information for user and style ci fixes<commit_after><?php

namespace Northstar\Http\Controllers;

use Illuminate\Http\Request;
use Northstar\Models\User;
use Northstar\Services\Phoenix;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Auth;

class SignupController extends Controller
{
    /**
     * Phoenix Drupal API wrapper.
     * @var Phoenix
     */
    protected $phoenix;

    /**
     * Make a new Signup controller, inject dependencies,
     * and set middleware for this controller's methods.
     * @param Phoenix $phoenix
     */
    public function __construct(Phoenix $phoenix)
    {
        $this->phoenix = $phoenix;

        $this->middleware('key:user', ['only' => ['profile', 'store']]);
        $this->middleware('auth', ['only' => ['profile', 'store']]);
    }

    /**
     * Displays the (optionally filtered) index of signups.
     * GET /signups
     *
     * @see Phoenix /api/v1/signups endpoint
     * <https://github.com/DoSomething/phoenix/wiki/API#retrieve-a-signup-collection>
     *
     * @param Request $request
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $options = $request->query();

        // Transform user into users.
        if (! empty($options['user'])) {
            $options['users'] = $options['user'];
        }

        // If a user is specified, turn Northstar ID into Drupal ID
        if (! empty($options['users'])) {
            $usersQuery = explode(',', $options['users']);
            $options['users'] = User::drupalIDForNorthstarId($usersQuery);
        }

        $results = $this->phoenix->getSignupIndex($options);

        foreach (array_slice($results, 1) as $result) {
            $northstar_id = $result[0]['user']['id'];
            $user = User::where('_id', $northstar_id)->first();
            $last_initial = substr(($user->last_name), 0, 1);

            if ($last_initial === false) {
                $last_initial = null;
            }

            $result[0]['user'] = [
                'first_name' => $user->first_name,
                'last_initial' => $last_initial,
                'photo' => isset($user) ? $user->photo : null,
                'country' => $user->country,
                'test' => 'test',
            ];
        }

        return $results;
    }

    /**
     * Displays the currently authenticated user's signups.
     * GET /profile/signups
     *
     * @see Phoenix /api/v1/signups endpoint
     * <https://github.com/DoSomething/phoenix/wiki/API#retrieve-a-signup-collection>
     *
     * @param Request $request
     * @return \Illuminate\Http\Response
     */
    public function profile(Request $request)
    {
        // Get the currently authenticated Northstar user.
        $user = Auth::user();

{'fraction_non_alphanumeric': 0.1430615164520744, 'fraction_numerical': 0.0018393623543838135, 'mean_word_length': 2.3566529492455417, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, 'https://': 4, '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': '1201750', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1430, 'n_words': 320}