Merge lp:~mhr3/unity-lens-applications/strip-query into lp:~unity-team/unity-lens-applications/libunity7-compatible

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 337
Merged at revision: 337
Proposed branch: lp:~mhr3/unity-lens-applications/strip-query
Merge into: lp:~unity-team/unity-lens-applications/libunity7-compatible
Diff against target: 94 lines (+14/-12)
1 file modified
src/daemon.vala (+14/-12)
To merge this branch: bzr merge lp:~mhr3/unity-lens-applications/strip-query
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Paweł Stołowski (community) Approve
Review via email: mp+158674@code.launchpad.net

Commit message

String query string before using it to construct DB queries.

Description of the change

String query string before using it to construct DB queries.

This fixes the issue where searching for " " and then changing the filterset will produce empty resultset.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2013-03-22 10:36:48 +0000
3+++ src/daemon.vala 2013-04-12 16:39:24 +0000
4@@ -501,14 +501,15 @@
5 /* We'll clear the model once we finish waiting for the dbus-call
6 * to finish, to prevent flicker. */
7
8- debug ("Searching for: %s", search.search_string);
9+ var search_string = search.search_string.strip ();
10+ debug ("Searching for: %s", search_string);
11
12 var type_filter = search.get_filter ("type") as OptionsFilter;
13
14- string pkg_search_string = XapianUtils.prepare_pkg_search_string (search.search_string, type_filter);
15+ string pkg_search_string = XapianUtils.prepare_pkg_search_string (search_string, type_filter);
16
17 bool has_filter = (type_filter != null && type_filter.filtering);
18- bool has_search = !Utils.is_search_empty (search.search_string);
19+ bool has_search = !Utils.is_search_empty (search_string);
20
21 Timer timer = new Timer ();
22
23@@ -568,7 +569,7 @@
24 // no need to bother
25 return;
26 } catch (GLib.Error e) {
27- warning ("Error performing search '%s': %s", search.search_string, e.message);
28+ warning ("Error performing search '%s': %s", search_string, e.message);
29 }
30 }
31
32@@ -594,7 +595,7 @@
33 else if (has_filter) /* Empty search string + active filters should get lots of results from selected categories */
34 {
35 timer.start ();
36- string? filter_query = XapianUtils.prepare_pkg_search_string (search.search_string, type_filter);
37+ string? filter_query = XapianUtils.prepare_pkg_search_string (search_string, type_filter);
38
39 var pkgresults = pkgsearcher.get_apps (filter_query, MAX_APP_FOR_DOWNLOAD_FOR_EMPTY_QUERY, filter_cb);
40 purchase_info.from_pkgresults (pkgresults);
41@@ -641,7 +642,7 @@
42 // add scopes (if filter is active)
43 if (!has_filter || type_filter.get_option ("scopes").active)
44 {
45- add_remote_scopes_results (search.search_string, model);
46+ add_remote_scopes_results (search_string, model);
47 }
48
49 if (model.get_n_rows () == 0)
50@@ -658,8 +659,9 @@
51 * In global search, with a non-empty search string, we collate all
52 * hits under one Applications category
53 */
54+ var search_string = search.search_string.strip ();
55
56- if (Utils.is_search_empty (search.search_string))
57+ if (Utils.is_search_empty (search_string))
58 {
59 yield update_global_without_search (search, cancellable);
60 return;
61@@ -669,11 +671,11 @@
62
63 model.clear ();
64
65- var search_string = XapianUtils.prepare_pkg_search_string (search.search_string, null);
66+ var pkg_search_string = XapianUtils.prepare_pkg_search_string (search_string, null);
67 Set<string> installed_uris = new HashSet<string> ();
68 Set<string> available_uris = new HashSet<string> ();
69 var timer = new Timer ();
70- var appresults = appsearcher.search (search_string, 0,
71+ var appresults = appsearcher.search (pkg_search_string, 0,
72 Unity.Package.SearchType.PREFIX,
73 Unity.Package.Sort.BY_RELEVANCY);
74 resort_pkg_search_results (appresults);
75@@ -682,7 +684,7 @@
76
77 timer.stop ();
78 debug ("Global search listed %i Installed apps in %fms for query: %s",
79- appresults.num_hits, timer.elapsed ()*1000, search_string);
80+ appresults.num_hits, timer.elapsed ()*1000, pkg_search_string);
81 }
82
83 private async void update_global_without_search (DeprecatedScopeSearch search,
84@@ -700,8 +702,8 @@
85 {
86 try
87 {
88- var zg_search_string = XapianUtils.prepare_zg_search_string (search.search_string,
89- null);
90+ var zg_search_string = XapianUtils.prepare_zg_search_string ("",
91+ null);
92
93 var time_range = new Zeitgeist.TimeRange.anytime ();
94 var results = yield log.find_events (time_range,

Subscribers

People subscribed via source and target branches

to all changes: