<commit_before><?php

namespace SynchWeb\Page\EM;

trait Picker
{
    public function pickerMovies()
    {
        $rows = $this->db->pq(
            "SELECT m.movieNumber
            FROM ParticlePicker pp
            LEFT JOIN MotionCorrection mc ON mc.motionCorrectionId = pp.firstMotionCorrectionId
            LEFT JOIN Movie m ON m.movieId = mc.movieId
            INNER JOIN DataCollection dc ON dc.dataCollectionId = m.dataCollectionId
            INNER JOIN DataCollectionGroup dcg ON dcg.dataCollectionGroupId = dc.dataCollectionGroupId
            INNER JOIN BLSession bls ON bls.sessionId = dcg.sessionId
            INNER JOIN Proposal p ON p.proposalId = bls.proposalId
            WHERE CONCAT(p.proposalCode, p.proposalNumber) = :1
            AND pp.programId = :2",
            array($this->arg('prop'), $this->arg('id')),
            false
        );
        $this->_output(
            array_map(
                function ($row) {
                    return $row['movieNumber'];
                },
                $rows
            )
        );
    }

    public function pickerResult()
    {
        $rows = $this->db->pq(
            "SELECT
                pp.particleDiameter,
                pp.numberOfParticles,
                pp.summaryImageFullPath,
                m.movieNumber
            FROM ParticlePicker pp
            LEFT JOIN MotionCorrection mc ON mc.motionCorrectionId = pp.firstMotionCorrectionId
            LEFT JOIN Movie m ON m.movieId = mc.movieId
            INNER JOIN DataCollection dc ON dc.dataCollectionId = m.dataCollectionId
            INNER JOIN DataCollectionGroup dcg ON dcg.dataCollectionGroupId = dc.dataCollectionGroupId
            INNER JOIN BLSession bls ON bls.sessionId = dcg.sessionId
            INNER JOIN Proposal p ON p.proposalId = bls.proposalId
            WHERE CONCAT(p.proposalCode, p.proposalNumber) = :1
            AND pp.programId = :2
            AND m.movieNumber = :3",
            array(
                $this->arg('prop'),
                $this->arg('id'),
                $this->has_arg('movieNumber') ? $this->arg('movieNumber') : 1
            ),
            false
        );

        if (!sizeof($rows)) {
            $this->_error('No such pick');
        }
        $row = $rows[0];

        $row['summaryImageFullPath'] = file_exists($row['summaryImageFullPath']) ? 1 : 0;

        $this->_output($row);
    }

    public function pickerImage()
    {
        $rows = $this->db->pq(
            "SELECT pp.summaryImageFullPath
            FROM ParticlePicker pp
            LEFT JOIN MotionCorrection mc ON mc.motionCorrectionId = pp.firstMotionCorrectionId
            LEFT JOIN Movie m ON m.movieId = mc.movieId
            INNER JOIN DataCollection dc ON dc.dataCollectionId = m.dataCollectionId
            INNER JOIN DataCollectionGroup dcg ON dcg.dataCollectionGroupId = dc.dataCollectionGroupId
            INNER JOIN BLSession bls ON bls.sessionId = dcg.sessionId
            INNER JOIN Proposal p ON p.proposalId = bls.proposalId
            WHERE CONCAT(p.proposalCode, p.proposalNumber) = :1
            AND pp.programId = :2
            AND m.movieNumber = :3",
            array(
                $this->arg('prop'),
                $this->arg('id'),
                $this->has_arg('movieNumber') ? $this->arg('movieNumber') : 1
            ),
            false
        );

        if (!sizeof($rows)) {
            $this->_error('No such particle picking');
        }

        $image = $rows[0]['summaryImageFullPath'];

        if (file_exists($image)) {
            $this->sendImage($image);
            return;
        }

        $this->app->contentType('image/png');
        readfile('assets/images/no_image.png');
    }
}<commit_msg>Small fix make API picker code more explicit.<commit_after><?php

namespace SynchWeb\Page\EM;

trait Picker
{
    public function pickerMovies()
    {
        $rows = $this->db->pq(
            "SELECT m.movieNumber
            FROM ParticlePicker pp
            LEFT JOIN MotionCorrection mc ON mc.motionCorrectionId = pp.firstMotionCorrectionId
            LEFT JOIN Movie m ON m.movieId = mc.movieId
            INNER JOIN DataCollection dc ON dc.dataCollectionId = m.dataCollectionId
            INNER JOIN DataCollectionGroup dcg ON dcg.dataCollectionGroupId = dc.dataCollectionGroupId
            INNER JOIN BLSession bls ON bls.sessionId = dcg.sessionId
            INNER JOIN Proposal p ON p.proposalId = bls.proposalId
            WHERE CONCAT(p.proposalCode, p.proposalNumber) = :1
            AND pp.programId = :2",
            array($this->arg('prop'), $this->arg('id')),
            false
        );
        $this->_output(
            array_map(
                function ($row) {
                    return $row['movieNumber'];
                },
                $rows
            )
        );
    }

    public function pickerResult()
    {
        $rows = $this->db->pq(
            "SELECT
                pp.particleDiameter,
                pp.numberOfParticles,
                pp.summaryImageFullPath,
                m.movieNumber
            FROM ParticlePicker pp
            LEFT JOIN MotionCorrection mc ON mc.motionCorrectionId = pp.firstMotionCorrectionId
            LEFT JOIN Movie m ON m.movieId = mc.movieId
            INNER JOIN DataCollection dc ON dc.dataCollectionId = m.dataCollectionId
            INNER JOIN DataCollectionGroup dcg ON dcg.dataCollectionGroupId = dc.dataCollectionGroupId
            INNER JOIN BLSession bls ON bls.sessionId = dcg.sessionId
            INNER JOIN Proposal p ON p.proposalId = bls.proposalId
            WHERE CONCAT(p.proposalCode, p.proposalNumber) = :1
            AND pp.programId = :2
            AND m.movieNumber = :3",
            array(
                $this->arg('prop'),
                $this->arg('id'),
                $this->has_arg('movieNumber') ? $this->arg('movieNumber') : 1
            ),
            false
        );

        if (!sizeof($rows)) {
            $this->_error('No such pick');
        }
        $row = $rows[0];

        $row['summaryImageFullPath'] = file_exists($row['summaryImageFullPath']) ? 1 : 0;

        $this->_output($row);
    }

    public function pickerImage()
    {
        $rows = $this->db->pq(
            "SELECT pp.summaryImageFullPath
            FROM ParticlePicker pp
            LEFT JOIN MotionCorrection mc ON mc.motionCorrectionId = pp.firstMotionCorrectionId
            LEFT JOIN Movie m ON m.movieId = mc.movieId
            INNER JOIN DataCollection dc ON dc.dataCollectionId = m.dataCollectionId
            INNER JOIN DataCollectionGroup dcg ON dcg.dataCollectionGroupId = dc.dataCollectionGroupId
            INNER JOIN BLSession bls ON bls.sessionId = dcg.sessionId
            INNER JOIN Proposal p ON p.proposalId = bls.proposalId
            WHERE CONCAT(p.proposalCode, p.proposalNumber) = :1
            AND pp.programId = :2
            AND m.movieNumber = :3",
            array(
                $this->arg('prop'),
                $this->arg('id'),
                $this->has_arg('movieNumber') ? $this->arg('movieNumber') : 1
            ),
            false
        );

        if (sizeof($rows) == 0) {
            $this->_error('No such particle picking');
        }

        $image = $rows[0]['summaryImageFullPath'];

        if (file_exists($image)) {
            $this->sendImage($image);
            return;
        }

        $this->app->contentType('image/png');
        readfile('assets/images/no_image.png');
    }
}
{'fraction_non_alphanumeric': 0.09965453095934095, 'fraction_numerical': 0.0038533085304278502, 'mean_word_length': 1.7360959651035988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '6313095', 'n_tokens_mistral': 2231, 'n_tokens_neox': 2070, 'n_words': 490}