Stop journal entries being created when not needed

This commit is contained in:
Mark Watkins 2014-08-21 07:23:33 +10:00
parent 9d967002c5
commit 86c1cf88a2

View File

@ -1945,7 +1945,7 @@ Session * Daily::CreateJournalSession(QDate date)
Session *sess=new Session(m,0); Session *sess=new Session(m,0);
qint64 st,et; qint64 st,et;
Day *cday=p_profile->GetDay(date,MT_CPAP); Day *cday=p_profile->GetDay(date);
if (cday) { if (cday) {
st=cday->first(); st=cday->first();
et=cday->last(); et=cday->last();
@ -1954,21 +1954,23 @@ Session * Daily::CreateJournalSession(QDate date)
st=qint64(dt.toTime_t())*1000L; st=qint64(dt.toTime_t())*1000L;
et=st+3600000L; et=st+3600000L;
} }
sess->SetSessionID(st / 1000L);
sess->set_first(st); sess->set_first(st);
sess->set_last(et); sess->set_last(et);
sess->SetChanged(true);
m->AddSession(sess); m->AddSession(sess);
return sess; return sess;
} }
Session * Daily::GetJournalSession(QDate date) // Get the first journal session Session * Daily::GetJournalSession(QDate date) // Get the first journal session
{ {
Day *day=p_profile->addDay(date); Day *day=p_profile->GetDay(date, MT_JOURNAL);
if (day) {
Session * session = day->firstSession(MT_JOURNAL); Session * session = day->firstSession(MT_JOURNAL);
if (!session) { if (!session) {
session = CreateJournalSession(date); session = CreateJournalSession(date);
} }
return session; return session;
}
return nullptr;
} }
void Daily::UpdateCPAPGraphs(Day *day) void Daily::UpdateCPAPGraphs(Day *day)