X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fmessagelistinserter.cpp;h=b608145a7a597d232d4f487ab4b7c1d77b8c6247;hb=c7fcb4c4bc5012a584add81a9509fc1f84c3c688;hp=57d40f9930b3073bd514129455a126cccc3b31cd;hpb=6b896a9e1dc143bba86795be1e9336549db9b85f;p=fms.git diff --git a/src/freenet/messagelistinserter.cpp b/src/freenet/messagelistinserter.cpp index 57d40f9..b608145 100644 --- a/src/freenet/messagelistinserter.cpp +++ b/src/freenet/messagelistinserter.cpp @@ -11,7 +11,7 @@ MessageListInserter::MessageListInserter() Initialize(); } -MessageListInserter::MessageListInserter(FCPv2 *fcp):IIndexInserter(fcp) +MessageListInserter::MessageListInserter(FCPv2 *fcp):IIndexInserter(fcp) { Initialize(); } @@ -21,6 +21,7 @@ void MessageListInserter::CheckForNeededInsert() // only do 1 insert at a time if(m_inserting.size()==0) { + std::string sql; DateTime now; DateTime previous; @@ -29,10 +30,15 @@ void MessageListInserter::CheckForNeededInsert() previous.Add(0,0,0,-m_daysbackward); - // query for identities that have messages in the past X days and we haven't inserted lists for in the past hour - SQLite3DB::Statement st=m_db->Prepare("SELECT tblLocalIdentity.LocalIdentityID FROM tblLocalIdentity INNER JOIN tblMessageInserts ON tblLocalIdentity.LocalIdentityID=tblMessageInserts.LocalIdentityID WHERE tblMessageInserts.Day>=? AND (tblLocalIdentity.LastInsertedMessageList<=? OR tblLocalIdentity.LastInsertedMessageList IS NULL OR tblLocalIdentity.LastInsertedMessageList='');"); + // query for identities that have messages in the past X days and (we haven't inserted lists for in the past 30 minutes OR identity has a record in tmpMessageListInsert) + sql="SELECT tblLocalIdentity.LocalIdentityID "; + sql+="FROM tblLocalIdentity INNER JOIN tblMessageInserts ON tblLocalIdentity.LocalIdentityID=tblMessageInserts.LocalIdentityID "; + sql+="WHERE tblMessageInserts.Day>=? AND ((tblLocalIdentity.LastInsertedMessageList<=? OR tblLocalIdentity.LastInsertedMessageList IS NULL OR tblLocalIdentity.LastInsertedMessageList='') OR tblLocalIdentity.LocalIdentityID IN (SELECT LocalIdentityID FROM tmpMessageListInsert)) "; + sql+=";"; + + SQLite3DB::Statement st=m_db->Prepare(sql); st.Bind(0,previous.Format("%Y-%m-%d")); - st.Bind(1,(now-(1.0/24.0)).Format("%Y-%m-%d %H:%M:%S")); + st.Bind(1,(now-(1.0/48.0)).Format("%Y-%m-%d %H:%M:%S")); st.Step(); if(st.RowReturned()) @@ -93,8 +99,15 @@ const bool MessageListInserter::HandlePutSuccessful(FCPMessage &message) st.Bind(1,localidentityid); st.Step(); + // delete any record from tmpMessageListInsert + st=m_db->Prepare("DELETE FROM tmpMessageListInsert WHERE LocalIdentityID=?;"); + st.Bind(0,localidentityid); + st.Step(); + RemoveFromInsertList(localidentityid); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageListInserter::HandlePutSuccessful successfully inserted MessageList."); + return true; } @@ -104,7 +117,7 @@ void MessageListInserter::Initialize() m_fcpuniquename="MessageListInserter"; m_daysbackward=0; - Option::instance()->Get("MessageListDaysBackward",tempval); + Option::Instance()->Get("MessageListDaysBackward",tempval); StringFunctions::Convert(tempval,m_daysbackward); }