Ejemplo n.º 1
0
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     // cleanup Lucene index
     $index = JobeetJobTable::getLuceneIndex();
     $q = Doctrine_Query::create()->from('JobeetJob j')->where('j.expires_at < ?', date('Y-m-d'));
     $jobs = $q->execute();
     foreach ($jobs as $job) {
         if ($hit = $index->find('pk:' . $job->getId())) {
             $index->delete($hit->id);
         }
     }
     $index->optimize();
     $this->logSection('lucene', 'Cleaned up and optimized the job index');
     // Remove stale jobs
     $nb = Doctrine_Core::getTable('JobeetJob')->cleanup($options['days']);
     $this->logSection('doctrine', sprintf('Removed %d stale jobs', $nb));
 }
Ejemplo n.º 2
0
 public function updateLuceneIndex()
 {
     $index = JobeetJobTable::getLuceneIndex();
     // remove existing entries
     foreach ($index->find('pk:' . $this->getId()) as $hit) {
         $index->delete($hit->id);
     }
     // don't index expired and non-activated jobs
     if ($this->isExpired() || !$this->getIsActivated()) {
         return;
     }
     $doc = new Zend_Search_Lucene_Document();
     // store job primary key to identify it in the search results
     $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId()));
     // index job fields
     $doc->addField(Zend_Search_Lucene_Field::UnStored('position', $this->getPosition(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('company', $this->getCompany(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('location', $this->getLocation(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('description', $this->getDescription(), 'utf-8'));
     // add job to the index
     $index->addDocument($doc);
     $index->commit();
 }
Ejemplo n.º 3
0
 /**
  * Удаление вакансии 
  */
 public function delete(Doctrine_Connection $conn = null)
 {
     $index = JobeetJobTable::getLuceneIndex();
     foreach ($index->find('pk:' . $this->getId()) as $hit) {
         $index->delete($hit->id);
     }
     return parent::delete($conn);
 }