MAINT-5478 FIXED Keep history according to calendar days and don't completely remove events while changing threshold.
parent
0bbb17226c
commit
1086ce1f09
|
|
@ -112,6 +112,7 @@ void LLExperienceLog::handleExperienceMessage(LLSD& message)
|
|||
}
|
||||
message["Time"] = time_of_day;
|
||||
mEvents[day].append(message);
|
||||
mEventsToSave[day].append(message);
|
||||
mSignals(message);
|
||||
}
|
||||
|
||||
|
|
@ -180,9 +181,8 @@ void LLExperienceLog::notify( LLSD& message )
|
|||
|
||||
void LLExperienceLog::saveEvents()
|
||||
{
|
||||
eraseExpired();
|
||||
std::string filename = getFilename();
|
||||
LLSD settings = LLSD::emptyMap().with("Events", mEvents);
|
||||
LLSD settings = LLSD::emptyMap().with("Events", mEventsToSave);
|
||||
|
||||
settings["MaxDays"] = (int)mMaxDays;
|
||||
settings["Notify"] = mNotifyNewEvent;
|
||||
|
|
@ -217,9 +217,8 @@ void LLExperienceLog::loadEvents()
|
|||
if(mMaxDays > 0 && settings.has("Events"))
|
||||
{
|
||||
mEvents = settings["Events"];
|
||||
mEventsToSave = mEvents;
|
||||
}
|
||||
|
||||
eraseExpired();
|
||||
}
|
||||
|
||||
LLExperienceLog::~LLExperienceLog()
|
||||
|
|
@ -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
|
||||
{
|
||||
return mEvents;
|
||||
|
|
@ -248,10 +267,6 @@ void LLExperienceLog::clear()
|
|||
void LLExperienceLog::setMaxDays( U32 val )
|
||||
{
|
||||
mMaxDays = val;
|
||||
if(mMaxDays > 0)
|
||||
{
|
||||
eraseExpired();
|
||||
}
|
||||
}
|
||||
|
||||
LLExperienceLog::callback_connection_t LLExperienceLog::addUpdateSignal( const callback_slot_t& cb )
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ public:
|
|||
static void notify(LLSD& message);
|
||||
static std::string getFilename();
|
||||
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:
|
||||
LLExperienceLog();
|
||||
void handleExperienceMessage(LLSD& message);
|
||||
|
|
@ -68,7 +70,10 @@ protected:
|
|||
void saveEvents();
|
||||
void eraseExpired();
|
||||
|
||||
|
||||
|
||||
LLSD mEvents;
|
||||
LLSD mEventsToSave;
|
||||
callback_signal_t mSignals;
|
||||
callback_connection_t mNotifyConnection;
|
||||
U32 mMaxDays;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ LLPanelExperienceLog::LLPanelExperienceLog( )
|
|||
buildFromFile("panel_experience_log.xml");
|
||||
}
|
||||
|
||||
|
||||
BOOL LLPanelExperienceLog::postBuild( void )
|
||||
{
|
||||
LLExperienceLog* log = LLExperienceLog::getInstance();
|
||||
|
|
@ -112,7 +111,7 @@ void LLPanelExperienceLog::refresh()
|
|||
int itemsToSkip = mPageSize*mCurrentPage;
|
||||
int items = 0;
|
||||
bool moreItems = false;
|
||||
|
||||
LLSD events_to_save = events;
|
||||
if (!events.emptyMap())
|
||||
{
|
||||
LLSD::map_const_iterator day = events.endMap();
|
||||
|
|
@ -120,6 +119,13 @@ void LLPanelExperienceLog::refresh()
|
|||
{
|
||||
--day;
|
||||
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();
|
||||
if(itemsToSkip > size)
|
||||
{
|
||||
|
|
@ -164,6 +170,7 @@ void LLPanelExperienceLog::refresh()
|
|||
}
|
||||
} while (day != events.beginMap());
|
||||
}
|
||||
LLExperienceLog::getInstance()->setEventsToSave(events_to_save);
|
||||
if(waiting)
|
||||
{
|
||||
mEventList->deleteAllItems();
|
||||
|
|
@ -237,12 +244,8 @@ void LLPanelExperienceLog::notifyChanged()
|
|||
void LLPanelExperienceLog::logSizeChanged()
|
||||
{
|
||||
int value = (int)(getChild<LLSpinCtrl>("logsizespinner")->get());
|
||||
bool dirty = value > 0 && value < LLExperienceLog::instance().getMaxDays();
|
||||
LLExperienceLog::instance().setMaxDays(value);
|
||||
if(dirty)
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
void LLPanelExperienceLog::onSelectionChanged()
|
||||
|
|
|
|||
Loading…
Reference in New Issue