Example #1
0
 public function process_covers($break, $limit)
 {
     $num_found = 0;
     $not_found = array();
     $total = 0;
     //$db = MDB2::connect($this->dsn);
     $couch = new couchClient($this->couchserver, $this->couchdatabase);
     // Grab items that don't have covers
     if ($break !== 0) {
         $nocovers = $couch->asArray()->limit($limit)->startkey((string) $break)->descending(true)->getView('bib', 'covercache');
     } else {
         $nocovers = $couch->asArray()->limit($limit)->descending(true)->getView('bib', 'covercache');
     }
     foreach ($nocovers['rows'] as $bib) {
         $total++;
         if ($bib['value']) {
             // clean the stdnum field to just the number
             ereg("^[0-9a-zA-Z]+", $bib['value'][0], $regs);
             $bib['stdnum'] = array($regs[0]);
             if ($this->cli) {
                 echo $bib['id'] . ": ";
             }
             if ($cover = self::get_coverimage($bib)) {
                 $this->putlog($cover['stdnum'] . "::" . $cover['image_url']);
                 $num_found++;
                 if (self::create_covercache($bib['id'], $cover['image_url'], $cover['stdnum'])) {
                     $this->putlog("SUCCESS: " . $bib['id']);
                 } else {
                     $this->putlog("ERROR CREATING CACHE: " . $bib['id']);
                 }
             } else {
                 // Update covercache table to record timestamp of failure
                 //$db->query("REPLACE INTO locum_covercache SET bnum = " . $bib['id'] . ", cover_stdnum = ''");
                 //$not_found++;
             }
         }
     }
     if ($this->cli) {
         $end_time = time();
         $percentage = number_format($num_found / $total * 100, 2);
         $average = number_format(($end_time - $this->start_time) / $total, 2);
         echo "\nPROCESSING COMPLETE: {$num_found} / {$total} ({$percentage}%)\n";
         echo "TIME: " . date("m/d/Y H:i:s", $this->start_time) . "-" . date("m/d/Y H:i:s", $end_time);
         echo " ({$average} sec. avg.)\n";
         echo "\nLOOKUP COUNT: " . $this->lookup_count . " XISBN COUNT: " . $this->xisbn_count . "\n";
         foreach ($this->sources_count as $id => $count) {
             echo $id . " COUNT: " . $count . " ";
         }
         echo "\n";
     }
 }
Example #2
0
 function ajaxissuedetailAction()
 {
     $this->_helper->layout->disableLayout();
     $idString = $this->_request->getParam('key');
     if ($idString) {
         $config = Zend_Registry::get('config');
         $topicsClient = new couchClient($config->couchdb->uri . ":" . $config->couchdb->port, $config->couchdb->topics);
         $doc = $topicsClient->asArray()->getDoc(urldecode($idString));
         if (!isset($doc['error'])) {
             $this->view->issue = $doc;
         }
     }
 }
Example #3
0
 public function get_bib_items($bnum_arr)
 {
     if (is_callable(array(__CLASS__ . '_hook', __FUNCTION__))) {
         eval('$hook = new ' . __CLASS__ . '_hook;');
         return $hook->{__FUNCTION__}($bnum_arr);
     }
     if (count($bnum_arr)) {
         $couch = new couchClient($this->couchserver, $this->couchdatabase);
         try {
             $doc = $couch->asArray()->include_docs(true)->keys($bnum_arr)->getAllDocs();
         } catch (Exception $e) {
             return FALSE;
         }
     }
     return $doc['rows'];
 }