<?php

require '../../boot.php';
list($cmd, $supporter_KEY) = $argv;
#$supporter_KEY = 48965489;
$supporter_query = $db->query("SELECT * FROM supporter WHERE supporter_KEY=" . $supporter_KEY);
if ($supporter_query->num_rows > 0) {
    while ($supporter_arr = $supporter_query->fetch_assoc()) {
        $supporter = new Supporter($supporter_arr);
        $supporter->process();
        #$supporter->geovalidate();
        $supporter->updateDonationCounts();
        $supporter->updateActionCounts();
        $supporter->updateEmailCounts();
        $supporter->updateUnsubscribeInfo();
        $supporter->updateSupporterTypes();
        //$supporter->db_update();
        $supporter->data['key'] = $supporter->data['supporter_KEY'];
        //$dia->save('supporter', $supporter->data);
    }
}
echo '<pre>' . print_r($supporter) . '</pre>';
 function testCountEmailsClickedPastYear()
 {
     $s = new Supporter(array('supporter_KEY' => 67));
     $emails = array(array('supporter_KEY' => 67, 'email_KEY' => 17, 'Time_Sent' => date("Y-m-d H:i:s", strtotime("-7 months")), 'Status' => 'Opened'), array('supporter_KEY' => 67, 'email_KEY' => 18, 'Time_Sent' => date("Y-m-d H:i:s", strtotime("-9 months")), 'Status' => 'Sent and Clicked'), array('supporter_KEY' => 67, 'email_KEY' => 19, 'Time_Sent' => date("Y-m-d H:i:s", strtotime("-13 months"))), array('supporter_KEY' => 68, 'email_KEY' => 20, 'Time_Sent' => date("Y-m-d H:i:s", strtotime("-7 months"))));
     foreach ($emails as $email) {
         $e = new Email($email);
         $e->db_insert();
     }
     $s->updateEmailCounts();
     $this->assertEqual($s->data['data__emails_clicked_past_year'], 1);
 }