mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T182, added coverageSummary / count functions
This commit is contained in:
@@ -183,6 +183,17 @@ namespace BlackMisc
|
|||||||
return objs.oldestDbTimestamp();
|
return objs.oldestDbTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
|
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::countWithValidDbKey() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
|
||||||
|
{
|
||||||
|
if (obj.hasValidDbKey()) { count++; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
QDateTime IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::latestDbTimestamp() const
|
QDateTime IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::latestDbTimestamp() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
|||||||
//! All keys as set
|
//! All keys as set
|
||||||
QSet<KEYTYPE> toDbKeySet() const;
|
QSet<KEYTYPE> toDbKeySet() const;
|
||||||
|
|
||||||
//! All keys as string set (also int keys will be converted to string)
|
//! All keys as string set (also integer keys will be converted to string)
|
||||||
QSet<QString> toDbKeyStringSet() const;
|
QSet<QString> toDbKeyStringSet() const;
|
||||||
|
|
||||||
//! The DB keys as string
|
//! The DB keys as string
|
||||||
@@ -62,6 +62,9 @@ namespace BlackMisc
|
|||||||
//! Latest DB timestamp (means objects with DB key)
|
//! Latest DB timestamp (means objects with DB key)
|
||||||
QDateTime oldestDbTimestamp() const;
|
QDateTime oldestDbTimestamp() const;
|
||||||
|
|
||||||
|
//! Number of entries with valid DB key
|
||||||
|
int countWithValidDbKey() const;
|
||||||
|
|
||||||
//! From DB JSON with default prefixes
|
//! From DB JSON with default prefixes
|
||||||
//! \remark Specialized classes might have their own fromDatabaseJson implementation
|
//! \remark Specialized classes might have their own fromDatabaseJson implementation
|
||||||
static CONTAINER fromDatabaseJson(const QJsonArray &array);
|
static CONTAINER fromDatabaseJson(const QJsonArray &array);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
|
#include <QStringBuilder>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
@@ -623,6 +624,46 @@ namespace BlackMisc
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CAircraftModelList::countVtolAircraft() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const CAircraftModel &model : (*this))
|
||||||
|
{
|
||||||
|
if (model.isVtol()) { count++; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAircraftModelList::countMilitaryAircraft() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const CAircraftModel &model : (*this))
|
||||||
|
{
|
||||||
|
if (model.isMilitary()) { count++; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAircraftModelList::countCivilianAircraft() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const CAircraftModel &model : (*this))
|
||||||
|
{
|
||||||
|
if (model.isCivilian()) { count++; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAircraftModelList::countDifferentAirlines() const
|
||||||
|
{
|
||||||
|
return this->getAirlineVDesignators().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAircraftModelList::countCombinedTypes() const
|
||||||
|
{
|
||||||
|
return this->getCombinedTypes().size();
|
||||||
|
}
|
||||||
|
|
||||||
void CAircraftModelList::updateDistributor(const CDistributor &distributor)
|
void CAircraftModelList::updateDistributor(const CDistributor &distributor)
|
||||||
{
|
{
|
||||||
for (CAircraftModel &model : *this)
|
for (CAircraftModel &model : *this)
|
||||||
@@ -678,6 +719,23 @@ namespace BlackMisc
|
|||||||
return designators;
|
return designators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSet<QString> CAircraftModelList::getCombinedTypes() const
|
||||||
|
{
|
||||||
|
QSet<QString> combinedCodes;
|
||||||
|
for (const CAircraftModel &model : *this)
|
||||||
|
{
|
||||||
|
const QString ct = model.getAircraftIcaoCode().getCombinedType();
|
||||||
|
if (ct.isEmpty()) { continue; }
|
||||||
|
combinedCodes.insert(ct);
|
||||||
|
}
|
||||||
|
return combinedCodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CAircraftModelList::getCombinedTypesAsString(const QString &separator) const
|
||||||
|
{
|
||||||
|
return this->getCombinedTypes().values().join(separator);
|
||||||
|
}
|
||||||
|
|
||||||
void CAircraftModelList::updateAircraftIcao(const CAircraftIcaoCode &icao)
|
void CAircraftModelList::updateAircraftIcao(const CAircraftIcaoCode &icao)
|
||||||
{
|
{
|
||||||
for (CAircraftModel &model : *this)
|
for (CAircraftModel &model : *this)
|
||||||
@@ -719,7 +777,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
// normally prefer colors if there is no airline
|
// normally prefer colors if there is no airline
|
||||||
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("Prefer color liveries: '%1', airline: '%2', ignore zero scores: '%3'").arg(boolToYesNo(preferColorLiveries), remoteModel.getAirlineIcaoCodeDesignator(), boolToYesNo(ignoreZeroScores)));
|
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("Prefer color liveries: '%1', airline: '%2', ignore zero scores: '%3'").arg(boolToYesNo(preferColorLiveries), remoteModel.getAirlineIcaoCodeDesignator(), boolToYesNo(ignoreZeroScores)));
|
||||||
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("--- Start scoring in list with %1 models, airline liveries: %2, color liveries: %3").arg(this->size()).arg(this->countModelsWithAirlineLivery()).arg(this->countModelsWithColorLivery()));
|
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("--- Start scoring in list with %1 models").arg(this->size()));
|
||||||
|
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), this->coverageSummary());
|
||||||
|
|
||||||
int c = 1;
|
int c = 1;
|
||||||
for (const CAircraftModel &model : *this)
|
for (const CAircraftModel &model : *this)
|
||||||
@@ -912,5 +971,20 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CAircraftModelList::coverageSummary(const QString &separator) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
QStringLiteral("Entries: ") % QString::number(this->size()) %
|
||||||
|
QStringLiteral(" valid DB keys: ") % QString::number(this->countWithValidDbKey()) % separator %
|
||||||
|
QStringLiteral("color liveries: ") % QString::number(this->countModelsWithColorLivery()) %
|
||||||
|
QStringLiteral(" airline liveries: ") % QString::number(this->countModelsWithAirlineLivery()) % separator %
|
||||||
|
QStringLiteral("VTOL: ") % QString::number(this->countVtolAircraft()) % separator %
|
||||||
|
QStringLiteral("Simulators: ") % this->countPerSimulator().toQString() % separator %
|
||||||
|
QStringLiteral("Military: ") % QString::number(this->countMilitaryAircraft()) %
|
||||||
|
QStringLiteral(" civilian: ") % QString::number(this->countCivilianAircraft()) % separator %
|
||||||
|
QStringLiteral("Different airlines: ") % QString::number(this->countDifferentAirlines()) % separator %
|
||||||
|
QStringLiteral("Combined types: ") % this->getCombinedTypesAsString();
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -243,6 +243,21 @@ namespace BlackMisc
|
|||||||
//! Models with an airline livery
|
//! Models with an airline livery
|
||||||
int countModelsWithAirlineLivery() const;
|
int countModelsWithAirlineLivery() const;
|
||||||
|
|
||||||
|
//! Count VTOL aircraft
|
||||||
|
int countVtolAircraft() const;
|
||||||
|
|
||||||
|
//! Count military aircraft
|
||||||
|
int countMilitaryAircraft() const;
|
||||||
|
|
||||||
|
//! Count civilian aircraft
|
||||||
|
int countCivilianAircraft() const;
|
||||||
|
|
||||||
|
//! Number of different airlines
|
||||||
|
int countDifferentAirlines() const;
|
||||||
|
|
||||||
|
//! Count different combined types
|
||||||
|
int countCombinedTypes() const;
|
||||||
|
|
||||||
//! Update distributor, all models in list are set to given distributor
|
//! Update distributor, all models in list are set to given distributor
|
||||||
void updateDistributor(const CDistributor &distributor);
|
void updateDistributor(const CDistributor &distributor);
|
||||||
|
|
||||||
@@ -258,6 +273,12 @@ namespace BlackMisc
|
|||||||
//! Airline virtual designators
|
//! Airline virtual designators
|
||||||
QSet<QString> getAirlineVDesignators() const;
|
QSet<QString> getAirlineVDesignators() const;
|
||||||
|
|
||||||
|
//! All combined types
|
||||||
|
QSet<QString> getCombinedTypes() const;
|
||||||
|
|
||||||
|
//! All combined types as string
|
||||||
|
QString getCombinedTypesAsString(const QString &separator = ", ") const;
|
||||||
|
|
||||||
//! Update aircraft ICAO
|
//! Update aircraft ICAO
|
||||||
void updateAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
|
void updateAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
|
||||||
|
|
||||||
@@ -299,6 +320,9 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! As HTML summary
|
//! As HTML summary
|
||||||
QString asHtmlSummary() const;
|
QString asHtmlSummary() const;
|
||||||
|
|
||||||
|
//! What kind of models are represented here
|
||||||
|
QString coverageSummary(const QString &separator = "\n") const;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user