<commit_before><?php

use \propel2\PostQuery;

class Controller_Orm_Propel2 extends Controller_Base
{

    public function setup()
    {
        require_once(APPPATH . '../generated-conf/config.php');
    }

    public function action_get_one($id = 1)
    {
        $timeStart = microtime(true);
        $memoryStart = memory_get_usage();
        
        $this->setup();
        
        $post = PostQuery::create()->findPk($id);

        echo $post->getTitle() . '<br>' . "\n";
        $comments = $post->getComments();
        echo $comments[0]->getBody() . '<br>' . "\n";
        
        echo microtime(true) - $timeStart . " secs<br>\n";
        echo (memory_get_usage() - $memoryStart)/1024 . " KB\n";
    }
}<commit_msg>Ordering propel2 post comments by created_at, descending<commit_after><?php

use \propel2\PostQuery;
use \Propel\Runtime\ActiveQuery\Criteria;

class Controller_Orm_Propel2 extends Controller_Base
{

    public function setup()
    {
        require_once(APPPATH . '../generated-conf/config.php');
    }

    public function action_get_one($id = 1)
    {
        $timeStart = microtime(true);
        $memoryStart = memory_get_usage();
        
        $this->setup();
        
        $post = PostQuery::create()
          ->useCommentQuery()
            ->orderByCreatedAt(Criteria::DESC)
            ->limit(1)
          ->endUse()
          ->findPk($id);

        echo $post->getTitle() . '<br>' . "\n";
        $comments = $post->getComments();
        echo $comments[0]->getBody() . '<br>' . "\n";
        
        echo microtime(true) - $timeStart . " secs<br>\n";
        echo (memory_get_usage() - $memoryStart)/1024 . " KB\n";
    }
}
{'fraction_non_alphanumeric': 0.16138673042438734, 'fraction_numerical': 0.010759115361625823, 'mean_word_length': 2.182509505703422, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '6949648', 'n_tokens_mistral': 544, 'n_tokens_neox': 525, 'n_words': 95}