From b8aa0ccd678e0ebf325282fb4b5b2328157fbcb4 Mon Sep 17 00:00:00 2001 From: RouxRC Date: Tue, 2 Oct 2018 02:09:15 +0200 Subject: [PATCH] handle case of scrutins with only votes pour for motions de censure votes 1114 & 1115 cf #115 --- lib/model/doctrine/Scrutin.class.php | 8 ++++++-- lib/task/loadScrutinsTask.class.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/model/doctrine/Scrutin.class.php b/lib/model/doctrine/Scrutin.class.php index 3e1d9890b..b00692f12 100644 --- a/lib/model/doctrine/Scrutin.class.php +++ b/lib/model/doctrine/Scrutin.class.php @@ -36,7 +36,7 @@ public function tagIntervention() { $inters = Doctrine::getTable('Intervention') ->createQuery('i') ->where('i.seance_id = ?', $this->seance_id) - ->andWhere("i.intervention LIKE '%nombre de votants%suffrages exprimés%pour%contre%'") + ->andWhere("i.intervention LIKE '%nombre de votants%suffrages exprimés%pour%contre%' OR i.intervention LIKE '%Majorité requise pour l\'adoption%pour l\'adoption%'") // ->andWhere("i.intervention LIKE '%table class=\"scrutin\"%'") ->orderBy('i.timestamp') ->execute(); @@ -53,7 +53,11 @@ public function tagIntervention() { $mp = preg_match_all('/pour l\'(?:adoption|approbation)(?:<\/td>|[,\s]*)(\d+)/i', $text, $match_pour); $mc = preg_match_all('/contre(?:<\/td>|[,\s])(\d+)/i', $text, $match_contre); - if ($mv == 0 || $mp == 0 || $mc == 0) { + if (preg_match("/Majorité requise pour l'adoption/", $text) && $mp != 0 && intval(end($match_pour[1])) == $this->nombre_votants && intval(end($match_pour[1])) == $this->nombre_pours) { + $found = TRUE; + $inter->addTag("scrutin:numero={$this->numero}"); + break; + } elseif ($mv == 0 || $mp == 0 || $mc == 0) { echo "WARNING: décomptes intervention {$inter->id} incomplets :\n$text\n"; } elseif (intval(end($match_votant[1])) != $this->nombre_votants || intval(end($match_pour[1])) != $this->nombre_pours diff --git a/lib/task/loadScrutinsTask.class.php b/lib/task/loadScrutinsTask.class.php index 595bb7566..9d6275fd8 100644 --- a/lib/task/loadScrutinsTask.class.php +++ b/lib/task/loadScrutinsTask.class.php @@ -110,7 +110,7 @@ protected function execute($arguments = array(), $options = array()) ->createQuery("i") ->select("count(1) as cnt") ->where("i.seance_id = ?", $seance->id) - ->andWhere("i.intervention LIKE '%nombre de votants%suffrages exprimés%pour%contre%'") + ->andWhere("i.intervention LIKE '%nombre de votants%suffrages exprimés%pour%contre%' OR i.intervention LIKE '%Majorité requise pour l\'adoption%pour l\'adoption%'") // ->andWhere("i.intervention LIKE '%fetchOne()['cnt'];