Plugin Directory

Changeset 1099096


Ignore:
Timestamp:
02/25/2015 10:03:29 AM (11 years ago)
Author:
naveenann
Message:

Working on synchronizing data with CRON

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opensearchserver-search/trunk/opensearchserver_admin.php

    r1098191 r1099096  
    234234function opensearchserver_reindex_site_with_cron() {
    235235  global $wpdb;
    236   opensearchserver_reindex_init();
     236  $lang = get_option('oss_language', '');
    237237  opensearchserver_delete_document('*:*');
    238    $contentTypesToKeep = array();
    239     foreach (get_post_types() as $post_type) {
    240         if (get_option('oss_index_types_'.$post_type) == 1) {
    241             $contentTypesToKeep[] = $post_type;
    242         }
    243     }
    244     $sql_query = 'SELECT ID FROM '.$wpdb->posts.' WHERE post_status = \'publish\' AND post_type IN ("'.implode('","', $contentTypesToKeep).'") ORDER BY ID'.$limitSuffix;
    245     $posts = $wpdb->get_results($sql_query);
    246     $total_count = count($posts);
    247     $index = new OSSIndexDocument();
    248     for ($i = 0; $i < $total_count; $i++) {
    249       $post = get_post($posts[$i]->ID);
    250       opensearchserver_add_documents_to_index($index, $lang, $post);
    251       $index = opensearchserver_checkindex($index, 200, $i, $total_count, FALSE);
    252     }
    253     opensearchserver_checkindex($index, 1, $i, $total_count,FALSE);
     238  $contentTypesToKeep = array();
     239  foreach (get_post_types() as $post_type) {
     240    if (get_option('oss_index_types_'.$post_type) == 1) {
     241        $contentTypesToKeep[] = $post_type; 
     242    }
     243  }
     244  $sql_query = 'SELECT ID FROM '.$wpdb->posts.' WHERE post_status = \'publish\' AND post_type IN ("'.implode('","', $contentTypesToKeep).'") ORDER BY ID';
     245  $posts = $wpdb->get_results($sql_query);
     246  $total_count = count($posts);
     247  $index = new OSSIndexDocument();
     248  for ($i = 0; $i < $total_count; $i++) {
     249    $post = get_post($posts[$i]->ID);
     250    opensearchserver_add_documents_to_index($index, $lang, $post);
     251    $index = opensearchserver_checkindex($index, 200, $i, $total_count, FALSE);
     252  }
     253  opensearchserver_checkindex($index, 1, $i, $total_count,FALSE);
    254254  opensearchserver_optimize();
    255255  opensearchserver_autocompletionBuild();
    256256  return 1;
    257257}
    258 /*
    259  * Function to initialize the variable for reindex.
    260 */
    261 function opensearchserver_reindex_init() {
    262   global $wpdb;
    263   $oss_server_url = get_option('oss_serverurl');
    264   $oss_indexname = get_option('oss_indexname');
    265   $oss_login =  get_option('oss_login');
    266   $oss_key = get_option('oss_key');
    267   $lang = get_option('oss_language', '');
    268   $table_name_posts =$wpdb->prefix ."posts";
    269   $table_name_users =$wpdb->prefix ."users";
    270   $index_status=0;
    271   $ossEnginePath  = config_request_value('ossEnginePath', $oss_server_url, 'engineURL');
    272   $ossEngineConnectTimeOut = config_request_value('ossEngineConnectTimeOut', 5, 'engineConnectTimeOut');
    273   $ossEngineIndex = config_request_value('ossEngineIndex', $oss_indexname, 'engineIndex');
    274 }
     258
    275259/*
    276260 * Function to reindex the website.
    277261*/
    278 function opensearchserver_reindex_site($id,$type, $from = 0, $to = 0) {
     262function opensearchserver_reindex_site($id, $type, $from = 0, $to = 0) {
    279263  global $wpdb;
    280   opensearchserver_reindex_init();
     264  $lang = get_option('oss_language', '');
    281265  if($id) {
    282266    $delete='id:'.$type.'_'.$id;
     
    895879  $post_oss_submit = $_POST['opensearchserver_submit'];
    896880  if($post_oss_submit == 'Synchronize with CRON') {
    897     wp_schedule_single_event(time(), 'synchronize_with_cron');
     881    wp_schedule_single_event(time() + 900, 'synchronize_with_cron');
    898882    opensearchserver_display_messages('Re indexing has been successfully scheduled with cron will be executed in next 15 minutes.');
    899883  }else {
Note: See TracChangeset for help on using the changeset viewer.