<commit_before><?php

namespace App\Bundle\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

/**
 * Handle actions about record
 */
class RecordController extends Controller
{
    const NUMBER_PER_PAGE = 20;

    /**
     * List all records ordered by date
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function listAction(Request $request)
    {
        $page        = $request->get('page', 1);
        $elements    = $this->get('app_main.record.lister.date')->get(self::NUMBER_PER_PAGE, $page);
        if (count($elements) === 0) {
            throw $this->createNotFoundException();
        }
        $isNextPage  = (count($elements) === self::NUMBER_PER_PAGE);
        $identifiers = $this->getIdentifiers($elements);
        $records     = $this->get('app_main.record.reader')->find($identifiers);

        $orderedRecords = $this->getOrderedRecords($elements, $records);

        return $this->render('AppMainBundle:Record:list.html.twig', [
            'records'  => $orderedRecords,
            'nextPage' => ($isNextPage ? $page + 1 : null),
        ]);
    }

    /**
     * Retrieve record identifiers from the given elements array
     *
     * @param \App\Component\Lister\Element[] $elements
     *
     * @return int[]
     */
    private function getIdentifiers(array $elements)<commit_msg>Use the record index aggregator on all pages of the list, instead of only the first one<commit_after><?php

namespace App\Bundle\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

/**
 * Handle actions about record
 */
class RecordController extends Controller
{
    const NUMBER_PER_PAGE = 20;

    /**
     * List all records ordered by date
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function listAction(Request $request)
    {
        $page        = $request->get('page', 1);
        $elements    = $this->get('app_main.record.lister.date')->get(self::NUMBER_PER_PAGE, $page);
        if (count($elements) === 0) {
            throw $this->createNotFoundException();
        }
        $isNextPage  = (count($elements) === self::NUMBER_PER_PAGE);
        $identifiers = $this->getIdentifiers($elements);
        $records     = $this->get('app_main.record.index.aggregator')->get($identifiers);

        $orderedRecords = $this->getOrderedRecords($elements, $records);

        return $this->render('AppMainBundle:Record:list.html.twig', [
            'records'  => $orderedRecords,
            'nextPage' => ($isNextPage ? $page + 1 : null),
        ]);
    }

    /**
     * Retrieve record identifiers from the given elements array
     *
     * @param \App\Component\Lister\Element[] $elements
     *
     * @return int[]
     */
    private function getIdentifiers(array $elements)
{'fraction_non_alphanumeric': 0.13715455475946775, 'fraction_numerical': 0.0034118048447628795, 'mean_word_length': 2.857894736842105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2272837', 'n_tokens_mistral': 843, 'n_tokens_neox': 822, 'n_words': 169}