mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T237, find latest DB cache ts and only init caches if there are no or old cache data
This commit is contained in:
@@ -865,11 +865,18 @@ namespace BlackCore
|
||||
m_webDataServices.reset(
|
||||
new CWebDataServices(m_webReadersUsed, m_dbReaderConfig, {}, this)
|
||||
);
|
||||
Q_ASSERT_X(m_webDataServices, Q_FUNC_INFO, "Missing web services");
|
||||
|
||||
// caches from local files (i.e. the files delivered)
|
||||
if (this->isInstallerOptionSet())
|
||||
{
|
||||
msgs.push_back(m_webDataServices->initDbCachesFromLocalResourceFiles(false));
|
||||
const QDateTime ts = m_webDataServices->getLatestDbEntityCacheTimestamp();
|
||||
if (!ts.isValid() || ts < QDateTime::currentDateTimeUtc().addYears(-2))
|
||||
{
|
||||
// we only init, if there are:
|
||||
// a) no cache timestamps b) or it was not updated for some years
|
||||
msgs.push_back(m_webDataServices->initDbCachesFromLocalResourceFiles(false));
|
||||
}
|
||||
}
|
||||
|
||||
// watchdog
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace BlackCore
|
||||
//! Delegates to QCommandLineParser::isSet
|
||||
bool isParserOptionSet(const QString &option) const;
|
||||
|
||||
//! Installer called?
|
||||
//! Called by installer?
|
||||
bool isInstallerOptionSet() const;
|
||||
|
||||
//! Delegates to QCommandLineParser::isSet
|
||||
|
||||
@@ -419,6 +419,22 @@ namespace BlackCore
|
||||
return reader->getLatestEntityTimestampFromSharedInfoObjects(entity);
|
||||
}
|
||||
|
||||
QDateTime CWebDataServices::getLatestDbEntityCacheTimestamp() const
|
||||
{
|
||||
QDateTime latest;
|
||||
const CEntityFlags::EntitySet set = CEntityFlags::asSingleEntities(CEntityFlags::AllDbEntitiesNoInfoObjects);
|
||||
for (CEntityFlags::Entity e : set)
|
||||
{
|
||||
const QDateTime ts = this->getCacheTimestamp(e);
|
||||
if (!ts.isValid()) { continue; }
|
||||
if (!latest.isValid() || latest < ts)
|
||||
{
|
||||
latest = ts;
|
||||
}
|
||||
}
|
||||
return latest;
|
||||
}
|
||||
|
||||
CEntityFlags::Entity CWebDataServices::getEntitiesWithNewerSharedFile(CEntityFlags::Entity entities) const
|
||||
{
|
||||
Q_ASSERT_X(m_sharedInfoDataReader, Q_FUNC_INFO, "Shared info reader was not initialized");
|
||||
|
||||
@@ -77,8 +77,7 @@ namespace BlackCore
|
||||
/*!
|
||||
* Encapsulates reading data from web sources
|
||||
*/
|
||||
class BLACKCORE_EXPORT CWebDataServices :
|
||||
public QObject
|
||||
class BLACKCORE_EXPORT CWebDataServices : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -385,11 +384,17 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const;
|
||||
|
||||
//! Latest DB object timestamp, or null if there is no such timestamp
|
||||
//! \threadsafe
|
||||
QDateTime getLatestDbEntityCacheTimestamp() const;
|
||||
|
||||
//! Corresponding DB timestamp if applicable
|
||||
//! \remark from Db::CInfoDataReader
|
||||
//! \threadsafe
|
||||
QDateTime getLatestDbEntityTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const;
|
||||
|
||||
//! Shared info object timestamp
|
||||
//! \remark from Db::CInfoDataReader
|
||||
//! \threadsafe
|
||||
QDateTime getLatestSharedInfoObjectTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user