<commit_before><?php
namespace AnhNhan\Converge\Modules\User\Controllers;

use AnhNhan\Converge as cv;
use AnhNhan\Converge\Modules\Forum\Query\DiscussionQuery;
use AnhNhan\Converge\Modules\Forum\Views\Objects\ForumListing;
use AnhNhan\Converge\Modules\Forum\Views\Objects\ForumObject;
use AnhNhan\Converge\Modules\Tag\Views\TagView;
use AnhNhan\Converge\Modules\User\Query\UserQuery;
use AnhNhan\Converge\Modules\User\Storage\User;
use AnhNhan\Converge\Views\Grid\Grid;
use AnhNhan\Converge\Views\Panel\Panel;
use AnhNhan\Converge\Views\Web\Response\ResponseHtml404;
use AnhNhan\Converge\Web\Application\HtmlPayload;
use YamwLibs\Libs\Html\Markup\MarkupContainer;

/**
 * @author <NAME> <<EMAIL>>
 */
final class UserDisplay extends AbstractUserController
{
    public function handle()
    {
        $request = $this->request;

        $req_canon_name = $request->get('name');

        $query = new UserQuery($this->app);
        $user  = idx($query->retrieveUsersForCanonicalNames([$req_canon_name], 1), 0);

        if (!$user)
        {
            // Q: Put suggestions here?
            return id(new ResponseHtml404)->setText('Could not find a user with the name \'' . $req_canon_name . '\'.');
        }

        $payload = new HtmlPayload;
        $payload->setTitle(sprintf('User \'%s\'', $user->name));
        $container = new MarkupContainer;
        $payload->setPayloadContents($container);

        $container->push(h1($user->name)->append(' ')->append(cv\ht('small', $user->handle)));
        $container->push(cv\ht('img')->addOption('src', $user->getGravatarImagePath(50))->addOption('style', 'width: 50px; height: 50px;'));

        $roles_container = div();
        $roles_container->append(h2('Roles inhabited'));
        $ul = cv\ht('ul');
        foreach ($user->roles as $role)
        {
            $ul->append(cv\ht('li', $role->label . ' ')->append(cv\ht('span', $role->name)->addClass('muted')));
        }
        $roles_container->append($ul);
        $container->push($roles_container);

        $disqQuery = $this->buildForumQuery();
        $disqs = $this->fetchDiscussions([$user->uid]);
        $disqQuery->fetchExternalsForDiscussions($disqs);<commit_msg>Fixing a bug where we would not find a user, the fifth<commit_after><?php
namespace AnhNhan\Converge\Modules\User\Controllers;

use AnhNhan\Converge as cv;
use AnhNhan\Converge\Modules\Forum\Query\DiscussionQuery;
use AnhNhan\Converge\Modules\Forum\Views\Objects\ForumListing;
use AnhNhan\Converge\Modules\Forum\Views\Objects\ForumObject;
use AnhNhan\Converge\Modules\Tag\Views\TagView;
use AnhNhan\Converge\Modules\User\Query\UserQuery;
use AnhNhan\Converge\Modules\User\Storage\User;
use AnhNhan\Converge\Views\Grid\Grid;
use AnhNhan\Converge\Views\Panel\Panel;
use AnhNhan\Converge\Views\Web\Response\ResponseHtml404;
use AnhNhan\Converge\Web\Application\HtmlPayload;
use YamwLibs\Libs\Html\Markup\MarkupContainer;

/**
 * @author <NAME> <<EMAIL>>
 */
final class UserDisplay extends AbstractUserController
{
    public function handle()
    {
        $request = $this->request;

        $req_canon_name = $request->get('name');

        $query = new UserQuery($this->app);
        $user  = head($query->retrieveUsersForCanonicalNames([$req_canon_name], 1));

        if (!$user)
        {
            // Q: Put suggestions here?
            return id(new ResponseHtml404)->setText('Could not find a user with the name \'' . $req_canon_name . '\'.');
        }

        $payload = new HtmlPayload;
        $payload->setTitle(sprintf('User \'%s\'', $user->name));
        $container = new MarkupContainer;
        $payload->setPayloadContents($container);

        $container->push(h1($user->name)->append(' ')->append(cv\ht('small', $user->handle)));
        $container->push(cv\ht('img')->addOption('src', $user->getGravatarImagePath(50))->addOption('style', 'width: 50px; height: 50px;'));

        $roles_container = div();
        $roles_container->append(h2('Roles inhabited'));
        $ul = cv\ht('ul');
        foreach ($user->roles as $role)
        {
            $ul->append(cv\ht('li', $role->label . ' ')->append(cv\ht('span', $role->name)->addClass('muted')));
        }
        $roles_container->append($ul);
        $container->push($roles_container);

        $disqQuery = $this->buildForumQuery();
        $disqs = $this->fetchDiscussions([$user->uid]);
        $disqQuery->fetchExternalsForDiscussions($disqs);
{'fraction_non_alphanumeric': 0.16685507574044767, 'fraction_numerical': 0.007008817544652951, 'mean_word_length': 3.500508646998983, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 69, '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': '6201103', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1487, 'n_words': 225}