mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
Fixed missing distributor read and minor improvements
This commit is contained in:
@@ -55,6 +55,7 @@ namespace BlackCore
|
|||||||
while (currentEntity)
|
while (currentEntity)
|
||||||
{
|
{
|
||||||
const CDatabaseReaderConfig config(this->getConfigForEntity(currentEntity));
|
const CDatabaseReaderConfig config(this->getConfigForEntity(currentEntity));
|
||||||
|
const QString currentEntityName = CEntityFlags::flagToString(currentEntity);
|
||||||
if (config.getRetrievalMode().testFlag(CDbFlags::Cached))
|
if (config.getRetrievalMode().testFlag(CDbFlags::Cached))
|
||||||
{
|
{
|
||||||
if (hasInfoObjects)
|
if (hasInfoObjects)
|
||||||
@@ -64,28 +65,23 @@ namespace BlackCore
|
|||||||
const QDateTime latestEntityTs(this->getLatestEntityTimestamp(currentEntity));
|
const QDateTime latestEntityTs(this->getLatestEntityTimestamp(currentEntity));
|
||||||
const qint64 cacheTimestamp = cacheTs.isValid() ? cacheTs.toMSecsSinceEpoch() : -1;
|
const qint64 cacheTimestamp = cacheTs.isValid() ? cacheTs.toMSecsSinceEpoch() : -1;
|
||||||
const qint64 latestEntityTimestamp = latestEntityTs.isValid() ? latestEntityTs.toMSecsSinceEpoch() : -1;
|
const qint64 latestEntityTimestamp = latestEntityTs.isValid() ? latestEntityTs.toMSecsSinceEpoch() : -1;
|
||||||
Q_ASSERT_X(latestEntityTimestamp > 0, Q_FUNC_INFO, "Missing timestamp");
|
Q_ASSERT_X(latestEntityTimestamp >= 0, Q_FUNC_INFO, "Missing timestamp");
|
||||||
if (!changedUrl && cacheTimestamp >= latestEntityTimestamp && cacheTimestamp > 0)
|
if (!changedUrl && cacheTimestamp >= latestEntityTimestamp && cacheTimestamp >= 0 && latestEntityTimestamp >= 0)
|
||||||
{
|
{
|
||||||
this->syncronizeCaches(currentEntity);
|
this->syncronizeCaches(currentEntity);
|
||||||
entities &= ~currentEntity; // do not load from web
|
entities &= ~currentEntity; // do not load from web
|
||||||
cachedEntities |= currentEntity; // read from cache
|
cachedEntities |= currentEntity; // read from cache
|
||||||
CLogMessage(this).info("Using cache for %1 (%2, %3)")
|
CLogMessage(this).info("Using cache for %1 (%2, %3)") << currentEntityName << cacheTs.toString() << cacheTimestamp;
|
||||||
<< CEntityFlags::flagToString(currentEntity)
|
|
||||||
<< cacheTs.toString() << cacheTimestamp;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (changedUrl)
|
if (changedUrl)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Data location changed, will override cache for %1")
|
CLogMessage(this).info("Data location changed, will override cache for %1") << currentEntityName;
|
||||||
<< CEntityFlags::flagToString(currentEntity);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Cache for %1 outdated, latest entity (%2, %3)")
|
CLogMessage(this).info("Cache for %1 outdated, latest entity (%2, %3)") << currentEntityName << latestEntityTs.toString() << latestEntityTimestamp;
|
||||||
<< CEntityFlags::flagToString(currentEntity)
|
|
||||||
<< latestEntityTs.toString() << latestEntityTimestamp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,8 +90,7 @@ namespace BlackCore
|
|||||||
// no info objects, server down
|
// no info objects, server down
|
||||||
this->syncronizeCaches(currentEntity);
|
this->syncronizeCaches(currentEntity);
|
||||||
const int c = this->getCacheCount(currentEntity);
|
const int c = this->getCacheCount(currentEntity);
|
||||||
CLogMessage(this).info("No info object for %1, using cache with %2 objects")
|
CLogMessage(this).info("No info object for %1, using cache with %2 objects") << currentEntityName << c;
|
||||||
<< CEntityFlags::flagToString(currentEntity) << c;
|
|
||||||
entities &= ~currentEntity; // do not load from web
|
entities &= ~currentEntity; // do not load from web
|
||||||
cachedEntities |= currentEntity; // read from cache
|
cachedEntities |= currentEntity; // read from cache
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ namespace BlackCore
|
|||||||
liveries = CLiveryList::fromDatabaseJson(res);
|
liveries = CLiveryList::fromDatabaseJson(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = liveries.size();
|
const int n = liveries.size();
|
||||||
qint64 latestTimestamp = liveries.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = liveries.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
{
|
{
|
||||||
@@ -311,7 +311,7 @@ namespace BlackCore
|
|||||||
distributors = CDistributorList::fromDatabaseJson(res);
|
distributors = CDistributorList::fromDatabaseJson(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = distributors.size();
|
const int n = distributors.size();
|
||||||
qint64 latestTimestamp = distributors.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = distributors.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
{
|
{
|
||||||
@@ -354,7 +354,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// syncronized update
|
// syncronized update
|
||||||
int n = models.size();
|
const int n = models.size();
|
||||||
qint64 latestTimestamp = models.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = models.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace BlackMisc
|
|||||||
if (this->m_tableName.contains("livery", Qt::CaseInsensitive)) { return CEntityFlags::LiveryEntity; }
|
if (this->m_tableName.contains("livery", Qt::CaseInsensitive)) { return CEntityFlags::LiveryEntity; }
|
||||||
if (this->m_tableName.contains("aircraftmodel", Qt::CaseInsensitive)) { return CEntityFlags::ModelEntity; }
|
if (this->m_tableName.contains("aircraftmodel", Qt::CaseInsensitive)) { return CEntityFlags::ModelEntity; }
|
||||||
if (this->m_tableName.contains("country", Qt::CaseInsensitive)) { return CEntityFlags::CountryEntity; }
|
if (this->m_tableName.contains("country", Qt::CaseInsensitive)) { return CEntityFlags::CountryEntity; }
|
||||||
|
if (this->m_tableName.contains("distributor", Qt::CaseInsensitive)) { return CEntityFlags::DistributorEntity; }
|
||||||
return CEntityFlags::NoEntity;
|
return CEntityFlags::NoEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ namespace BlackMisc
|
|||||||
if (entities.testFlag(LiveryEntity)) { entities &= ~LiveryEntity; return LiveryEntity; }
|
if (entities.testFlag(LiveryEntity)) { entities &= ~LiveryEntity; return LiveryEntity; }
|
||||||
if (entities.testFlag(CountryEntity)) { entities &= ~CountryEntity; return CountryEntity; }
|
if (entities.testFlag(CountryEntity)) { entities &= ~CountryEntity; return CountryEntity; }
|
||||||
if (entities.testFlag(ModelEntity)) { entities &= ~ModelEntity; return ModelEntity; }
|
if (entities.testFlag(ModelEntity)) { entities &= ~ModelEntity; return ModelEntity; }
|
||||||
|
if (entities.testFlag(DistributorEntity)) { entities &= ~DistributorEntity; return DistributorEntity; }
|
||||||
return NoEntity;
|
return NoEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user