Merge lp:~mhr3/libunity/invalidate-on-subscopes into lp:~unity-team/libunity/libunity-7.0

Proposed by Michal Hruby on 2013-04-30
Status: Merged
Approved by: Paweł Stołowski on 2013-04-30
Approved revision: 375
Merged at revision: 373
Proposed branch: lp:~mhr3/libunity/invalidate-on-subscopes
Merge into: lp:~unity-team/libunity/libunity-7.0
Diff against target: 153 lines (+55/-9)
5 files modified
src/unity-aggregator-scope-private.vala (+19/-6)
src/unity-master-scope.vala (+1/-1)
src/unity-scope-channel.vala (+1/-0)
src/unity-utils.vala (+1/-0)
test/vala/test-scope.vala (+33/-2)
To merge this branch: bzr merge lp:~mhr3/libunity/invalidate-on-subscopes
Reviewer Review Type Date Requested Status
Paweł Stołowski 2013-04-30 Approve on 2013-04-30
PS Jenkins bot (community) continuous-integration Approve on 2013-04-30
Review via email: mp+161543@code.launchpad.net

Commit message

Invalidate cached resultset if subscopes filter is provided.

Description of the change

Invalidate cached resultset if subscopes filter is provided.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
375. By Michal Hruby on 2013-04-30

Update subscopes hint

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Paweł Stołowski (stolowski) wrote :

Looks good and works fine. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-aggregator-scope-private.vala'
2--- src/unity-aggregator-scope-private.vala 2013-04-26 10:20:06 +0000
3+++ src/unity-aggregator-scope-private.vala 2013-04-30 16:23:36 +0000
4@@ -1425,11 +1425,22 @@
5 if (filter_row_variant != null)
6 {
7 update_filter_state (channel, filter_row_variant);
8- if (channel.last_search != null)
9- {
10- channel.last_search.search_context.cancellable.cancel ();
11- channel.last_search = null;
12- }
13+ }
14+
15+ unowned Variant subscopes_filter_variant = hints[SEARCH_SUBSCOPES_HINT];
16+ uint subscope_filter_tag = 0;
17+ if (subscopes_filter_variant != null && subscopes_filter_variant.get_type_string () == "as")
18+ {
19+ string[] subscopes = (string[]) subscopes_filter_variant;
20+ subscope_filter_tag = string.joinv (";", subscopes).hash ();
21+ }
22+
23+ bool invalidate_last_search = filter_row_variant != null;
24+
25+ if (invalidate_last_search && channel.last_search != null)
26+ {
27+ channel.last_search.search_context.cancellable.cancel ();
28+ channel.last_search = null;
29 }
30
31 // did the search change?
32@@ -1438,7 +1449,8 @@
33 {
34 // FIXME: take result set's TTL into consideration when scopes
35 // properly set it
36- if (last_search.search_context.search_query == search_string)
37+ if (last_search.search_context.search_query == search_string
38+ && channel.last_search_tag == subscope_filter_tag)
39 {
40 if (channel.is_search_running ())
41 {
42@@ -1522,6 +1534,7 @@
43 });
44
45 channel.last_search = aggsearch;
46+ channel.last_search_tag = subscope_filter_tag;
47 // we need to wait for the cancelled search to clean up the channel state
48 if (channel.is_search_running ())
49 {
50
51=== modified file 'src/unity-master-scope.vala'
52--- src/unity-master-scope.vala 2013-04-12 13:39:42 +0000
53+++ src/unity-master-scope.vala 2013-04-30 16:23:36 +0000
54@@ -111,7 +111,7 @@
55
56 string[] search_subscopes = {};
57
58- var filter_variant = scope_search.hints["subscopes_filter"];
59+ var filter_variant = scope_search.hints[Internal.SEARCH_SUBSCOPES_HINT];
60 if (filter_variant != null && filter_variant.get_type_string () == "as")
61 {
62 search_subscopes = (string[]) filter_variant;
63
64=== modified file 'src/unity-scope-channel.vala'
65--- src/unity-scope-channel.vala 2013-04-25 15:16:59 +0000
66+++ src/unity-scope-channel.vala 2013-04-30 16:23:36 +0000
67@@ -48,6 +48,7 @@
68 public string id;
69
70 public ScopeSearchBase? last_search;
71+ public uint last_search_tag;
72
73 private ChannelState state;
74 private Utils.DelegateWrapper[] callbacks = {};
75
76=== modified file 'src/unity-utils.vala'
77--- src/unity-utils.vala 2013-04-25 10:22:08 +0000
78+++ src/unity-utils.vala 2013-04-30 16:23:36 +0000
79@@ -85,6 +85,7 @@
80 internal const string SEARCH_FILTER_ROW_HINT = "changed-filter-row";
81 internal const string SEARCH_SEQNUM_HINT = "model-seqnum";
82 internal const string SEARCH_TIME_HINT = "search-time";
83+internal const string SEARCH_SUBSCOPES_HINT = "subscopes-filter";
84 internal const string SEARCH_NO_RESULTS_HINT = "no-results-hint";
85
86 internal const string ACTIVATE_PREVIEW_ACTION_HINT = "preview-action-id";
87
88=== modified file 'test/vala/test-scope.vala'
89--- test/vala/test-scope.vala 2013-04-25 15:17:15 +0000
90+++ test/vala/test-scope.vala 2013-04-30 16:23:36 +0000
91@@ -139,6 +139,8 @@
92 Fixture.create<MasterScopeTester> (MasterScopeTester.test_push_results));
93 Test.add_data_func ("/Unit/MasterScope/PushAndSearch",
94 Fixture.create<MasterScopeTester> (MasterScopeTester.test_push_results_and_search));
95+ Test.add_data_func ("/Unit/MasterScope/SubscopesSearch",
96+ Fixture.create<MasterScopeTester> (MasterScopeTester.test_subscopes_search));
97 Test.add_data_func ("/Unit/AggregatorScope/CategoryOrderSignal",
98 Fixture.create<AggregatorScopeTester> (AggregatorScopeTester.test_scope_category_order_signal));
99
100@@ -727,7 +729,7 @@
101 var ml = new MainLoop ();
102 Unity.Protocol.ActivationReplyRaw? activation_reply = null;
103 var hints = new HashTable<string, Variant> (str_hash, str_equal);
104- hints["preview-action-id"] = PREVIEW_TEST_ACTION;
105+ hints[Unity.Internal.ACTIVATE_PREVIEW_ACTION_HINT] = PREVIEW_TEST_ACTION;
106 proxy.activate.begin (channel_id, scope_result_to_variant (result),
107 Unity.Protocol.ActionType.PREVIEW_ACTION,
108 hints, null,
109@@ -1415,7 +1417,7 @@
110
111 var hints = new HashTable<string, Variant> (str_hash, str_equal);
112 string[] subscopes = {"test_masterscope-childscope_1.scope"};
113- hints ["subscopes_filter"] = new GLib.Variant.strv (subscopes);
114+ hints [Unity.Internal.SEARCH_SUBSCOPES_HINT] = new GLib.Variant.strv (subscopes);
115
116 var reply_dict = ScopeTester.perform_search (proxy, channel_id, "", hints, model);
117 assert (reply_dict != null);
118@@ -1493,6 +1495,35 @@
119 }
120 assert (pushed_result_found);
121 }
122+
123+ public void test_subscopes_search ()
124+ {
125+ assert (proxy != null);
126+
127+ Dee.SerializableModel model;
128+ var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT, out model);
129+ assert (channel_id != null);
130+
131+ var hints = new HashTable<string, Variant> (str_hash, str_equal);
132+ var reply_dict = ScopeTester.perform_search (proxy, channel_id, "foo",
133+ hints, model);
134+
135+ assert (reply_dict != null);
136+ // standard search, should invoke all subscopes
137+ assert (search_handler_invocations == child_scopes.length);
138+ assert (model.get_n_rows () == child_scopes.length);
139+
140+ string[] subscopes = {"test_masterscope-childscope_1.scope"};
141+ hints [Unity.Internal.SEARCH_SUBSCOPES_HINT] = new GLib.Variant.strv (subscopes);
142+
143+ // even though search string didn't change, this shouldn't just serve
144+ // the last resultset
145+ reply_dict = ScopeTester.perform_search (proxy, channel_id, "foo",
146+ hints, model);
147+
148+ assert (reply_dict != null);
149+ assert (model.get_n_rows () == 1);
150+ }
151 }
152
153 class AggregatorScopeTester: Object, Fixture

Subscribers

People subscribed via source and target branches

to all changes: