viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]
Filename | |
---|---|
controllers/controller.php | |
css/search.css | |
index.php | |
models/datasources/datasource_manager.php | |
models/phrase_model.php | |
views/layouts/web_layout.php | |
views/search_view.php |
diff --git a/controllers/controller.php b/controllers/controller.php index db77a57f8..90cdd8e7b 100755 --- a/controllers/controller.php +++ b/controllers/controller.php @@ -130,11 +130,19 @@ abstract class Controller $model_name = ucfirst($model)."Model"; $model_instance_name = lcfirst($model_name); $data['QUERY_STATISTICS'] = array_merge( - $data['QUERY_STATISTICS'], - $this->$model_instance_name->db->query_log); + $this->$model_instance_name->db->query_log, + $data['QUERY_STATISTICS'] + ); $data['TOTAL_ELAPSED_TIME'] += $this->$model_instance_name->db->total_time; } + $locale_info = getLocaleQueryStatistics(); + $data['QUERY_STATISTICS'] = array_merge( + $locale_info['QUERY_LOG'], + $data['QUERY_STATISTICS'] + ); + $data['TOTAL_ELAPSED_TIME'] += + $locale_info['TOTAL_ELAPSED_TIME']; } $this->$view_instance_name->render($data); } diff --git a/css/search.css b/css/search.css index 09c61dbff..532a19f60 100755 --- a/css/search.css +++ b/css/search.css @@ -146,12 +146,17 @@ body.html-tb-lr border-right: 1px solid #000; } +.landing-spacer +{ + height:5in; +} .html-ltr .landing { position:absolute; top:1.5in; left:12%; min-width:6in; + clear: both; } .html-rtl .landing @@ -251,6 +256,7 @@ body.html-tb-lr background-color: #ddddff; border-width: 2px; border-style: dashed; + } .searchbox p diff --git a/index.php b/index.php index 5c72db80c..4dbd6edc6 100755 --- a/index.php +++ b/index.php @@ -221,6 +221,21 @@ function getLocaleDirection() return $locale->getLocaleDirection(); } +/** + * Returns the query statistics info for the current llocalt. + * + * @return array consisting of queries and elapses times for locale computations + */ +function getLocaleQueryStatistics() +{ + global $locale; + $query_info = array(); + $query_info['QUERY_LOG'] = $locale->db->query_log; + $query_info['TOTAL_ELAPSED_TIME'] = $locale->db->total_time; + return $query_info; +} + + /** * Returns the current locales method of writing blocks (things like divs or * paragraphs).A language like English puts blocks one after another from the diff --git a/models/datasources/datasource_manager.php b/models/datasources/datasource_manager.php index 59083677b..8bec04d18 100755 --- a/models/datasources/datasource_manager.php +++ b/models/datasources/datasource_manager.php @@ -111,8 +111,8 @@ abstract class DatasourceManager } $result =$this->exec($sql); if(QUERY_STATISTICS) { - $query_info['ELASPED_TIME'] = changeInMicrotime($start_time); - $this->total_time += $query_info['ELASPED_TIME']; + $query_info['ELAPSED_TIME'] = changeInMicrotime($start_time); + $this->total_time += $query_info['ELAPSED_TIME']; $this->query_log[] = $query_info; } return $result; diff --git a/models/phrase_model.php b/models/phrase_model.php index 6891e3e96..1ad9a2112 100755 --- a/models/phrase_model.php +++ b/models/phrase_model.php @@ -80,6 +80,13 @@ class PhraseModel extends Model * @var array */ var $additional_meta_words; + + /** + * Used to hold query statistics about the current query + * @var array + */ + var $query_info; + /** * Number of pages to cache in one go in memcache * Size chosen based on 1MB max object size for memcache @@ -188,6 +195,17 @@ class PhraseModel extends Model $input_phrase, $low = 0, $results_per_page = NUM_RESULTS_PER_PAGE, $format = true) { + if(QUERY_STATISTICS) { + $indent= " "; + $in2 = $indent . $indent; + $in3 = $in2 . $indent; + $prs_cnt = 0; + $dis_cnt = 0; + $this->query_info = array(); + $this->query_info['QUERY'] = + "<b>PHRASE QUERY</b>: ".$input_phrase."<br />"; + $start_time = microtime(); + } $results = NULL; $word_structs = array(); /* @@ -262,14 +280,35 @@ class PhraseModel extends Model $low; $disjunct_phrases = explode("|", $phrase); $word_structs = array(); + if(QUERY_STATISTICS) { + $this->query_info['QUERY'] .= $indent . + "<b>Presentation $prs_cnt:</b><br />"; + $this->query_info['QUERY'] .= "$in2<i>Low</i>:". + $result_bounds[0][0]."<br />"; + $this->query_info['QUERY'] .= $in2 . + "<i>High</i>: ".$result_bounds[0][1]."<br />"; + $prs_cnt++; + } + foreach($disjunct_phrases as $disjunct) { + if(QUERY_STATISTICS) { + + $this->query_info['QUERY'] .= "$in2<b>Disjunct $dis_cnt:" + . "</b><br />"; + $dis_cnt++; + } list($word_struct, $format_words) = $this->parseWordStructConjunctiveQuery($disjunct); - if($word_struct != NULL) { $word_structs[] = $word_struct; } } + if(QUERY_STATISTICS) { + $this->query_info['QUERY'] .= + "$in2<b>Presentation Parse time</b>: " . + changeInMicrotime($start_time)."<br />"; + $summaries_time = microtime(); + } $out_results = $this->getSummariesByHash($word_structs, $low, $phrase_num); @@ -291,6 +330,11 @@ class PhraseModel extends Model $total_rows = $out_results['TOTAL_ROWS']; } } + if(QUERY_STATISTICS) { + $this->query_info['QUERY'] .= "$in2<b>Get Summaries time</b>: ". + changeInMicrotime($summaries_time)."<br />"; + $format_time = microtime(); + } } if(isset($results['PAGES'])){ @@ -332,6 +376,13 @@ class PhraseModel extends Model $output = $this->formatPageResults($results, $format_words, $description_length); + if(QUERY_STATISTICS) { + $this->query_info['QUERY'] .= "<b>Format time</b>: ". + changeInMicrotime($format_time)."<br />"; + $this->query_info['ELAPSED_TIME'] = changeInMicrotime($start_time); + $this->db->total_time += $this->query_info['ELAPSED_TIME']; + $this->db->query_log[] = $this->query_info; + } return $output; } @@ -387,6 +438,10 @@ class PhraseModel extends Model */ function parseWordStructConjunctiveQuery($phrase) { + $indent= " "; + $in2 = $indent . $indent; + $in3 = $in2 . $indent; + $in4 = $in2. $in2; $phrase = " ".$phrase; $phrase_string = $phrase; $meta_words = array('link:', 'site:', 'version:', 'modified:', @@ -442,6 +497,20 @@ class PhraseModel extends Model array_keys(PhraseParser::extractPhrasesAndCount($phrase_string, MAX_PHRASE_LEN, getLocaleTag())); //stemmed $words = array_merge($base_words, $found_metas); + if(QUERY_STATISTICS) { + $this->query_info['QUERY'] .= "$in3<i>Index</i>: ". + $index_archive_name."<br />"; + $this->query_info['QUERY'] .= "$in3<i>LocaleTag</i>: ". + getLocaleTag()."<br />"; + $this->query_info['QUERY'] .= "$in3<i>Stemmed Words</i>:<br />"; + foreach($base_words as $word){ + $this->query_info['QUERY'] .= "$in4$word<br />"; + } + $this->query_info['QUERY'] .= "$in3<i>Meta Words</i>:<br />"; + foreach($found_metas as $word){ + $this->query_info['QUERY'] .= "$in4$word<br />"; + } + } if(isset($words) && count($words) == 1 && count($disallow_phrases) < 1) { $phrase_string = $words[0]; diff --git a/views/layouts/web_layout.php b/views/layouts/web_layout.php index 64e6504c3..a10cbb539 100755 --- a/views/layouts/web_layout.php +++ b/views/layouts/web_layout.php @@ -87,12 +87,12 @@ class WebLayout extends Layout <?php e("<h1>".tl('web_layout_query_statistics')."</h1>"); e("<b>".tl('web_layout_total_elapsed_time', - $data['TOTAL_ELAPSED_TIME'])."</b>"); + $data['TOTAL_ELAPSED_TIME'])."</b>"); foreach($data['QUERY_STATISTICS'] as $query_info) { e("<div class='query'><div>".$query_info['QUERY']. "</div><div><b>". tl('web_layout_query_time', - $query_info['ELASPED_TIME']). + $query_info['ELAPSED_TIME']). "</b></div></div>"); } ?> diff --git a/views/search_view.php b/views/search_view.php index 2e94fce80..75cb8c1bc 100755 --- a/views/search_view.php +++ b/views/search_view.php @@ -208,7 +208,7 @@ class SearchView extends View implements CrawlConstants </div><?php if(!isset($data['PAGES'])) { - e("</div>"); + e("</div><div class='landing-spacer'></div>"); } }