<commit_before><?php

namespace Command;

use Command\Base\BaseCommand;
use Survos\Client\Resource\AssignmentResource;
use Survos\Client\SurvosCriteria;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Survos\Client\SurvosClient;
use Survos\Client\Resource\MemberResource;
use Survos\Client\Resource\ProjectResource;
use Survos\Client\Resource\UserResource;


class AssignmentProcessCommand extends BaseCommand
{
    protected function configure()
    {
        parent::configure();
        $this
            ->setName('assignment:process')
            ->setDescription('Process API assignments')
            ->addOption(
                'project-code',
                null,
                InputOption::VALUE_REQUIRED,
                'Source project code'
            );
    }

    /**
     * @param \Symfony\Component\Console\Input\InputInterface   $input
     * @param \Symfony\Component\Console\Output\OutputInterface $output
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $isVerbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
        $projectCode = $input->getOption('project-code');

        /** @type AssignmentResource $assignmentResource */
        $assignmentResource = new AssignmentResource($this->sourceClient);

        $page = 0;
        $perPage = 10;
        $maxPages = 1;
        $criteria = [];
        $data = [];
        $assignments = $assignmentResource->getList(
            1,
            1,
            [
                'survey_response_status_code' => 'initiated',
            ],
            null,
            null,
            ['project_code' => 'behattest']
        );

        // if no items, return
        if (!count($assignments['items']) || !$assignments['total']) {
            return;
        }

        foreach ($assignments['items'] as $key => $assignment) {
            if ($isVerbose) {
                $no = ($page - 1) * $perPage + $key + 1;
                $output->writeln("{$no} - Reading assignment #{$assignment['id']}");
            }

            var_dump($assignment);

            if ($isVerbose) {
                $output->writeln("Accepting member #{$assignment['id']}");
            }
        }


    }


    /**
     * @param $member
     * @return array
     */
    private function getMemberCriteria()
    {
        return [
            'enrollment_status_code' => 'applicant',
        ];
    }

}<commit_msg>get the survey JSON from the assignment<commit_after><?php

namespace Command;

use Command\Base\BaseCommand;
use Survos\Client\Resource\AssignmentResource;
use Survos\Client\Resource\TaskResource;
use Survos\Client\SurvosCriteria;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Survos\Client\SurvosClient;
use Survos\Client\Resource\MemberResource;
use Survos\Client\Resource\ProjectResource;
use Survos\Client\Resource\UserResource;


class AssignmentProcessCommand extends BaseCommand
{
    protected function configure()
    {
        parent::configure();
        $this
            ->setName('assignment:process')
            ->setDescription('Process API assignments')
            ->addOption(
                'project-code',
                null,
                InputOption::VALUE_REQUIRED,
                'Source project code'
            );
    }

    /**
     * @param \Symfony\Component\Console\Input\InputInterface   $input
     * @param \Symfony\Component\Console\Output\OutputInterface $output
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $isVerbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
        $projectCode = $input->getOption('project-code');

        /** @type AssignmentResource $assignmentResource */
        $assignmentResource = new AssignmentResource($this->sourceClient);

        $page = 0;
        $perPage = 10;
        $maxPages = 1;
        $criteria = [];
        $data = [];
        $assignments = $assignmentResource->getList(
            1,
            1,
            [
                'survey_response_status_code' => 'initiated',
            ],
            null,
            null,
            ['project_code' => 'behattest']
        );

        // if no items, return
        if (!count($assignments['items']) || !$assignments['total']) {
            return;
        }
        $tasksIds = array_map(function($item){ return $item['task_id']; }, $assignments['items']);
        $taskResource = new TaskResource($this->sourceClient);
        $tasks = $taskResource->getList(null, null, ['id' => array_unique($tasksIds)], ['id' => SurvosCriteria::IN]);
        $surveyByTask = [];
        foreach ($tasks['items'] as $task) {
            $surveyByTask[$task['id']] = isset($task['survey_json']) ? json_decode($task['survey_json'], true) : null;
        }
        foreach ($assignments['items'] as $key => $assignment) {
//            $taskId = $assignment['task_id'];
//            $survey = $surveyByTask[$taskId];
            if ($isVerbose) {
                $no = ($page - 1) * $perPage + $key + 1;
                $output->writeln("{$no} - Reading assignment #{$assignment['id']}");
            }

            var_dump($assignment);

            if ($isVerbose) {
                $output->writeln("Accepting member #{$assignment['id']}");
            }
        }


    }


    /**
     * @param $member
     * @return array
     */
    private function getMemberCriteria()
    {
        return [
            'enrollment_status_code' => 'applicant',
        ];
    }

}
{'fraction_non_alphanumeric': 0.13303060881264717, 'fraction_numerical': 0.0026908846283215607, 'mean_word_length': 2.2268041237113403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '3819313', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1635, 'n_words': 295}