mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-24 09:54:16 +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 "airportdatareader.h"
|
||||||
#include "blackcore/db/databaseutils.h"
|
#include "blackcore/db/databaseutils.h"
|
||||||
#include "blackcore/application.h"
|
#include "blackcore/application.h"
|
||||||
#include "blackmisc/logmessage.h"
|
|
||||||
#include "blackmisc/network/networkutils.h"
|
#include "blackmisc/network/networkutils.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
#include "blackmisc/verify.h"
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -159,16 +160,23 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
CAirportList airports;
|
CAirportList airports;
|
||||||
|
CAirportList inconsistent;
|
||||||
if (res.isRestricted())
|
if (res.isRestricted())
|
||||||
{
|
{
|
||||||
const CAirportList incAirports(CAirportList::fromDatabaseJson(res));
|
const CAirportList incrementalAirports(CAirportList::fromDatabaseJson(res, &inconsistent));
|
||||||
if (incAirports.isEmpty()) { return; } // currently ignored
|
if (incrementalAirports.isEmpty()) { return; } // currently ignored
|
||||||
airports = this->getAirports();
|
airports = this->getAirports();
|
||||||
airports.replaceOrAddObjectsByKey(incAirports);
|
airports.replaceOrAddObjectsByKey(incrementalAirports);
|
||||||
}
|
}
|
||||||
else
|
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();
|
const int size = airports.size();
|
||||||
|
|||||||
@@ -339,10 +339,10 @@ namespace BlackCore
|
|||||||
if (res.isRestricted())
|
if (res.isRestricted())
|
||||||
{
|
{
|
||||||
// create full list if it was just incremental
|
// create full list if it was just incremental
|
||||||
const CCountryList incCountries(CCountryList::fromDatabaseJson(res));
|
const CCountryList incrementalCountries(CCountryList::fromDatabaseJson(res));
|
||||||
if (incCountries.isEmpty()) { return; } // currently ignored
|
if (incrementalCountries.isEmpty()) { return; } // currently ignored
|
||||||
countries = this->getCountries();
|
countries = this->getCountries();
|
||||||
countries.replaceOrAddObjectsByKey(incCountries);
|
countries.replaceOrAddObjectsByKey(incrementalCountries);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,9 +79,10 @@ namespace BlackMisc
|
|||||||
return icaos;
|
return icaos;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAirportList CAirportList::fromDatabaseJson(const QJsonArray &array)
|
CAirportList CAirportList::fromDatabaseJson(const QJsonArray &array, CAirportList *inconsistent)
|
||||||
{
|
{
|
||||||
CAirportList airports;
|
CAirportList airports;
|
||||||
|
Q_UNUSED(inconsistent); // not yet implemented, but signature already prepared
|
||||||
for (const QJsonValue &value : array)
|
for (const QJsonValue &value : array)
|
||||||
{
|
{
|
||||||
const CAirport airport(CAirport::fromDatabaseJson(value.toObject()));
|
const CAirport airport(CAirport::fromDatabaseJson(value.toObject()));
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace BlackMisc
|
|||||||
QStringList allIcaoCodes(bool sorted) const;
|
QStringList allIcaoCodes(bool sorted) const;
|
||||||
|
|
||||||
//! From our DB JSON
|
//! From our DB JSON
|
||||||
static CAirportList fromDatabaseJson(const QJsonArray &array);
|
static CAirportList fromDatabaseJson(const QJsonArray &array, CAirportList *inconsistent = nullptr);
|
||||||
};
|
};
|
||||||
} //namespace
|
} //namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user