fixed the logic with distant search.

This commit is contained in:
csoler 2020-06-16 00:00:22 +02:00
parent 61437cd0b4
commit 8e2c670716
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C

View File

@ -5203,19 +5203,10 @@ void RsGxsNetService::receiveTurtleSearchResults( TurtleRequestId req, const std
for(const RsGxsGroupSummary& gps : group_infos) for(const RsGxsGroupSummary& gps : group_infos)
{ {
std::cerr <<" " << gps.mGroupId << " \"" << gps.mGroupName << "\" " ; std::cerr <<" " << gps.mGroupId << " \"" << gps.mGroupName << "\"" << std::endl;
grpMeta[gps.mGroupId] = nullptr;
if(search_results_map.find(gps.mGroupId) == search_results_map.end())
{
std::cerr << "added to search." << std::endl;
grpMeta[gps.mGroupId] = nullptr;
}
else
std::cerr << "ignored (already in search results)." << std::endl;
} }
// Do a search for only groups that we dont have yet in the search results.
mDataStore->retrieveGxsGrpMetaData(grpMeta); mDataStore->retrieveGxsGrpMetaData(grpMeta);
std::cerr << "Retrieved data store group data for the following groups:" <<std::endl; std::cerr << "Retrieved data store group data for the following groups:" <<std::endl;
@ -5230,7 +5221,9 @@ void RsGxsNetService::receiveTurtleSearchResults( TurtleRequestId req, const std
* mDataStore may in some situations allocate an empty group meta data, so it's important * mDataStore may in some situations allocate an empty group meta data, so it's important
* to test that the group meta is both non null and actually corresponds to the group id we seek. */ * to test that the group meta is both non null and actually corresponds to the group id we seek. */
if(grpMeta[gps.mGroupId] != nullptr && grpMeta[gps.mGroupId]->mGroupId == gps.mGroupId) auto& meta(grpMeta[gps.mGroupId]);
if(meta != nullptr && meta->mGroupId == gps.mGroupId)
continue; continue;
std::cerr << " group " << gps.mGroupId << " is not known. Adding it to search results..." << std::endl; std::cerr << " group " << gps.mGroupId << " is not known. Adding it to search results..." << std::endl;
@ -5244,21 +5237,15 @@ void RsGxsNetService::receiveTurtleSearchResults( TurtleRequestId req, const std
groupsToNotifyResults.insert(grpId); groupsToNotifyResults.insert(grpId);
auto it2 = search_results_map.find(grpId); auto it2 = search_results_map.find(grpId);
if(it2 != search_results_map.end())
{ RsGxsGroupSummary& eGpS(search_results_map[grpId]);
// update existing data
RsGxsGroupSummary& eGpS(it2->second); int popularity = eGpS.mPopularity + 1;
eGpS.mPopularity++; int number_of_msg = std::max( eGpS.mNumberOfMessages, gps.mNumberOfMessages );
eGpS.mNumberOfMessages = std::max(
eGpS.mNumberOfMessages, eGpS = gps;
gps.mNumberOfMessages ); eGpS.mPopularity = popularity;
} eGpS.mNumberOfMessages = number_of_msg;
else
{
search_results_map[grpId] = gps;
// number of results so far
search_results_map[grpId].mPopularity = 1;
}
} }
} // end RS_STACK_MUTEX(mNxsMutex); } // end RS_STACK_MUTEX(mNxsMutex);