<commit_before><?php

final class DiffusionHomeController extends DiffusionController {

  public function processRequest() {
    $request = $this->getRequest();
    $user = $request->getUser();

    $shortcuts = id(new PhabricatorRepositoryShortcut())->loadAll();
    if ($shortcuts) {
      $shortcuts = msort($shortcuts, 'getSequence');

      $rows = array();
      foreach ($shortcuts as $shortcut) {
        $rows[] = array(
          phutil_render_tag(
            'a',
            array(
              'href' => $shortcut->getHref(),
            ),
            phutil_escape_html($shortcut->getName())),
          phutil_escape_html($shortcut->getDescription()),
        );
      }

      $shortcut_table = new AphrontTableView($rows);
      $shortcut_table->setHeaders(
        array(
          'Link',
          '',
        ));
      $shortcut_table->setColumnClasses(
        array(
          'pri',
          'wide',
        ));

      $shortcut_panel = new AphrontPanelView();
      $shortcut_panel->setHeader('Shortcuts');
      $shortcut_panel->appendChild($shortcut_table);
    } else {
      $shortcut_panel = null;
    }

    $repository = new PhabricatorRepository();

    $repositories = $repository->loadAll();
    foreach ($repositories as $key => $repo) {
      if (!$repo->isTracked()) {
        unset($repositories[$key]);
      }
    }

    $repository_ids = mpull($repositories, 'getID');
    $summaries = array();
    $commits = array();
    if ($repository_ids) {
      $summaries = queryfx_all(
        $repository->establishConnection('r'),
        'SELECT * FROM %T WHERE repositoryID IN (%Ld)',
        PhabricatorRepository::TABLE_SUMMARY,
        $repository_ids);
      $summaries = ipull($summaries, null, 'repositoryID');

      $commit_ids = array_filter(ipull($summaries, 'lastCommitID'));
      if ($commit_ids) {
        $commit = new PhabricatorRepositoryCommit();
        $commits = $commit->loadAllWhere('id IN (%Ld)', $commit_ids);
        $commits = mpull($commits, null, 'getRepositoryID');
      }
    }

    $rows = array();
    foreach ($repositories as $repository) {
      $id = $repository->getID();
      $commit = idx($commits, $id);

      $size = idx(idx($summaries, $id, array()), 'size', 0);

      $date = '-';
      $time = '-';
      if ($commit) {
        $date = phabricator_date($commit->getEpoch(), $user);
        $time = phabricator_time($commit->getEpoch(), $user);
      }

      $rows[] = array(
        phutil_render_tag(
          'a',
          array(
            'href' => '/diffusion/'.$repository->getCallsign().'/',
          ),
          phutil_escape_html($repository->getName())),
        phutil_escape_html($repository->getDetail('description')),
        PhabricatorRepositoryType::getNameForRepositoryType(
          $repository->getVersionControlSystem()),
        $size ? number_format($size) : '-',
        $commit
          ? DiffusionView::linkCommit(
              $repository,
              $commit->getCommitIdentifier())
          : '-',<commit_msg>Link repo history from repo overview commits<commit_after><?php

final class DiffusionHomeController extends DiffusionController {

  public function processRequest() {
    $request = $this->getRequest();
    $user = $request->getUser();

    $shortcuts = id(new PhabricatorRepositoryShortcut())->loadAll();
    if ($shortcuts) {
      $shortcuts = msort($shortcuts, 'getSequence');

      $rows = array();
      foreach ($shortcuts as $shortcut) {
        $rows[] = array(
          phutil_render_tag(
            'a',
            array(
              'href' => $shortcut->getHref(),
            ),
            phutil_escape_html($shortcut->getName())),
          phutil_escape_html($shortcut->getDescription()),
        );
      }

      $shortcut_table = new AphrontTableView($rows);
      $shortcut_table->setHeaders(
        array(
          'Link',
          '',
        ));
      $shortcut_table->setColumnClasses(
        array(
          'pri',
          'wide',
        ));

      $shortcut_panel = new AphrontPanelView();
      $shortcut_panel->setHeader('Shortcuts');
      $shortcut_panel->appendChild($shortcut_table);
    } else {
      $shortcut_panel = null;
    }

    $repository = new PhabricatorRepository();

    $repositories = $repository->loadAll();
    foreach ($repositories as $key => $repo) {
      if (!$repo->isTracked()) {
        unset($repositories[$key]);
      }
    }

    $repository_ids = mpull($repositories, 'getID');
    $summaries = array();
    $commits = array();
    if ($repository_ids) {
      $summaries = queryfx_all(
        $repository->establishConnection('r'),
        'SELECT * FROM %T WHERE repositoryID IN (%Ld)',
        PhabricatorRepository::TABLE_SUMMARY,
        $repository_ids);
      $summaries = ipull($summaries, null, 'repositoryID');

      $commit_ids = array_filter(ipull($summaries, 'lastCommitID'));
      if ($commit_ids) {
        $commit = new PhabricatorRepositoryCommit();
        $commits = $commit->loadAllWhere('id IN (%Ld)', $commit_ids);
        $commits = mpull($commits, null, 'getRepositoryID');
      }
    }

    $rows = array();
    foreach ($repositories as $repository) {
      $id = $repository->getID();
      $commit = idx($commits, $id);

      $size = idx(idx($summaries, $id, array()), 'size', '-');
      if ($size != '-') {
        $size = hsprintf(
          '<a href="%s">%s</a>',
          DiffusionRequest::generateDiffusionURI(array(
            'callsign' => $repository->getCallsign(),
            'action' => 'history',
          )),
          number_format($size));
      }

      $date = '-';
      $time = '-';
      if ($commit) {
        $date = phabricator_date($commit->getEpoch(), $user);
        $time = phabricator_time($commit->getEpoch(), $user);
      }

      $rows[] = array(
        phutil_render_tag(
          'a',
          array(
            'href' => '/diffusion/'.$repository->getCallsign().'/',
          ),
          phutil_escape_html($repository->getName())),
        phutil_escape_html($repository->getDetail('description')),
        PhabricatorRepositoryType::getNameForRepositoryType(
          $repository->getVersionControlSystem()),
        $size,
        $commit
          ? DiffusionView::linkCommit(
              $repository,
              $commit->getCommitIdentifier())
          : '-',
{'fraction_non_alphanumeric': 0.15753962027302684, 'fraction_numerical': 0.00015691197238349287, 'mean_word_length': 2.3760593220338984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 58, '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': '5451523', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1877, 'n_words': 322}