added test search functions in rsgxsnetservice

This commit is contained in:
csoler 2018-06-11 22:00:03 +02:00
parent 6fb459ce64
commit be1e127a93
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 35 additions and 2 deletions

View File

@ -5112,8 +5112,36 @@ void RsGxsNetService::turtleSearchRequest(const std::string& match_string)
mGxsNetTunnel->turtleSearchRequest(match_string,this) ;
}
static bool termSearch(const std::string& src, const std::string& substring)
{
/* always ignore case */
return src.end() != std::search( src.begin(), src.end(), substring.begin(), substring.end(), RsRegularExpression::CompareCharIC() );
}
bool RsGxsNetService::search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos)
{
#warning MISSING CODE HERE!
return true ;
RsGxsGrpMetaTemporaryMap grpMetaMap;
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
RsGroupNetworkStats stats ;
for(auto it(grpMetaMap.begin());it!=grpMetaMap.end();++it)
if(termSearch(it->second->mGroupName,substring))
{
getGroupNetworkStats(it->first,stats) ;
RsGxsGroupSummary s ;
s.group_id = it->first ;
s.group_name = it->second->mGroupName ;
s.group_description = it->second->mGroupName ; // to be filled with something better when we use the real search
s.search_context = it->second->mGroupName ;
s.author_id = it->second->mAuthorId;
s.publish_ts = it->second->mPublishTs;
s.number_of_messages = stats.mMaxVisibleCount ;
s.last_message_ts = stats.mLastGroupModificationTS ;
group_infos.push_back(s) ;
}
return !group_infos.empty();
}

View File

@ -1048,7 +1048,12 @@ void RsGxsNetTunnelService::receiveSearchResult(TurtleSearchRequestId request_id
if(result_gs != NULL)
{
std::cerr << "Received group summary result for search request " << std::hex << request_id << " for service " << result_gs->service << std::dec << ": " << std::endl;
for(auto it(result_gs->group_infos.begin());it!=result_gs->group_infos.end();++it)
std::cerr << " group " << (*it).group_id << ": " << (*it).group_name << ", " << (*it).number_of_messages << " messages, last is " << time(NULL)-(*it).last_message_ts << " secs ago." << std::endl;
#warning MISSING CODE HERE - data should be passed up to UI in some way
}
}