mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
refs #748, fixed airport JSON bugs and removed workaround
* removed workaround in web data services * removed convertFromDatabaseJson functions, not needed * changed to use the correct static fromDatabaseJson functions * fixed prefixes * load correct Country object by loading it as nested object * key and timestamp was missing in CAirport tuple metadata
This commit is contained in:
@@ -21,7 +21,7 @@ namespace BlackCore
|
||||
{
|
||||
namespace Db
|
||||
{
|
||||
CAirportDataReader::CAirportDataReader(QObject* parent, const CDatabaseReaderConfigList &config) :
|
||||
CAirportDataReader::CAirportDataReader(QObject *parent, const CDatabaseReaderConfigList &config) :
|
||||
CDatabaseReader(parent, config, QStringLiteral("CAirportDataReader"))
|
||||
{
|
||||
// void
|
||||
@@ -65,7 +65,7 @@ namespace BlackCore
|
||||
|
||||
void CAirportDataReader::ps_parseAirportData(QNetworkReply *nwReply)
|
||||
{
|
||||
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply);
|
||||
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply);
|
||||
if (res.hasErrorMessage())
|
||||
{
|
||||
CLogMessage::preformatted(res.lastWarningOrAbove());
|
||||
@@ -74,29 +74,26 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
CAirportList airports;
|
||||
|
||||
if (res.isRestricted())
|
||||
{
|
||||
airports = this->getAirports();
|
||||
CAirportList updates;
|
||||
updates.convertFromDatabaseJson(res);
|
||||
CAirportList updates(CAirportList::fromDatabaseJson(res));
|
||||
airports.replaceOrAddObjectsByKey(updates);
|
||||
}
|
||||
else
|
||||
{
|
||||
airports.convertFromDatabaseJson(res);
|
||||
airports = CAirportList::fromDatabaseJson(res);
|
||||
}
|
||||
|
||||
int size = airports.size();
|
||||
qint64 timestamp = lastModifiedMsSinceEpoch(nwReply);
|
||||
if (size > 0 && timestamp < 0)
|
||||
const int size = airports.size();
|
||||
qint64 latestTimestamp = airports.latestTimestampMsecsSinceEpoch();
|
||||
if (size > 0 && latestTimestamp < 0)
|
||||
{
|
||||
CLogMessage(this).error("No timestamp in airport list, setting to last modified value");
|
||||
timestamp = lastModifiedMsSinceEpoch(nwReply);
|
||||
latestTimestamp = lastModifiedMsSinceEpoch(nwReply);
|
||||
}
|
||||
|
||||
m_airportCache.set(airports, timestamp);
|
||||
|
||||
m_airportCache.set(airports, latestTimestamp);
|
||||
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, airports.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ namespace BlackCore
|
||||
//! \copydoc BlackCore::Db::CDatabaseReader::getCacheTimestamp()
|
||||
QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entities) const override;
|
||||
|
||||
//! \copydoc BlackCore::Db::CDatabaseReader:;getCacheCount()
|
||||
//! \copydoc BlackCore::Db::CDatabaseReader::getCacheCount()
|
||||
int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
|
||||
protected:
|
||||
//! \copydoc BlackCore::Db::CDatabaseReader::syncronizeCaches()
|
||||
//! \copydoc BlackCore::Db::CDatabaseReader::synchronizeCaches()
|
||||
void synchronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
|
||||
//! \copydoc BlackCore::Db::CDatabaseReader::invalidateCaches()
|
||||
|
||||
Reference in New Issue
Block a user