Added statistic calculation and retrieval

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7457 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-07-19 08:00:06 +00:00
parent ee0c48b912
commit da335802e2
4 changed files with 69 additions and 3 deletions

View File

@ -311,6 +311,7 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
grpMeta->mPublishTs = c.getInt32(COL_TIME_STAMP); grpMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);
grpMeta->mGroupFlags = c.getInt32(COL_NXS_FLAGS); grpMeta->mGroupFlags = c.getInt32(COL_NXS_FLAGS);
grpMeta->mGrpSize = c.getInt32(COL_NXS_FILE_LEN);
offset = 0; offset = 0;
@ -441,7 +442,7 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c)
offset = 0; offset = 0;
data = (char*)c.getData(COL_SIGN_SET, data_len); data = (char*)c.getData(COL_SIGN_SET, data_len);
msgMeta->signSet.GetTlv(data, data_len, &offset); msgMeta->signSet.GetTlv(data, data_len, &offset);
msgMeta->mMsgSize = c.getInt32(COL_NXS_FILE_LEN);
msgMeta->mMsgFlags = c.getInt32(COL_NXS_FLAGS); msgMeta->mMsgFlags = c.getInt32(COL_NXS_FLAGS);
msgMeta->mPublishTs = c.getInt32(COL_TIME_STAMP); msgMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);

View File

@ -75,6 +75,7 @@ public:
uint32_t mMsgCount; // ??? uint32_t mMsgCount; // ???
uint32_t mLastPost; // ??? uint32_t mLastPost; // ???
uint32_t mReputationCutOff; uint32_t mReputationCutOff;
uint32_t mGrpSize;
uint32_t mGroupStatus; uint32_t mGroupStatus;
uint32_t mRecvTS; uint32_t mRecvTS;
@ -116,6 +117,7 @@ public:
// normally READ / UNREAD flags. LOCAL Data. // normally READ / UNREAD flags. LOCAL Data.
uint32_t mMsgStatus; uint32_t mMsgStatus;
uint32_t mMsgSize;
time_t mChildTs; time_t mChildTs;
uint32_t recvTS; uint32_t recvTS;
RsFileHash mHash; RsFileHash mHash;

View File

@ -1435,6 +1435,55 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
return true; return true;
} }
bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
{
// filter based on options
GxsMsgIdResult metaReq;
metaReq[req->mGrpId] = std::vector<RsGxsMessageId>();
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
req->mGroupStatistic.mTotalSizeOfMsgs = 0;
for(int i = 0; i < msgMetaV.size(); i++)
{
RsGxsMsgMetaData* m = msgMetaV[i];
req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size();
}
return true;
}
// potentially very expensive!
bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
{
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
mDataStore->retrieveGxsGrpMetaData(grpMeta);
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
req->mServiceStatistic.mNumGrps = grpMeta.size();
req->mServiceStatistic.mSizeOfGrps = 0;
req->mServiceStatistic.mSizeOfMsgs = 0;
for(; mit != grpMeta.end(); mit++)
{
RsGxsGrpMetaData* m = mit->second;
req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size();
GroupStatisticRequest gr;
gr.mGrpId = m->mGroupId;
getGroupStatistic(&gr);
req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs;
req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs;
}
req->mServiceStatistic.mSizeStore = req->mServiceStatistic.mSizeOfGrps + req->mServiceStatistic.mSizeOfMsgs;
return true;
}
bool RsGxsDataAccess::getMsgList(MsgIdReq* req) bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
{ {

View File

@ -399,12 +399,26 @@ private:
/*! /*!
* Attempts to retrieve messages related to msgIds of associated equest * Attempts to retrieve messages related to msgIds of associated equest
* @param token request token to be redeemed * @param req Request object to satisfy
* @param msgIds
* @return false if data cannot be found for token * @return false if data cannot be found for token
*/ */
bool getMsgRelatedInfo(MsgRelatedInfoReq* req); bool getMsgRelatedInfo(MsgRelatedInfoReq* req);
/*!
*
* Attempts to retrieve group statistic
* @param req Request object to satisfy
*/
bool getGroupStatistic(GroupStatisticRequest* req);
/*!
*
* Attempts to service statistic
* @param req request object to satisfy
*/
bool getServiceStatistic(ServiceStatisticRequest* req);
/*! /*!
* This filter msgs based of options supplied (at the moment just status masks) * This filter msgs based of options supplied (at the moment just status masks)
* @param msgIds The msgsIds to filter * @param msgIds The msgsIds to filter