<commit_before><?php
namespace App\Controller;

use Cake\ORM\TableRegistry;

/**
 * Controller Trait responsible for changelog functionality.
 */
trait ChangelogTrait
{
    /**
     * Table name for Log Audit model.
     *
     * @var string
     */
    protected $_tableLog = 'LogAudit';

    /**
     * Table name for Users model.
     *
     * @var string
     */
    protected $_tableUsers = 'CakeDC/Users.Users';

    /**
     * Element to be used as View template.
     *
     * @var string
     */
    protected $_elementView = 'Element/changelog';

    /**
     * Return log audit results for specific record.
     *
     * @param  string $id Record id
     * @return void
     */
    public function changelog($id)
    {
        /*
        ideally we want to group by user and timestamp, but having user in the meta information makes this non-trivial
        for now we are using just the timestamp assuming that different will edit the same record at the same time is
        very unlikely.
         */
        $query = TableRegistry::get($this->_tableLog)->findByPrimaryKey($id)
            ->order([$this->_tableLog . '.timestamp' => 'DESC'])
            ->group($this->_tableLog . '.timestamp');

        $modelAlias = $this->{$this->name}->alias();
        $methodName = 'moduleAlias';
        if (method_exists($this->{$this->name}, $methodName) && is_callable([$this->{$this->name}, $methodName])) {
            $modelAlias = $this->{$this->name}->{$methodName}();
        }

        $entity = $this->{$this->name}->findById($id)->firstOrFail();
<commit_msg>fix element path (task #2715)<commit_after><?php
namespace App\Controller;

use Cake\ORM\TableRegistry;

/**
 * Controller Trait responsible for changelog functionality.
 */
trait ChangelogTrait
{
    /**
     * Table name for Log Audit model.
     *
     * @var string
     */
    protected $_tableLog = 'LogAudit';

    /**
     * Table name for Users model.
     *
     * @var string
     */
    protected $_tableUsers = 'CakeDC/Users.Users';

    /**
     * Element to be used as View template.
     *
     * @var string
     */
    protected $_elementView = '/Element/changelog';

    /**
     * Return log audit results for specific record.
     *
     * @param  string $id Record id
     * @return void
     */
    public function changelog($id)
    {
        /*
        ideally we want to group by user and timestamp, but having user in the meta information makes this non-trivial
        for now we are using just the timestamp assuming that different will edit the same record at the same time is
        very unlikely.
         */
        $query = TableRegistry::get($this->_tableLog)->findByPrimaryKey($id)
            ->order([$this->_tableLog . '.timestamp' => 'DESC'])
            ->group($this->_tableLog . '.timestamp');

        $modelAlias = $this->{$this->name}->alias();
        $methodName = 'moduleAlias';
        if (method_exists($this->{$this->name}, $methodName) && is_callable([$this->{$this->name}, $methodName])) {
            $modelAlias = $this->{$this->name}->{$methodName}();
        }

        $entity = $this->{$this->name}->findById($id)->firstOrFail();

{'fraction_non_alphanumeric': 0.14218009478672985, 'fraction_numerical': 0.001263823064770932, 'mean_word_length': 2.3326315789473684, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '5196076', 'n_tokens_mistral': 911, 'n_tokens_neox': 897, 'n_words': 254}