mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 16:39:43 -05:00
fixed the logic with distant search.
This commit is contained in:
parent
61437cd0b4
commit
8e2c670716
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user