mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 21:04:32 -04:00
Improve code quality after Cyril review
This commit is contained in:
parent
6f8c2f6f41
commit
e8c9ba52b2
4 changed files with 17 additions and 33 deletions
|
@ -99,11 +99,7 @@ struct DeepSearch
|
||||||
|
|
||||||
// Index each field with a suitable prefix.
|
// Index each field with a suitable prefix.
|
||||||
termgenerator.index_text(chan.mMeta.mGroupName, 1, "G");
|
termgenerator.index_text(chan.mMeta.mGroupName, 1, "G");
|
||||||
|
termgenerator.index_text(timetToXapianDate(chan.mMeta.mPublishTs), 1, "D");
|
||||||
char date[] = "YYYYMMDD\0";
|
|
||||||
std::strftime(date, 9, "%Y%m%d", std::gmtime(&chan.mMeta.mPublishTs));
|
|
||||||
termgenerator.index_text(date, 1, "D");
|
|
||||||
|
|
||||||
termgenerator.index_text(chan.mDescription, 1, "XD");
|
termgenerator.index_text(chan.mDescription, 1, "XD");
|
||||||
|
|
||||||
// Index fields without prefixes for general search.
|
// Index fields without prefixes for general search.
|
||||||
|
@ -116,7 +112,7 @@ struct DeepSearch
|
||||||
.setQueryKV("id", chan.mMeta.mGroupId.toStdString());
|
.setQueryKV("id", chan.mMeta.mGroupId.toStdString());
|
||||||
const std::string idTerm("Q" + chanUrl.toString());
|
const std::string idTerm("Q" + chanUrl.toString());
|
||||||
|
|
||||||
chanUrl.setQueryKV("publishDate", date);
|
chanUrl.setQueryKV("publishTs", std::to_string(chan.mMeta.mPublishTs));
|
||||||
chanUrl.setQueryKV("name", chan.mMeta.mGroupName);
|
chanUrl.setQueryKV("name", chan.mMeta.mGroupName);
|
||||||
if(!chan.mMeta.mAuthorId.isNull())
|
if(!chan.mMeta.mAuthorId.isNull())
|
||||||
chanUrl.setQueryKV("authorId", chan.mMeta.mAuthorId.toStdString());
|
chanUrl.setQueryKV("authorId", chan.mMeta.mAuthorId.toStdString());
|
||||||
|
@ -164,10 +160,7 @@ struct DeepSearch
|
||||||
|
|
||||||
// Index each field with a suitable prefix.
|
// Index each field with a suitable prefix.
|
||||||
termgenerator.index_text(post.mMeta.mMsgName, 1, "S");
|
termgenerator.index_text(post.mMeta.mMsgName, 1, "S");
|
||||||
|
termgenerator.index_text(timetToXapianDate(post.mMeta.mPublishTs), 1, "D");
|
||||||
char date[] = "YYYYMMDD\0";
|
|
||||||
std::strftime(date, 9, "%Y%m%d", std::gmtime(&post.mMeta.mPublishTs));
|
|
||||||
termgenerator.index_text(date, 1, "D");
|
|
||||||
|
|
||||||
// Avoid indexing HTML
|
// Avoid indexing HTML
|
||||||
bool isPlainMsg = post.mMsg[0] != '<' || post.mMsg[post.mMsg.size() - 1] != '>';
|
bool isPlainMsg = post.mMsg[0] != '<' || post.mMsg[post.mMsg.size() - 1] != '>';
|
||||||
|
@ -200,8 +193,9 @@ struct DeepSearch
|
||||||
.setQueryKV("msgid", post.mMeta.mMsgId.toStdString());
|
.setQueryKV("msgid", post.mMeta.mMsgId.toStdString());
|
||||||
std::string idTerm("Q" + postUrl.toString());
|
std::string idTerm("Q" + postUrl.toString());
|
||||||
|
|
||||||
postUrl.setQueryKV("publishDate", date);
|
postUrl.setQueryKV("publishTs", std::to_string(post.mMeta.mPublishTs));
|
||||||
postUrl.setQueryKV("name", post.mMeta.mMsgName);
|
postUrl.setQueryKV("name", post.mMeta.mMsgName);
|
||||||
|
postUrl.setQueryKV("authorId", post.mMeta.mAuthorId.toStdString());
|
||||||
std::string rsLink(postUrl.toString());
|
std::string rsLink(postUrl.toString());
|
||||||
|
|
||||||
// store the RS link so we are able to retrive it on matching search
|
// store the RS link so we are able to retrive it on matching search
|
||||||
|
@ -247,5 +241,12 @@ private:
|
||||||
RsAccounts::AccountDirectory() + "/deep_search_xapian_db";
|
RsAccounts::AccountDirectory() + "/deep_search_xapian_db";
|
||||||
return dbDir;
|
return dbDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string timetToXapianDate(const time_t& time)
|
||||||
|
{
|
||||||
|
char date[] = "YYYYMMDD\0";
|
||||||
|
std::strftime(date, 9, "%Y%m%d", std::gmtime(&time));
|
||||||
|
return date;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -261,13 +261,6 @@
|
||||||
# include "deep_search/deep_search.h"
|
# include "deep_search/deep_search.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "util/cxx11retrocompat.h"
|
|
||||||
#if defined(GCC_VERSION) && GCC_VERSION > 50100
|
|
||||||
# include <iomanip>
|
|
||||||
#else
|
|
||||||
# include <cstdio>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Use the following defines to debug:
|
* Use the following defines to debug:
|
||||||
NXS_NET_DEBUG_0 shows group update high level information
|
NXS_NET_DEBUG_0 shows group update high level information
|
||||||
|
@ -5307,19 +5300,8 @@ bool RsGxsNetService::search( const std::string& substring,
|
||||||
s.mGroupName = rit->second;
|
s.mGroupName = rit->second;
|
||||||
if((rit = uQ.find("signFlags")) != uQ.end())
|
if((rit = uQ.find("signFlags")) != uQ.end())
|
||||||
s.mSignFlags = std::stoul(rit->second);
|
s.mSignFlags = std::stoul(rit->second);
|
||||||
if((rit = uQ.find("publishDate")) != uQ.end())
|
if((rit = uQ.find("publishTs")) != uQ.end())
|
||||||
{
|
s.mPublishTs = static_cast<time_t>(std::stoll(rit->second));
|
||||||
std::tm tm; memset(&tm, 0, sizeof(tm));
|
|
||||||
#if defined(GCC_VERSION) && GCC_VERSION > 50100
|
|
||||||
std::istringstream ss(rit->second);
|
|
||||||
ss >> std::get_time(&tm, "%Y%m%d");
|
|
||||||
#else // defined(GCC_VERSION) && GCC_VERSION > 50100
|
|
||||||
sscanf( rit->second.c_str(),
|
|
||||||
"%4d%2d%2d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday );
|
|
||||||
#endif // defined(GCC_VERSION) && GCC_VERSION > 50100
|
|
||||||
|
|
||||||
s.mPublishTs = mktime(&tm);
|
|
||||||
}
|
|
||||||
if((rit = uQ.find("authorId")) != uQ.end())
|
if((rit = uQ.find("authorId")) != uQ.end())
|
||||||
s.mAuthorId = RsGxsId(rit->second);
|
s.mAuthorId = RsGxsId(rit->second);
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,9 @@ const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_KEEP_ALIVE = 0x02
|
||||||
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_RANDOM_BIAS = 0x03 ;
|
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_RANDOM_BIAS = 0x03 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_SUBSTRING = 0x04 ;
|
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_SUBSTRING = 0x04 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_REQUEST = 0x05 ;
|
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_REQUEST = 0x05 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY = 0x06 ;
|
// const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY = 0x06; // DEPRECATED
|
||||||
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA = 0x07 ;
|
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA = 0x07 ;
|
||||||
|
const uint8_t RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_SUMMARY = 0x08;
|
||||||
|
|
||||||
class RsGxsNetTunnelItem: public RsItem
|
class RsGxsNetTunnelItem: public RsItem
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,7 +162,7 @@ void RsGxsIntegrityCheck::run()
|
||||||
bool RsGxsIntegrityCheck::check()
|
bool RsGxsIntegrityCheck::check()
|
||||||
{
|
{
|
||||||
#ifdef RS_DEEP_SEARCH
|
#ifdef RS_DEEP_SEARCH
|
||||||
bool isGxsChannels = dynamic_cast<p3GxsChannels*>(mGenExchangeClient);
|
bool isGxsChannels = mGenExchangeClient->serviceType() == RS_SERVICE_GXS_TYPE_CHANNELS;
|
||||||
std::set<RsGxsGroupId> indexedGroups;
|
std::set<RsGxsGroupId> indexedGroups;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue