Commit 569b7f26 authored by Volker Krause's avatar Volker Krause

Add poll time computation for pkpass updates too

parent 505e7697
......@@ -43,7 +43,7 @@ private Q_SLOTS:
{
PkPassManager mgr;
clearPasses(&mgr);
const auto now = QDateTime::currentDateTime();
const auto now = QDateTime::currentDateTime().addSecs(-1);
QSignalSpy addSpy(&mgr, &PkPassManager::passAdded);
QVERIFY(addSpy.isValid());
......
......@@ -464,10 +464,6 @@ void LiveDataManager::pollForUpdates(bool force)
checkTrainTrip(res, batchId);
}
// TODO we need poll time computation for pkpass files first before removing this!
if (!force)
continue;
// check for pkpass updates, for each element in this batch
const auto resIds = m_resMgr->reservationsForBatch(batchId);
for (const auto &resId : resIds) {
......@@ -522,7 +518,7 @@ int LiveDataManager::nextPollTimeForReservation(const QString& resId) const
// check last poll time for this reservation
const auto lastArrivalPoll = m_arrivals.value(resId).timestamp;
const auto lastDeparturePoll = m_departures.value(resId).timestamp;
const auto lastDeparturePoll = lastDeparturePollTime(resId, res);
auto lastRelevantPoll = lastArrivalPoll;
// ignore departure if we have already departed
if (!hasDeparted(resId, res) && lastDeparturePoll.isValid()) {
......@@ -536,4 +532,27 @@ int LiveDataManager::nextPollTimeForReservation(const QString& resId) const
return std::max((it->pollInterval - lastPollDist) * 1000, 0); // we need msecs
}
QDateTime LiveDataManager::lastDeparturePollTime(const QString &batchId, const QVariant &res) const
{
auto dt = m_departures.value(batchId).timestamp;
if (dt.isValid()) {
return dt;
}
// check for pkpass updates
const auto resIds = m_resMgr->reservationsForBatch(batchId);
for (const auto &resId : resIds) {
const auto res = m_resMgr->reservation(resId);
const auto passId = m_pkPassMgr->passId(res);
if (!passId.isEmpty()) {
dt = m_pkPassMgr->updateTime(passId);
}
if (dt.isValid()) {
return dt;
}
}
return dt;
}
#include "moc_livedatamanager.cpp"
......@@ -102,6 +102,9 @@ private:
int nextPollTime() const;
int nextPollTimeForReservation(const QString &resId) const;
/** Last time we queried any kind of departure information for this reservation batch. */
QDateTime lastDeparturePollTime(const QString &batchId, const QVariant &res) const;
ReservationManager *m_resMgr;
PkPassManager *m_pkPassMgr;
std::unique_ptr<KPublicTransport::Manager> m_ptMgr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment