mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
Improved matching logging
This commit is contained in:
committed by
Mat Sutcliffe
parent
949513ce50
commit
56d72b94c1
@@ -403,8 +403,11 @@ namespace BlackCore
|
|||||||
|
|
||||||
// lookup if model is not yet from DB
|
// lookup if model is not yet from DB
|
||||||
const DBTripleIds ids = CAircraftModel::parseNetworkLiveryString(networkLiveryInfo);
|
const DBTripleIds ids = CAircraftModel::parseNetworkLiveryString(networkLiveryInfo);
|
||||||
if (ids.model >= 0)
|
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Livery string with ids: '%1'").arg(ids.toQString())); }
|
||||||
|
|
||||||
|
if (ids.model >= 0 && !modelToLookup.hasModelString())
|
||||||
{
|
{
|
||||||
|
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Model lookup with id %1 from triple ids '%2'").arg(ids.model).arg(ids.toQString())); }
|
||||||
const CAircraftModel modelFromDb = CAircraftMatcher::reverseLookupModelId(ids.model, callsign, log);
|
const CAircraftModel modelFromDb = CAircraftMatcher::reverseLookupModelId(ids.model, callsign, log);
|
||||||
if (modelFromDb.hasValidDbKey())
|
if (modelFromDb.hasValidDbKey())
|
||||||
{
|
{
|
||||||
@@ -416,6 +419,7 @@ namespace BlackCore
|
|||||||
// no direct resolution of model, try livery and aircraft ICAO
|
// no direct resolution of model, try livery and aircraft ICAO
|
||||||
if (!modelToLookup.getAircraftIcaoCode().hasValidDbKey() && ids.aircraft >= 0)
|
if (!modelToLookup.getAircraftIcaoCode().hasValidDbKey() && ids.aircraft >= 0)
|
||||||
{
|
{
|
||||||
|
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Aircraft ICAO lookup with id %1 from triple ids '%2'").arg(ids.aircraft).arg(ids.toQString())); }
|
||||||
const CAircraftIcaoCode icaoFromDb = CAircraftMatcher::reverseLookupAircraftIcaoId(ids.aircraft, callsign, log);
|
const CAircraftIcaoCode icaoFromDb = CAircraftMatcher::reverseLookupAircraftIcaoId(ids.aircraft, callsign, log);
|
||||||
if (icaoFromDb.hasValidDbKey())
|
if (icaoFromDb.hasValidDbKey())
|
||||||
{
|
{
|
||||||
@@ -425,6 +429,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (!modelToLookup.getLivery().hasValidDbKey() && ids.livery >= 0)
|
if (!modelToLookup.getLivery().hasValidDbKey() && ids.livery >= 0)
|
||||||
{
|
{
|
||||||
|
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Livery lookup with id %1 from triple ids '%2'").arg(ids.livery).arg(ids.toQString())); }
|
||||||
const CLivery liveryFromDb = CAircraftMatcher::reverseLookupLiveryId(ids.livery, callsign, log);
|
const CLivery liveryFromDb = CAircraftMatcher::reverseLookupLiveryId(ids.livery, callsign, log);
|
||||||
if (liveryFromDb.hasValidDbKey())
|
if (liveryFromDb.hasValidDbKey())
|
||||||
{
|
{
|
||||||
@@ -489,12 +494,25 @@ namespace BlackCore
|
|||||||
// if no DB livery yet, create own livery
|
// if no DB livery yet, create own livery
|
||||||
if (!model.hasValidDbKey() && !model.getLivery().hasValidDbKey())
|
if (!model.hasValidDbKey() && !model.getLivery().hasValidDbKey())
|
||||||
{
|
{
|
||||||
// create a pseudo livery, try to find airline first
|
|
||||||
if (airlineIcaoCode.hasValidDesignator())
|
if (airlineIcaoCode.hasValidDesignator())
|
||||||
{
|
{
|
||||||
const CLivery liveryDummy(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode, "Generated");
|
if (airlineIcaoCode.hasValidDbKey())
|
||||||
model.setLivery(liveryDummy);
|
{
|
||||||
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Generated livery, set livery `%1`").arg(liveryDummy.getCombinedCodePlusInfo())); }
|
const CLivery stdLivery(sApp->getWebDataServices()->getStdLiveryForAirlineCode(airlineIcaoCode));
|
||||||
|
if (stdLivery.hasValidDbKey())
|
||||||
|
{
|
||||||
|
model.setLivery(stdLivery);
|
||||||
|
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Set standardlivery `%1`").arg(stdLivery.getCombinedCodePlusInfo())); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!model.getLivery().hasValidDbKey())
|
||||||
|
{
|
||||||
|
// create a pseudo livery, try to find airline first
|
||||||
|
const CLivery liveryDummy(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode, "Generated");
|
||||||
|
model.setLivery(liveryDummy);
|
||||||
|
if (log) { CMatchingUtils::addLogDetailsToList(log, callsign, QStringLiteral("Generated livery, set livery `%1`").arg(liveryDummy.getCombinedCodePlusInfo())); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // pseudo livery
|
} // pseudo livery
|
||||||
} // livery from DB
|
} // livery from DB
|
||||||
@@ -1377,15 +1395,22 @@ namespace BlackCore
|
|||||||
mode.testFlag(CAircraftMatcherSetup::ByAirlineGroupSameAsAirline) ||
|
mode.testFlag(CAircraftMatcherSetup::ByAirlineGroupSameAsAirline) ||
|
||||||
(outList.isEmpty() || mode.testFlag(CAircraftMatcherSetup::ByAirlineGroupIfNoAirline)))
|
(outList.isEmpty() || mode.testFlag(CAircraftMatcherSetup::ByAirlineGroupIfNoAirline)))
|
||||||
{
|
{
|
||||||
const CAircraftModelList groupModels = inList.findByAirlineGroup(remoteAircraft.getAirlineIcaoCode());
|
if (remoteAircraft.getAirlineIcaoCode().hasGroupMembership())
|
||||||
outList.replaceOrAddModelsWithString(groupModels, Qt::CaseInsensitive);
|
|
||||||
if (log)
|
|
||||||
{
|
{
|
||||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft,
|
const CAircraftModelList groupModels = inList.findByAirlineGroup(remoteAircraft.getAirlineIcaoCode());
|
||||||
groupModels.isEmpty() ?
|
outList.replaceOrAddModelsWithString(groupModels, Qt::CaseInsensitive);
|
||||||
QStringLiteral("No group models found by using airline group '%1'").arg(remoteAircraft.getAirlineIcaoCode().getGroupDesignator()) :
|
if (log)
|
||||||
QStringLiteral("Added %1 model(s) by using airline group '%2', all members: '%3'").arg(groupModels.sizeInt()).arg(remoteAircraft.getAirlineIcaoCode().getGroupDesignator(), joinStringSet(groupModels.getAirlineVDesignators(), ", ")),
|
{
|
||||||
getLogCategories());
|
CMatchingUtils::addLogDetailsToList(log, remoteAircraft,
|
||||||
|
groupModels.isEmpty() ?
|
||||||
|
QStringLiteral("No group models found by using airline group '%1'").arg(remoteAircraft.getAirlineIcaoCode().getGroupDesignator()) :
|
||||||
|
QStringLiteral("Added %1 model(s) by using airline group '%2', all members: '%3'").arg(groupModels.sizeInt()).arg(remoteAircraft.getAirlineIcaoCode().getGroupDesignator(), joinStringSet(groupModels.getAirlineVDesignators(), ", ")),
|
||||||
|
getLogCategories());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,9 @@ namespace BlackMisc
|
|||||||
//! Group id
|
//! Group id
|
||||||
void setGroupId(int id) { m_groupId = id; }
|
void setGroupId(int id) { m_groupId = id; }
|
||||||
|
|
||||||
|
//! Are we a member of a group?
|
||||||
|
bool hasGroupMembership() const { return m_groupId >= 0 && !m_groupDesignator.isEmpty(); }
|
||||||
|
|
||||||
//! Virtual airline
|
//! Virtual airline
|
||||||
bool isVirtualAirline() const { return m_isVa; }
|
bool isVirtualAirline() const { return m_isVa; }
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
return model >= 0 || livery >= 0 || aircraft >= 0;
|
return model >= 0 || livery >= 0 || aircraft >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Return as string
|
||||||
|
QString toQString() const
|
||||||
|
{
|
||||||
|
return QStringLiteral("Model: %1 Livery: %2 Aircraft: %3").arg(model).arg(livery).arg(aircraft);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Aircraft model (used by another pilot, my models on disk)
|
//! Aircraft model (used by another pilot, my models on disk)
|
||||||
|
|||||||
Reference in New Issue
Block a user