Changeset 45261

Show
Ignore:
Timestamp:
05/11/08 17:25:33 (2 months ago)
Author:
misterbisson
Message:

alpha

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bsuite/trunk/core.php

    r44934 r45261  
    192192            add_filter('cron_schedules', array(&$this, 'cron_reccurences')); 
    193193            if( $this->loadavg < 4 ){ // only do cron if load is low-ish 
    194                   add_filter('bsuite_interval', array(&$this, 'bstat_migrator')); 
     194//                add_filter('bsuite_interval', array(&$this, 'bstat_migrator')); 
    195195//                add_filter('bsuite_interval', array(&$this, 'searchsmart_upindex_passive')); 
    196196            } 
     
    616616 
    617617            if (  
    618                   ( get_option('bsuite_doing_migration') > time() ) ||  
    619                   ( get_option('bsuite_doing_report') > time() ) 
     618                  ( get_option( 'bsuite_doing_migration') > time() ) ||  
     619                  ( get_option( 'bsuite_doing_report') > time() ) 
    620620            ) 
    621621                  return( TRUE ); 
    622622 
    623             update_option('bsuite_doing_migration', time() + 250 ); 
     623            update_option( 'bsuite_doing_migration', time() + 250 ); 
     624            $status = get_option ( 'bsuite_doing_migration_status' ); 
    624625 
    625626            $getcount = 100; 
     
    633634                  LIMIT $getcount" ); 
    634635             
     636            $status['count_incoming'] = count( $res ); 
     637            update_option( 'bsuite_doing_migration_status', $status ); 
     638 
    635639            foreach( $res as $hit ){ 
    636640                  $object_id = $object_type = $session_id = 0; 
     
    671675            } 
    672676 
    673             if( count( $targets )){ 
     677            $status['count_targets'] = count( $targets ); 
     678            $status['count_searchwords'] = count( $searchwords ); 
     679            $status['count_shistory'] = count( $shistory ); 
     680            update_option( 'bsuite_doing_migration_status', $status ); 
     681 
     682            if( count( $targets ) && !$status['did_targets'] ){ 
    674683                  if ( false === $wpdb->query( "INSERT INTO $this->hits_targets (object_id, object_type, hit_count, hit_date) VALUES ". implode( $targets, ',' ) ." ON DUPLICATE KEY UPDATE hit_count = hit_count + 1;" )) 
    675684                        return new WP_Error('db_insert_error', __('Could not insert bsuite_hits_target into the database'), $wpdb->last_error); 
    676             } 
    677              
    678             if( count( $searchwords )){ 
     685 
     686                  $status['did_targets'] = 1 ; 
     687                  update_option( 'bsuite_doing_migration_status', $status ); 
     688            } 
     689             
     690            if( count( $searchwords ) && !$status['did_searchwords'] ){ 
    679691                  if ( false === $wpdb->query( "INSERT INTO $this->hits_searchwords (object_id, object_type, term_id, hit_count, hit_date) VALUES ". implode( $searchwords, ',' ) ." ON DUPLICATE KEY UPDATE hit_count = hit_count + 1;" )) 
    680692                        return new WP_Error('db_insert_error', __('Could not insert bsuite_hits_searchword into the database'), $wpdb->last_error); 
    681             } 
    682  
    683             if( count( $shistory )){ 
     693 
     694                  $status['did_searchwords'] = 1; 
     695                  update_option( 'bsuite_doing_migration_status', $status ); 
     696            } 
     697 
     698            if( count( $shistory ) && !$status['did_shistory'] ){ 
    684699                  if ( false === $wpdb->query( "INSERT INTO $this->hits_shistory (sess_id, object_id, object_type) VALUES ". implode( $shistory, ',' ) .';' )) 
    685700                        return new WP_Error('db_insert_error', __('Could not insert bsuite_hits_session_history into the database'), $wpdb->last_error); 
     701 
     702                  $status['did_shistory'] = count( $shistory ); 
     703                  update_option( 'bsuite_doing_migration_status', $status ); 
    686704            } 
    687705 
    688706            if( count( $res )){ 
    689707                  if ( false === $wpdb->query( "DELETE FROM $this->hits_incoming WHERE in_time < '$since' ORDER BY in_time ASC LIMIT ". count( $res ) .';')) 
    690                         return new WP_Error('db_insert_error', __('Could not clean up the incomin stats table'), $wpdb->last_error); 
     708                        return new WP_Error('db_insert_error', __('Could not clean up the incoming stats table'), $wpdb->last_error); 
    691709                  if( $getcount > count( $res )) 
    692710                        $wpdb->query( "OPTIMIZE TABLE $this->hits_incoming;"); 
     
    733751 
    734752            update_option( 'bsuite_doing_migration', 0 ); 
     753            update_option( 'bsuite_doing_migration_status', array() ); 
    735754            return(TRUE); 
    736755      }