Changeset 1440


Ignore:
Timestamp:
Sep 26, 2010, 9:57:55 PM (10 years ago)
Author:
teymour
Message:

Si pas de résultat on revient dans PERIOD seconds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/lib/task/sendAlertTask.class.php

    r1438 r1440  
    1212  }
    1313 
     14  protected static $period = array('HOUR' => 3600, 'DAY' => 86400, 'WEEK' => 604800, 'MONTH' => 2592000);
     15
    1416  protected function execute($arguments = array(), $options = array())
    1517  {
     
    2022   
    2123    $solr = new SolrConnector();
    22     $query = Doctrine::getTable('Alerte')->createQuery('a')->where('next_mail < NOW()');
     24    $query = Doctrine::getTable('Alerte')->createQuery('a')->where('next_mail < NOW()')->andWhere('confirmed = 1');
    2325    foreach($query->execute() as $alerte) {
    2426      $date = strtotime(preg_replace('/ /', 'T', $alerte->last_mail)."Z")-3600*2;
    2527      $query = $alerte->query." date:[".date('Y-m-d', $date).'T'.date('H:i:s', $date)."Z TO ".date('Y-m-d').'T'.date('H:i:s')."Z]";
    2628      $results = $solr->search($query, array('sort' => 'date desc', 'hl' => 'yes', 'hl.fragsize'=>500));
    27       echo "$query\n";
    28       if (! $results['response']['numFound'])
     29      $alerte->next_mail = date('Y-m-d H:i:s', time() + self::$period[$alerte->period]);
     30      echo $alerte->next_mail." $query\n";
     31      if (! $results['response']['numFound']) {
     32        $alerte->save();
    2933        continue;
     34      }
    3035      echo "sending mail to : ".$alerte->email."\n";
    3136      $message = $this->getMailer()->compose(array('no-reply@nosdeputes.fr' => 'Regards Citoyens (ne pas répondre)'),
Note: See TracChangeset for help on using the changeset viewer.