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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-10-23 15:14:43 +0000
+++ CMakeLists.txt 2015-11-20 22:28:57 +0000
@@ -1,4 +1,4 @@
1set(VERSION "4.0")1set(VERSION "4.0.1")
22
3# Supress qDebug() output3# Supress qDebug() output
4ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )4ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )
55
=== modified file 'src/query.cpp'
--- src/query.cpp 2015-10-23 10:54:53 +0000
+++ src/query.cpp 2015-11-20 22:28:57 +0000
@@ -288,6 +288,8 @@
288 int idx = -1;//used in scopes_m_int_localId to store scope local_id288 int idx = -1;//used in scopes_m_int_localId to store scope local_id
289 for (const std::string &local_id : scopes_ordered)289 for (const std::string &local_id : scopes_ordered)
290 {290 {
291 qDebug() << "==== handle. checking scope locali_id: " << qstr(local_id);
292 qDebug() << "==== handle. checking scope id: " << qstr(localId_id_m[local_id]);
291 // get a pointer to the current child scope (by id from the map)293 // get a pointer to the current child scope (by id from the map)
292 std::shared_ptr<AggChildScope> scope = scopes_m[local_id];294 std::shared_ptr<AggChildScope> scope = scopes_m[local_id];
293295
294296
=== modified file 'src/utils.cpp'
--- src/utils.cpp 2015-09-14 02:37:51 +0000
+++ src/utils.cpp 2015-11-20 22:28:57 +0000
@@ -352,7 +352,7 @@
352 declared_order.emplace_back(cat->id);352 declared_order.emplace_back(cat->id);
353 categories.emplace_back(cat);353 categories.emplace_back(cat);
354 id_category_m[cat->id] = cat;354 id_category_m[cat->id] = cat;
355 }355 } // end "category"
356356
357 if (item_o.contains("scope"))357 if (item_o.contains("scope"))
358 {358 {
@@ -553,7 +553,7 @@
553 child_scopes.emplace_back(cs);553 child_scopes.emplace_back(cs);
554 child_scopes_m[cs->local_id] = cs;554 child_scopes_m[cs->local_id] = cs;
555 type_ids_m[cs->local_id].emplace_back(cs->local_id);555 type_ids_m[cs->local_id].emplace_back(cs->local_id);
556 }556 } // end "scope"
557 else if (item_o.contains("keyword"))557 else if (item_o.contains("keyword"))
558 {558 {
559 keyword keyword_;559 keyword keyword_;
@@ -678,7 +678,7 @@
678{678{
679 for (std::string id : declared_order)679 for (std::string id : declared_order)
680 {680 {
681 qDebug() << "==== SET ORDER. DECLARED order id: " << qstr(id);681 //qDebug() << "==== SET ORDER. DECLARED order id: " << qstr(id);
682 for (auto pr : type_ids_m)682 for (auto pr : type_ids_m)
683 {683 {
684 if (pr.first == id)684 if (pr.first == id)
@@ -691,6 +691,9 @@
691 }691 }
692 }692 }
693 }693 }
694 for(auto sc : scopes_ordered) {
695 qDebug() << "==== FINAL ORDER: " << qstr(sc);
696 }
694}697}
695698
696/*699/*
@@ -821,14 +824,9 @@
821 if (!keyword_child.enabled)824 if (!keyword_child.enabled)
822 continue;825 continue;
823826
824 std::vector<std::string>::iterator iter;
825 iter = find(current_scopes.begin(), current_scopes.end(), localId_id_m[keyword_child.id]);
826 if (iter != current_scopes.end()) // don't add as keyword if already added as declared
827 continue;
828827
829 AggChildScope keych(keyword_child.id);828 AggChildScope keych(keyword_child.id);
830 QString time_str = QDateTime::currentDateTimeUtc().toString();829 QString time_str = QDateTime::currentDateTimeUtc().toString();
831 keych.set_local_id(keyword_child.id + time_str.toStdString());
832 keych.set_keyword_scope(true);830 keych.set_keyword_scope(true);
833 dept d;831 dept d;
834 d.id = keyword_child.id;832 d.id = keyword_child.id;
@@ -849,7 +847,13 @@
849 });847 });
850 if (found_scopes.size() == 0 )848 if (found_scopes.size() == 0 )
851 continue;849 continue;
852 type_ids_m[kw].emplace_back(id);850 std::vector<std::string>::iterator iter1;
851 iter1 = find(current_scopes.begin(), current_scopes.end(), localId_id_m[keyword_child.id + kw]);
852 if (iter1 != current_scopes.end()) // don't add as keyword if already added as declared
853 continue;
854
855 keych.set_local_id(keyword_child.id + ":" + kw);
856 type_ids_m[kw].emplace_back(keych.local_id());
853 d.keyword = kw;857 d.keyword = kw;
854 keych.set_department(kw);858 keych.set_department(kw);
855 keych.set_keyword(kw);859 keych.set_keyword(kw);
@@ -930,10 +934,10 @@
930 if (curr_dept_id.empty())934 if (curr_dept_id.empty())
931 curr_dept_id = "root";935 curr_dept_id = "root";
932 qWarning() << "==== ID 2 KEYWORD: " << qstr(keych.keyword());936 qWarning() << "==== ID 2 KEYWORD: " << qstr(keych.keyword());
933 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));937 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()));
934 scopes_m[keych.id()] = std::make_shared<AggChildScope>(keych);938 scopes_m[keych.local_id()] = std::make_shared<AggChildScope>(keych);
935 localId_id_m[keych.id()] = keych.id();939 localId_id_m[keych.local_id()] = keych.id();
936 current_scopes.emplace_back(keych.id());940 current_scopes.emplace_back(keych.local_id());
937 }941 }
938}942}
939943

Subscribers

People subscribed via source and target branches