Skip to content

Commit

Permalink
ignore non voters ; add --min_date option ; add databoxes filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jygaulier committed Dec 13, 2023
1 parent 0b9a3e0 commit 5c6317d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion config/configuration.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
;
}
Expand Down Expand Up @@ -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("<error>bad format for --min_date</error>"));

return -1;
}

$min_date_filter = ' AND b.`vote_expires` >= \'' . $matches[1] . '-' . $matches[2] . '-' . $matches[3] . '\'';
}

$appbox = $this->getAppBox();

Expand All @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5c6317d

Please sign in to comment.