Merge lp:~knitzsche/scope-aggregator/ota8-nearby-places-bug-1518346 into lp:scope-aggregator

Proposed by Kyle Nitzsche
Status: Merged
Merged at revision: 155
Proposed branch: lp:~knitzsche/scope-aggregator/ota8-nearby-places-bug-1518346
Merge into: lp:scope-aggregator
Diff against target: 107 lines (+20/-14)
3 files modified
CMakeLists.txt (+1/-1)
src/query.cpp (+2/-0)
src/utils.cpp (+17/-13)
To merge this branch: bzr merge lp:~knitzsche/scope-aggregator/ota8-nearby-places-bug-1518346
Reviewer Review Type Date Requested Status
Gary.Wang Approve
Penk Chen Pending
Review via email: mp+278227@code.launchpad.net

Description of the change

  For the first time, we have an aggregator using multiple keywords and a
  child scope wanting to be aggregated by more than one. This was not working
  due to some lacking clarity in the relationship of scope id to local id and
  the various structures used to track these. Should work now.

  For some background, see bug 1518346

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

Note that the broken use case was "keyword"s (not "categories" (even when containing keywords), and not "scopes").

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Looks good to me.
Thanks.

review: Approve

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-10-23 15:14:43 +0000
3+++ CMakeLists.txt 2015-11-20 22:28:57 +0000
4@@ -1,4 +1,4 @@
5-set(VERSION "4.0")
6+set(VERSION "4.0.1")
7
8 # Supress qDebug() output
9 ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )
10
11=== modified file 'src/query.cpp'
12--- src/query.cpp 2015-10-23 10:54:53 +0000
13+++ src/query.cpp 2015-11-20 22:28:57 +0000
14@@ -288,6 +288,8 @@
15 int idx = -1;//used in scopes_m_int_localId to store scope local_id
16 for (const std::string &local_id : scopes_ordered)
17 {
18+ qDebug() << "==== handle. checking scope locali_id: " << qstr(local_id);
19+ qDebug() << "==== handle. checking scope id: " << qstr(localId_id_m[local_id]);
20 // get a pointer to the current child scope (by id from the map)
21 std::shared_ptr<AggChildScope> scope = scopes_m[local_id];
22
23
24=== modified file 'src/utils.cpp'
25--- src/utils.cpp 2015-09-14 02:37:51 +0000
26+++ src/utils.cpp 2015-11-20 22:28:57 +0000
27@@ -352,7 +352,7 @@
28 declared_order.emplace_back(cat->id);
29 categories.emplace_back(cat);
30 id_category_m[cat->id] = cat;
31- }
32+ } // end "category"
33
34 if (item_o.contains("scope"))
35 {
36@@ -553,7 +553,7 @@
37 child_scopes.emplace_back(cs);
38 child_scopes_m[cs->local_id] = cs;
39 type_ids_m[cs->local_id].emplace_back(cs->local_id);
40- }
41+ } // end "scope"
42 else if (item_o.contains("keyword"))
43 {
44 keyword keyword_;
45@@ -678,7 +678,7 @@
46 {
47 for (std::string id : declared_order)
48 {
49- qDebug() << "==== SET ORDER. DECLARED order id: " << qstr(id);
50+ //qDebug() << "==== SET ORDER. DECLARED order id: " << qstr(id);
51 for (auto pr : type_ids_m)
52 {
53 if (pr.first == id)
54@@ -691,6 +691,9 @@
55 }
56 }
57 }
58+ for(auto sc : scopes_ordered) {
59+ qDebug() << "==== FINAL ORDER: " << qstr(sc);
60+ }
61 }
62
63 /*
64@@ -821,14 +824,9 @@
65 if (!keyword_child.enabled)
66 continue;
67
68- std::vector<std::string>::iterator iter;
69- iter = find(current_scopes.begin(), current_scopes.end(), localId_id_m[keyword_child.id]);
70- if (iter != current_scopes.end()) // don't add as keyword if already added as declared
71- continue;
72
73 AggChildScope keych(keyword_child.id);
74 QString time_str = QDateTime::currentDateTimeUtc().toString();
75- keych.set_local_id(keyword_child.id + time_str.toStdString());
76 keych.set_keyword_scope(true);
77 dept d;
78 d.id = keyword_child.id;
79@@ -849,7 +847,13 @@
80 });
81 if (found_scopes.size() == 0 )
82 continue;
83- type_ids_m[kw].emplace_back(id);
84+ std::vector<std::string>::iterator iter1;
85+ iter1 = find(current_scopes.begin(), current_scopes.end(), localId_id_m[keyword_child.id + kw]);
86+ if (iter1 != current_scopes.end()) // don't add as keyword if already added as declared
87+ continue;
88+
89+ keych.set_local_id(keyword_child.id + ":" + kw);
90+ type_ids_m[kw].emplace_back(keych.local_id());
91 d.keyword = kw;
92 keych.set_department(kw);
93 keych.set_keyword(kw);
94@@ -930,10 +934,10 @@
95 if (curr_dept_id.empty())
96 curr_dept_id = "root";
97 qWarning() << "==== ID 2 KEYWORD: " << qstr(keych.keyword());
98- qWarning () << QString("%1: ADDING KEYWORD child scope: %2 by keyword %3 to department: %4").arg(qstr(scope_id), qstr(keych.id()), qstr(keych.keyword()), qstr(curr_dept_id));
99- scopes_m[keych.id()] = std::make_shared<AggChildScope>(keych);
100- localId_id_m[keych.id()] = keych.id();
101- current_scopes.emplace_back(keych.id());
102+ qWarning () << QString("%1: ADDING KEYWORD child scope: %2, local_id %5, by keyword %3, to department: %4").arg(qstr(scope_id), qstr(keych.id()), qstr(keych.keyword()), qstr(curr_dept_id), qstr(keych.local_id()));
103+ scopes_m[keych.local_id()] = std::make_shared<AggChildScope>(keych);
104+ localId_id_m[keych.local_id()] = keych.id();
105+ current_scopes.emplace_back(keych.local_id());
106 }
107 }
108

Subscribers

People subscribed via source and target branches