mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T104, return inconsistent airports
This commit is contained in:
committed by
Mathew Sutcliffe
parent
297c2f0539
commit
847fcfbb71
@@ -10,8 +10,9 @@
|
||||
#include "airportdatareader.h"
|
||||
#include "blackcore/db/databaseutils.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include <QNetworkReply>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -159,16 +160,23 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
CAirportList airports;
|
||||
CAirportList inconsistent;
|
||||
if (res.isRestricted())
|
||||
{
|
||||
const CAirportList incAirports(CAirportList::fromDatabaseJson(res));
|
||||
if (incAirports.isEmpty()) { return; } // currently ignored
|
||||
const CAirportList incrementalAirports(CAirportList::fromDatabaseJson(res, &inconsistent));
|
||||
if (incrementalAirports.isEmpty()) { return; } // currently ignored
|
||||
airports = this->getAirports();
|
||||
airports.replaceOrAddObjectsByKey(incAirports);
|
||||
airports.replaceOrAddObjectsByKey(incrementalAirports);
|
||||
}
|
||||
else
|
||||
{
|
||||
airports = CAirportList::fromDatabaseJson(res);
|
||||
airports = CAirportList::fromDatabaseJson(res, &inconsistent);
|
||||
}
|
||||
|
||||
if (!inconsistent.isEmpty())
|
||||
{
|
||||
BLACK_AUDIT_X(false, Q_FUNC_INFO, "Inconsistent aircraft codes");
|
||||
CLogMessage(this).warning("Inconsistent airports: %1") << inconsistent.dbKeysAsStrings(", ");
|
||||
}
|
||||
|
||||
const int size = airports.size();
|
||||
|
||||
@@ -339,10 +339,10 @@ namespace BlackCore
|
||||
if (res.isRestricted())
|
||||
{
|
||||
// create full list if it was just incremental
|
||||
const CCountryList incCountries(CCountryList::fromDatabaseJson(res));
|
||||
if (incCountries.isEmpty()) { return; } // currently ignored
|
||||
const CCountryList incrementalCountries(CCountryList::fromDatabaseJson(res));
|
||||
if (incrementalCountries.isEmpty()) { return; } // currently ignored
|
||||
countries = this->getCountries();
|
||||
countries.replaceOrAddObjectsByKey(incCountries);
|
||||
countries.replaceOrAddObjectsByKey(incrementalCountries);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -79,9 +79,10 @@ namespace BlackMisc
|
||||
return icaos;
|
||||
}
|
||||
|
||||
CAirportList CAirportList::fromDatabaseJson(const QJsonArray &array)
|
||||
CAirportList CAirportList::fromDatabaseJson(const QJsonArray &array, CAirportList *inconsistent)
|
||||
{
|
||||
CAirportList airports;
|
||||
Q_UNUSED(inconsistent); // not yet implemented, but signature already prepared
|
||||
for (const QJsonValue &value : array)
|
||||
{
|
||||
const CAirport airport(CAirport::fromDatabaseJson(value.toObject()));
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace BlackMisc
|
||||
QStringList allIcaoCodes(bool sorted) const;
|
||||
|
||||
//! From our DB JSON
|
||||
static CAirportList fromDatabaseJson(const QJsonArray &array);
|
||||
static CAirportList fromDatabaseJson(const QJsonArray &array, CAirportList *inconsistent = nullptr);
|
||||
};
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user