Indefero

Indefero Commit Details


Date:2008-11-22 07:17:26 (16 years 1 month ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:c86cf6e5f1bc94aa457fe9d5eaa61eb95cb8f9b0
Parents: d8870e6df0b923a3e013cd496dcaffaa0ffe4d0e
Message:Fixed issue 62, crash when searching in the issues.

The issue search is now correctly limiting the search to the issues.
Changes:

File differences

src/IDF/Search.php
4343
4444
4545
46
47
46
47
48
4849
49
50
5051
5152
5253
......
6162
6263
6364
64
65
6566
6667
6768
......
7273
7374
7475
76
7577
7678
77
79
7880
7981
8082
......
8385
8486
8587
86
88
89
8790
8891
8992
*
* @param string Query string.
* @param int Project id to limit the results (null)
* @param string Stemmer class.
* @return array Results.
* @param string Model class (null)
* @param string Stemmer class ('Pluf_Text_Stemmer_Porter')
* @return array Results
*/
public static function mySearch($query, $project=null, $stemmer='Pluf_Text_Stemmer_Porter')
public static function mySearch($query, $project=null, $model=null, $stemmer='Pluf_Text_Stemmer_Porter')
{
$query = Pluf_Text::cleanString(html_entity_decode($query, ENT_QUOTES, 'UTF-8'));
$words = Pluf_Text::tokenize($query);
if (in_array(null, $word_ids)) {
return array();
}
return self::mySearchDocuments($word_ids, $project);
return self::mySearchDocuments($word_ids, $project, $model);
}
/**
*
* @param array Ids.
* @param IDF_Project Project to limit the search.
* @param string Model class to limit the search.
* @return array Sorted by score, returns model_class, model_id and score.
*/
public static function mySearchDocuments($wids, $project)
public static function mySearchDocuments($wids, $project, $model)
{
$db =& Pluf::db();
$gocc = new IDF_Search_Occ();
$where[] = $db->qn('word').'='.(int)$id;
}
$prj = (is_null($project)) ? '' : ' AND project='.(int)$project->id;
$select = 'SELECT model_class, model_id, SUM(pondocc) AS score FROM '.$gocc->getSqlTable().' WHERE '.implode(' OR ', $where).$prj.' GROUP BY model_class, model_id HAVING COUNT(*)='.count($wids).' ORDER BY score DESC';
$md = (is_null($model)) ? '' : ' AND model_class='.$db->esc($model);
$select = 'SELECT model_class, model_id, SUM(pondocc) AS score FROM '.$gocc->getSqlTable().' WHERE '.implode(' OR ', $where).$prj.$md.' GROUP BY model_class, model_id HAVING COUNT(*)='.count($wids).' ORDER BY score DESC';
return $db->select($select);
}
src/IDF/Views/Issue.php
198198
199199
200200
201
201
202202
203203
204204
}
$q = $request->REQUEST['q'];
$title = sprintf(__('Search Issues - %s'), Pluf_esc($q));
$issues = new Pluf_Search_ResultSet(IDF_Search::mySearch($q, $prj));
$issues = new Pluf_Search_ResultSet(IDF_Search::mySearch($q, $prj, 'IDF_Issue'));
if (count($issues) > 100) {
// no more than 100 results as we do not care
$issues->results = array_slice($issues->results, 0, 100);

Archive Download the corresponding diff file

Page rendered in 0.07311s using 14 queries.