Skip to content
Snippets Groups Projects
Commit 1086ce1f authored by Mnikolenko ProductEngine's avatar Mnikolenko ProductEngine
Browse files

MAINT-5478 FIXED Keep history according to calendar days and don't completely...

MAINT-5478 FIXED Keep history according to calendar days and don't completely remove events while changing threshold.
parent 0bbb1722
No related branches found
No related tags found
No related merge requests found
...@@ -112,6 +112,7 @@ void LLExperienceLog::handleExperienceMessage(LLSD& message) ...@@ -112,6 +112,7 @@ void LLExperienceLog::handleExperienceMessage(LLSD& message)
} }
message["Time"] = time_of_day; message["Time"] = time_of_day;
mEvents[day].append(message); mEvents[day].append(message);
mEventsToSave[day].append(message);
mSignals(message); mSignals(message);
} }
...@@ -180,9 +181,8 @@ void LLExperienceLog::notify( LLSD& message ) ...@@ -180,9 +181,8 @@ void LLExperienceLog::notify( LLSD& message )
void LLExperienceLog::saveEvents() void LLExperienceLog::saveEvents()
{ {
eraseExpired();
std::string filename = getFilename(); std::string filename = getFilename();
LLSD settings = LLSD::emptyMap().with("Events", mEvents); LLSD settings = LLSD::emptyMap().with("Events", mEventsToSave);
settings["MaxDays"] = (int)mMaxDays; settings["MaxDays"] = (int)mMaxDays;
settings["Notify"] = mNotifyNewEvent; settings["Notify"] = mNotifyNewEvent;
...@@ -217,9 +217,8 @@ void LLExperienceLog::loadEvents() ...@@ -217,9 +217,8 @@ void LLExperienceLog::loadEvents()
if(mMaxDays > 0 && settings.has("Events")) if(mMaxDays > 0 && settings.has("Events"))
{ {
mEvents = settings["Events"]; mEvents = settings["Events"];
mEventsToSave = mEvents;
} }
eraseExpired();
} }
LLExperienceLog::~LLExperienceLog() LLExperienceLog::~LLExperienceLog()
...@@ -235,6 +234,26 @@ void LLExperienceLog::eraseExpired() ...@@ -235,6 +234,26 @@ void LLExperienceLog::eraseExpired()
} }
} }
bool LLExperienceLog::isNotExpired(std::string& date)
{
LLDate event_date;
S32 month, day, year;
S32 matched = sscanf(date.c_str(), "%d-%d-%d", &year, &month, &day);
if (matched != 3) return false;
event_date.fromYMDHMS(year, month, day);
const U32 seconds_in_day = 24 * 60 * 60;
S32 curr_year = 0, curr_month = 0, curr_day = 0;
LLDate curr_date = LLDate::now();
curr_date.split(&curr_year, &curr_month, &curr_day);
curr_date.fromYMDHMS(curr_year, curr_month, curr_day); // Set hour, min, and sec to 0
LLDate boundary_date = LLDate(curr_date.secondsSinceEpoch() - seconds_in_day*getMaxDays());
return event_date >= boundary_date;
}
const LLSD& LLExperienceLog::getEvents() const const LLSD& LLExperienceLog::getEvents() const
{ {
return mEvents; return mEvents;
...@@ -248,10 +267,6 @@ void LLExperienceLog::clear() ...@@ -248,10 +267,6 @@ void LLExperienceLog::clear()
void LLExperienceLog::setMaxDays( U32 val ) void LLExperienceLog::setMaxDays( U32 val )
{ {
mMaxDays = val; mMaxDays = val;
if(mMaxDays > 0)
{
eraseExpired();
}
} }
LLExperienceLog::callback_connection_t LLExperienceLog::addUpdateSignal( const callback_slot_t& cb ) LLExperienceLog::callback_connection_t LLExperienceLog::addUpdateSignal( const callback_slot_t& cb )
......
...@@ -59,6 +59,8 @@ class LLExperienceLog : public LLSingleton<LLExperienceLog> ...@@ -59,6 +59,8 @@ class LLExperienceLog : public LLSingleton<LLExperienceLog>
static void notify(LLSD& message); static void notify(LLSD& message);
static std::string getFilename(); static std::string getFilename();
static std::string getPermissionString(const LLSD& message, const std::string& base); static std::string getPermissionString(const LLSD& message, const std::string& base);
void setEventsToSave(LLSD new_events){mEventsToSave = new_events; }
bool isNotExpired(std::string& date);
protected: protected:
LLExperienceLog(); LLExperienceLog();
void handleExperienceMessage(LLSD& message); void handleExperienceMessage(LLSD& message);
...@@ -68,7 +70,10 @@ class LLExperienceLog : public LLSingleton<LLExperienceLog> ...@@ -68,7 +70,10 @@ class LLExperienceLog : public LLSingleton<LLExperienceLog>
void saveEvents(); void saveEvents();
void eraseExpired(); void eraseExpired();
LLSD mEvents; LLSD mEvents;
LLSD mEventsToSave;
callback_signal_t mSignals; callback_signal_t mSignals;
callback_connection_t mNotifyConnection; callback_connection_t mNotifyConnection;
U32 mMaxDays; U32 mMaxDays;
......
...@@ -54,7 +54,6 @@ LLPanelExperienceLog::LLPanelExperienceLog( ) ...@@ -54,7 +54,6 @@ LLPanelExperienceLog::LLPanelExperienceLog( )
buildFromFile("panel_experience_log.xml"); buildFromFile("panel_experience_log.xml");
} }
BOOL LLPanelExperienceLog::postBuild( void ) BOOL LLPanelExperienceLog::postBuild( void )
{ {
LLExperienceLog* log = LLExperienceLog::getInstance(); LLExperienceLog* log = LLExperienceLog::getInstance();
...@@ -112,7 +111,7 @@ void LLPanelExperienceLog::refresh() ...@@ -112,7 +111,7 @@ void LLPanelExperienceLog::refresh()
int itemsToSkip = mPageSize*mCurrentPage; int itemsToSkip = mPageSize*mCurrentPage;
int items = 0; int items = 0;
bool moreItems = false; bool moreItems = false;
LLSD events_to_save = events;
if (!events.emptyMap()) if (!events.emptyMap())
{ {
LLSD::map_const_iterator day = events.endMap(); LLSD::map_const_iterator day = events.endMap();
...@@ -120,6 +119,13 @@ void LLPanelExperienceLog::refresh() ...@@ -120,6 +119,13 @@ void LLPanelExperienceLog::refresh()
{ {
--day; --day;
const LLSD& dayArray = day->second; const LLSD& dayArray = day->second;
std::string date = day->first;
if(!LLExperienceLog::instance().isNotExpired(date))
{
events_to_save.erase(day->first);
continue;
}
int size = dayArray.size(); int size = dayArray.size();
if(itemsToSkip > size) if(itemsToSkip > size)
{ {
...@@ -164,6 +170,7 @@ void LLPanelExperienceLog::refresh() ...@@ -164,6 +170,7 @@ void LLPanelExperienceLog::refresh()
} }
} while (day != events.beginMap()); } while (day != events.beginMap());
} }
LLExperienceLog::getInstance()->setEventsToSave(events_to_save);
if(waiting) if(waiting)
{ {
mEventList->deleteAllItems(); mEventList->deleteAllItems();
...@@ -237,12 +244,8 @@ void LLPanelExperienceLog::notifyChanged() ...@@ -237,12 +244,8 @@ void LLPanelExperienceLog::notifyChanged()
void LLPanelExperienceLog::logSizeChanged() void LLPanelExperienceLog::logSizeChanged()
{ {
int value = (int)(getChild<LLSpinCtrl>("logsizespinner")->get()); int value = (int)(getChild<LLSpinCtrl>("logsizespinner")->get());
bool dirty = value > 0 && value < LLExperienceLog::instance().getMaxDays();
LLExperienceLog::instance().setMaxDays(value); LLExperienceLog::instance().setMaxDays(value);
if(dirty) refresh();
{
refresh();
}
} }
void LLPanelExperienceLog::onSelectionChanged() void LLPanelExperienceLog::onSelectionChanged()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment