diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml index bbd56df026..c8922b4014 100644 --- a/config/configuration.sample.yml +++ b/config/configuration.sample.yml @@ -424,8 +424,12 @@ order-manager: feedback-report: enabled: false actions: + # if any participant has not voted, set the "incomplete" icon action_unvoted: - # if any participant has not voted, set the "incomplete" icon + # play this action only on those databoxes + databoxes: + - myDatabox + - 555 status_bit: 8 value: '{% if vote.votes_unvoted > 0 %} 1 {% else %} 0 {% endif %}' diff --git a/lib/Alchemy/Phrasea/Command/Feedback/Report/FeedbackReportCommand.php b/lib/Alchemy/Phrasea/Command/Feedback/Report/FeedbackReportCommand.php index 8e2e350eed..a1bf862723 100644 --- a/lib/Alchemy/Phrasea/Command/Feedback/Report/FeedbackReportCommand.php +++ b/lib/Alchemy/Phrasea/Command/Feedback/Report/FeedbackReportCommand.php @@ -35,7 +35,8 @@ public function configure() $this->setName('feedback:report') ->setDescription('Report ended feedback results (votes) on records (set status-bits)') ->addOption('report', null, InputOption::VALUE_REQUIRED, "Report output format (all|condensed)", "all") - ->addOption('dry', null, InputOption::VALUE_NONE, "list translations but don't apply.", null) + ->addOption('min_date', null, InputOption::VALUE_REQUIRED, "Run only for feedbacks expired from this date (yyyy-mm-dd)", null) + ->addOption('dry', null, InputOption::VALUE_NONE, "list records but don't apply.", null) ->setHelp("") ; } @@ -79,6 +80,17 @@ protected function doExecute(InputInterface $input, OutputInterface $output) return 0; } + $min_date_filter = ''; + if( ($min_date = $input->getOption('min_date')) !== null) { + $matches = []; + if(preg_match('/(\d\d\d\d)\D(\d\d)\D(\d\d)/', $min_date, $matches) !== 1) { + $output->writeln(sprintf("bad format for --min_date")); + + return -1; + } + + $min_date_filter = ' AND b.`vote_expires` >= \'' . $matches[1] . '-' . $matches[2] . '-' . $matches[3] . '\''; + } $appbox = $this->getAppBox(); @@ -97,10 +109,10 @@ protected function doExecute(InputInterface $input, OutputInterface $output) MAX(b.`vote_expires`) AS `expired`, be.`id` AS `be_id`, be.`vote_expired` AS `be_vote_expired`, be.`sbas_id`, be.`record_id`, CONCAT(be.`sbas_id`, '_', be.`record_id`) AS `sbid_rid` FROM `BasketElements` AS be INNER JOIN `Baskets` AS b ON b.`id`=be.`basket_id` - WHERE b.`vote_expires` < NOW() + WHERE b.`vote_expires` < NOW()" . $min_date_filter . " GROUP BY `sbid_rid` ) AS q1 - INNER JOIN `BasketParticipants` AS bp ON bp.`basket_id`=q1.`basket_id` + INNER JOIN `BasketParticipants` AS bp ON bp.`can_agree`=1 AND bp.`basket_id`=q1.`basket_id` LEFT JOIN `BasketElementVotes` AS bv ON bv.`participant_id`=bp.`id` AND bv.`basket_element_id`=`be_id` GROUP BY q1.`sbid_rid` HAVING ISNULL(`be_vote_expired`) OR `expired` > `be_vote_expired` diff --git a/lib/Alchemy/Phrasea/Command/Feedback/Report/GlobalConfiguration.php b/lib/Alchemy/Phrasea/Command/Feedback/Report/GlobalConfiguration.php index ac4bc8f98f..d644011d15 100644 --- a/lib/Alchemy/Phrasea/Command/Feedback/Report/GlobalConfiguration.php +++ b/lib/Alchemy/Phrasea/Command/Feedback/Report/GlobalConfiguration.php @@ -165,6 +165,15 @@ public function getActions(\databox $databox): array $this->actions[$sbas_id] = []; foreach($this->configuration['actions'] as $action_name => $action_conf) { + if(array_key_exists('databoxes', $action_conf)) { + if(!is_array($action_conf['databoxes'])) { + $action_conf['databoxes'] = [$action_conf['databoxes']]; + } + // if the current db is not in databoxes list, ignore ths action for this db + if(!in_array($sbas_id, $action_conf['databoxes']) && !in_array($databox->get_dbname(), $action_conf['databoxes'])) { + continue; + } + } if(array_key_exists('status_bit', $action_conf)) { $this->actions[$sbas_id][] = new StatusBitAction($this->twig, $action_conf); }