mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
Merge pull request #1377 from G10h4ck/jsonapi
GXS deep search notify results also of already known groups
This commit is contained in:
commit
cfe95a57a0
@ -1373,7 +1373,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsStackMutex stack(mDbMutex);
|
RS_STACK_MUTEX(mDbMutex);
|
||||||
|
|
||||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
rstime::RsScopeTimer timer("");
|
rstime::RsScopeTimer timer("");
|
||||||
|
@ -1659,12 +1659,13 @@ void RsGenExchange::receiveNewMessages(std::vector<RsNxsMsg *>& messages)
|
|||||||
|
|
||||||
void RsGenExchange::receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId)
|
void RsGenExchange::receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId)
|
||||||
{
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " received result for request "
|
||||||
|
<< std::hex << id << std::dec << std::endl;
|
||||||
|
|
||||||
RS_STACK_MUTEX(mGenMtx);
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
|
|
||||||
RsGxsDistantSearchResultChange* gc = new RsGxsDistantSearchResultChange(id,grpId);
|
RsGxsDistantSearchResultChange* gc = new RsGxsDistantSearchResultChange(id,grpId);
|
||||||
mNotifications.push_back(gc);
|
mNotifications.push_back(gc);
|
||||||
|
|
||||||
std::cerr << "RsGenExchange::receiveDistantSearchResults(): received result for request " << std::hex << id << std::dec << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId)
|
void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId)
|
||||||
|
@ -5181,7 +5181,9 @@ bool RsGxsNetService::clearDistantSearchResults(const TurtleRequestId& id)
|
|||||||
mDistantSearchResults.erase(id);
|
mDistantSearchResults.erase(id);
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req, const std::list<RsGxsGroupSummary>& group_infos)
|
|
||||||
|
void RsGxsNetService::receiveTurtleSearchResults(
|
||||||
|
TurtleRequestId req, const std::list<RsGxsGroupSummary>& group_infos )
|
||||||
{
|
{
|
||||||
std::set<RsGxsGroupId> groupsToNotifyResults;
|
std::set<RsGxsGroupId> groupsToNotifyResults;
|
||||||
|
|
||||||
@ -5192,38 +5194,42 @@ void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req, const std:
|
|||||||
std::map<RsGxsGroupId,RsGxsGroupSummary>&
|
std::map<RsGxsGroupId,RsGxsGroupSummary>&
|
||||||
search_results_map(mDistantSearchResults[req]);
|
search_results_map(mDistantSearchResults[req]);
|
||||||
|
|
||||||
for(auto it(group_infos.begin());it!=group_infos.end();++it)
|
for(const RsGxsGroupSummary& gps : group_infos)
|
||||||
if(search_results_map.find((*it).mGroupId) == search_results_map.end())
|
if(search_results_map.find(gps.mGroupId) == search_results_map.end())
|
||||||
grpMeta[(*it).mGroupId] = NULL;
|
grpMeta[gps.mGroupId] = nullptr;
|
||||||
|
|
||||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||||
|
|
||||||
// only keep groups that are not locally known, and groups that are not already in the mDistantSearchResults structure
|
for (const RsGxsGroupSummary& gps : group_infos)
|
||||||
|
{
|
||||||
|
#ifndef RS_DEEP_SEARCH
|
||||||
|
/* Only keep groups that are not locally known, and groups that are
|
||||||
|
* not already in the mDistantSearchResults structure. */
|
||||||
|
if(grpMeta[gps.mGroupId]) continue;
|
||||||
|
#else // ndef RS_DEEP_SEARCH
|
||||||
|
/* When deep search is enabled search results may bring more info
|
||||||
|
* then we already have also about post that are indexed by xapian,
|
||||||
|
* so we don't apply this filter in this case. */
|
||||||
|
#endif
|
||||||
|
const RsGxsGroupId& grpId(gps.mGroupId);
|
||||||
|
|
||||||
for(auto it(group_infos.begin());it!=group_infos.end();++it)
|
groupsToNotifyResults.insert(grpId);
|
||||||
if(grpMeta[(*it).mGroupId] == NULL)
|
auto it2 = search_results_map.find(grpId);
|
||||||
|
if(it2 != search_results_map.end())
|
||||||
{
|
{
|
||||||
const RsGxsGroupId& grpId((*it).mGroupId);
|
// update existing data
|
||||||
|
RsGxsGroupSummary& eGpS(it2->second);
|
||||||
groupsToNotifyResults.insert(grpId);
|
eGpS.mPopularity++;
|
||||||
|
eGpS.mNumberOfMessages = std::max(
|
||||||
auto it2 = search_results_map.find(grpId);
|
eGpS.mNumberOfMessages,
|
||||||
|
gps.mNumberOfMessages );
|
||||||
if(it2 != search_results_map.end())
|
|
||||||
{
|
|
||||||
// update existing data
|
|
||||||
|
|
||||||
it2->second.mPopularity++;
|
|
||||||
it2->second.mNumberOfMessages = std::max(
|
|
||||||
it2->second.mNumberOfMessages,
|
|
||||||
(*it).mNumberOfMessages );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
search_results_map[grpId] = *it;
|
|
||||||
search_results_map[grpId].mPopularity = 1; // number of results so far
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
for(const RsGxsGroupId& grpId : groupsToNotifyResults)
|
for(const RsGxsGroupId& grpId : groupsToNotifyResults)
|
||||||
|
@ -114,10 +114,11 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Receive results from turtle search @see RsGenExchange @see RsNxsObserver
|
* Receive results from turtle search @see RsGenExchange @see RsNxsObserver
|
||||||
|
* @see RsGxsNetService::receiveTurtleSearchResults
|
||||||
* @see p3turtle::handleSearchResult
|
* @see p3turtle::handleSearchResult
|
||||||
*/
|
*/
|
||||||
void receiveDistantSearchResults( TurtleRequestId id,
|
void receiveDistantSearchResults( TurtleRequestId id,
|
||||||
const RsGxsGroupId& grpId );
|
const RsGxsGroupId& grpId ) override;
|
||||||
|
|
||||||
/* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */
|
/* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */
|
||||||
virtual bool getCommentData(uint32_t token, std::vector<RsGxsComment> &msgs)
|
virtual bool getCommentData(uint32_t token, std::vector<RsGxsComment> &msgs)
|
||||||
|
Loading…
Reference in New Issue
Block a user