Skip to content

Commit a4cd354

Browse files
committed
[smarcet]
* updates on election purge process
1 parent 297293b commit a4cd354

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

elections/code/cron_tasks/RevocationNotificationSenderTask.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ function run(){
3535

3636
try{
3737

38-
$batch_size = 100;
38+
$batch_size = 1000;
3939
$max_past_elections = 2 ;
4040

4141
if(isset($_GET['batch_size'])){
4242
$batch_size = intval(trim(Convert::raw2sql($_GET['batch_size'])));
4343
}
4444

45+
if(isset($_GET['max_past_elections'])){
46+
$max_past_elections = intval(trim(Convert::raw2sql($_GET['max_past_elections'])));
47+
}
48+
4549
$count = $this->manager->sendOutNotifications
4650
(
4751
$max_past_elections,

elections/code/model/ElectionManager.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ public function ingestVotersForElection($filename, $election_id){
105105
throw new NotFoundEntityException('Election');
106106
}
107107

108-
if($election->VoterFileID > 0){
109-
throw new EntityValidationException("Election already processed a voter file!");
110-
}
111-
112108
$reader = new CSVReader($filename);
113109
$line = false;
114110
$header = $reader->getLine();
@@ -161,6 +157,17 @@ public function ingestVotersForElection($filename, $election_id){
161157
continue;
162158
}
163159

160+
if(ElectionVote::get()->filter([
161+
'VoterID' => $member_2_process->ID,
162+
'ElectionID' => $election->ID,
163+
164+
])->count() > 0 )
165+
{
166+
$output .= sprintf("member id %s - first_name %s - last_name %s already voted as member id %s", $member_id, $first_name, $last_name, $member_2_process->ID).PHP_EOL;
167+
$not_processed[] = ['id' => $member_id, 'first_name' => $first_name, 'last_name' => $last_name];
168+
continue;
169+
}
170+
164171
$output .= sprintf("processed member id %s - first_name %s - last_name %s OK", $member_id, $first_name, $last_name).PHP_EOL;
165172
$vote = $this->vote_factory->buildVote($election, $member_2_process);
166173
$vote->write();

elections/code/model/FoundationMembershipRevocationSpecification.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ public function sql($latest_elections_qty, $necessary_votes, IElectionRepository
6767
foreach($elections as $election)
6868
array_push($elections_id, $election->getIdentifier());
6969

70-
$elections_id = implode(',',$elections_id);
70+
$elections_id = implode(',',$elections_id);
7171
$election_time_zone = $latest_election->getEntityTimeZone();
7272
$cut_date = new DateTime('2014-01-13', $election_time_zone);
7373
$election_open_date = new DateTime($latest_election->getElectionsOpen(), $election_time_zone);
74+
7475
if($election_open_date <= $cut_date) { // until January 2014
7576
$sql = <<<SQL
7677
-- members that did not vote on any latest election

0 commit comments

Comments
 (0)