Merge lp:~gary-wzl77/scope-aggregator/default_query_string_And_only_in_search into lp:~scope-aggregator/scope-aggregator/vivid-trunk-setaside

Proposed by Gary.Wang
Status: Merged
Approved by: Kyle Nitzsche
Approved revision: 141
Merged at revision: 141
Proposed branch: lp:~gary-wzl77/scope-aggregator/default_query_string_And_only_in_search
Merge into: lp:~scope-aggregator/scope-aggregator/vivid-trunk-setaside
Diff against target: 210 lines (+95/-3)
7 files modified
CMakeLists.txt (+1/-1)
README.md (+55/-1)
include/aggchildscope.h (+4/-0)
include/query.h (+1/-0)
src/aggchildscope.cpp (+10/-0)
src/query.cpp (+7/-1)
src/utils.cpp (+17/-0)
To merge this branch: bzr merge lp:~gary-wzl77/scope-aggregator/default_query_string_And_only_in_search
Reviewer Review Type Date Requested Status
Kyle Nitzsche (community) Needs Fixing
Review via email: mp+264690@code.launchpad.net

Commit message

Support only_in_search and default_query_string in scope json object

Description of the change

Support only_in_search and default_query_string in scope json object

To post a comment you must log in.
Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

Hi Gary.

Small format/style request 1):
Please add a space after the "&&" in this line:
if (query_string.empty() &&scope->only_in_search() == true)

Style request 2):
Please use four spaces instead of tabs in this project. For example indentation looks wrong on line 110 below.

Most new features need to be documented in the README.md. Do you think this does?

Please refresh the branch here and I will approve.

Thanks,
Kyle

review: Needs Fixing
140. By Gary.Wang

1.Update README.md with new properties(only_in_search and default_query_string)
2.Fixed indentation issue

141. By Gary.Wang

Pull master branch and merge to avoid conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-07-14 23:22:36 +0000
3+++ CMakeLists.txt 2015-07-15 03:54:56 +0000
4@@ -1,4 +1,4 @@
5-set(VERSION "1.5.20")
6+set(VERSION "1.5.20.1")
7
8 # Supress qDebug() output
9 ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )
10
11=== modified file 'README.md'
12--- README.md 2015-06-16 22:37:40 +0000
13+++ README.md 2015-07-15 03:54:56 +0000
14@@ -673,7 +673,7 @@
15
16 The `id` is used to refer to the common template when using `result_category_id_to_common_template`.
17
18-### template` (required)
19+### `template` (required)
20
21 Value: json
22
23@@ -705,3 +705,57 @@
24 [...]
25 }
26
27+
28+#### `default_query_string` key (optional)
29+
30+Value: string: a query string passed to child scope
31+
32+The key is useful for developer to display results with specific query string by default instead of results fetched with empty query string.
33+
34+
35+#### `only_in_search` key (optional)
36+
37+Value: string: "true" or "false", default value: "false"
38+
39+Displays only results of specified scope on search, not in surface.
40+
41+Note:If aggregator has multiple departments, in order to display results in current departments, you need to declare the scope with different deparment and local_id separately.
42+
43+ {
44+ "departments":
45+ {
46+ "do_not_use_departments": "false",
47+ "declarations":[
48+ {
49+ "id": "dept-movies",
50+ "root": "true",
51+ "_title": "Movies"
52+ },
53+ {
54+ "id": "dept-music",
55+ "root": "False",
56+ "_title": "Music"
57+ }
58+ ]
59+ },
60+ [...]
61+ "order":
62+ [
63+ {
64+ "scope":
65+ {
66+ "id": "your_scope_id",
67+ "local_id": "your_scope_id_1",
68+ "only_in_search":"true",
69+ "department": "dept-movies"
70+ },
71+ [...]
72+ "scope":
73+ {
74+ "id": "your_scope_id",
75+ "local_id": "your_scope_id_2",
76+ "only_in_search":"true",
77+ "department": "dept-music"
78+ }
79+ }
80+ ]
81
82=== modified file 'include/aggchildscope.h'
83--- include/aggchildscope.h 2015-07-07 02:46:30 +0000
84+++ include/aggchildscope.h 2015-07-15 03:54:56 +0000
85@@ -364,6 +364,9 @@
86 bool source_finder();
87 void set_source_finder(bool);
88
89+ bool only_in_search();
90+ void set_only_in_search(bool);
91+
92 private:
93
94 std::shared_ptr<us::ScopeMetadata> scope_metadata_;
95@@ -386,6 +389,7 @@
96 std::string dept_id = "";
97 std::string subsearch_dept_id = "";
98 bool using_category = false;
99+ bool only_in_search_ = false;
100 bool using_child_category_max_results_ = false;
101 int child_category_max_results_ = 6;
102 int result_idx_ = 0;
103
104=== modified file 'include/query.h'
105--- include/query.h 2015-07-09 21:45:42 +0000
106+++ include/query.h 2015-07-15 03:54:56 +0000
107@@ -107,6 +107,7 @@
108 int child_category_max_results = 6;//optional in json else use this default when child_category used
109 std::string child_department = "";//optional in json
110 std::string department = "";//optional in json
111+ bool only_in_search = false;//optional in json
112 //the rest are NOT json keys
113 bool using_child_category_max_results = false;//NOT A JSON KEY
114 bool overriding_surface_template = false;//NOT A JSON KEY
115
116=== modified file 'src/aggchildscope.cpp'
117--- src/aggchildscope.cpp 2015-07-07 02:46:30 +0000
118+++ src/aggchildscope.cpp 2015-07-15 03:54:56 +0000
119@@ -318,6 +318,16 @@
120 source_finder_ = b;
121 }
122
123+bool AggChildScope::only_in_search()
124+{
125+ return only_in_search_;
126+}
127+
128+void AggChildScope::set_only_in_search(bool b)
129+{
130+ only_in_search_ = b;
131+}
132+
133 bool AggChildScope::source_finder()
134 {
135 return source_finder_;
136
137=== modified file 'src/query.cpp'
138--- src/query.cpp 2015-07-14 23:19:35 +0000
139+++ src/query.cpp 2015-07-15 03:54:56 +0000
140@@ -232,6 +232,11 @@
141 continue;
142 }
143
144+ if (query_string.empty() && scope->only_in_search() == true)
145+ {
146+ continue;
147+ }
148+
149 idx++;
150 scopes_m_int_localId[idx] = local_id; // add id to map used later to get dept_id
151 qDebug() << "==== scopes scopes_m_int_localId[idx] init: " << qstr(scopes_m_int_localId[idx]);
152@@ -1115,6 +1120,7 @@
153 {
154 for (auto ch : current_child_scopes)
155 {
156+
157 if (ch.id == localId_id_m[scopes_m_int_localId[i]])
158 {
159 qDebug() << "=== subsearch non KEYWORD scope local_ id " << qstr(scope->local_id());
160@@ -1136,6 +1142,7 @@
161 adj_qry = localId_defaultQryStr[scopes_m_int_localId[i]];
162 else
163 adj_qry = "";
164+
165 subsearch
166 (
167 ch,
168@@ -1146,7 +1153,6 @@
169 );
170 break;
171 }
172-
173 }
174 }
175 }
176
177=== modified file 'src/utils.cpp'
178--- src/utils.cpp 2015-07-09 21:45:42 +0000
179+++ src/utils.cpp 2015-07-15 03:54:56 +0000
180@@ -535,6 +535,21 @@
181 cs->result_category_id_to_common_template[res_cat_id] = common_template;
182 }
183 }
184+
185+ if (scope_o.contains("default_query_string"))
186+ {
187+ QString default_query_string = scope_o["default_query_string"].toString();
188+ localId_defaultQryStr[cs->local_id] = default_query_string.toStdString();
189+ }
190+
191+ if (scope_o.contains("only_in_search") && scope_o["only_in_search"] == "true")
192+ {
193+ cs->only_in_search = true;
194+ cs->overriding_search_template = true;
195+ } else {
196+ cs->only_in_search = false;
197+ }
198+
199 child_scopes.emplace_back(cs);
200 child_scopes_m[cs->local_id] = cs;
201 type_ids_m[cs->local_id].emplace_back(cs->local_id);
202@@ -732,6 +747,8 @@
203 else
204 ch.set_override_search_template(false);
205
206+ ch.set_only_in_search(child->only_in_search);
207+
208 ch.set_source_finder(child->source_finder);
209 qWarning () << QString("%1: ADDING DECLARED child scope: %2, local_id: %3").arg(qstr(scope_id), qstr(ch.id()), qstr(ch.local_id()));
210 scopes_m[ch.local_id()] = std::make_shared<AggChildScope>(ch);

Subscribers

People subscribed via source and target branches

to all changes: