Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit eeecab8c authored by Volker Krause's avatar Volker Krause

Sanity-check extracted train trips too

parent e9570959
......@@ -135,6 +135,8 @@ bool ExtractorPostprocessor::filterReservation(const QVariant &res) const
if (resFor.userType() == qMetaTypeId<Flight>()) {
return filterFlight(resFor);
} else if (resFor.userType() == qMetaTypeId<TrainTrip>()) {
return filterTrainTrip(resFor);
}
return true;
}
......@@ -154,3 +156,17 @@ bool ExtractorPostprocessor::filterAirport(const QVariant &airport) const
const auto name = JsonLdDocument::readProperty(airport, "name").toString();
return !iataCode.isEmpty() || !name.isEmpty();
}
bool ExtractorPostprocessor::filterTrainTrip(const QVariant &trip) const
{
const auto depDt = JsonLdDocument::readProperty(trip, "departureTime").toDateTime();
const auto arrDt = JsonLdDocument::readProperty(trip, "arrivalTime").toDateTime();
return filterAirport(JsonLdDocument::readProperty(trip, "departureStation"))
&& filterAirport(JsonLdDocument::readProperty(trip, "arrivalStation"))
&& depDt.isValid() && arrDt.isValid();
}
bool ExtractorPostprocessor::filterTrainStation(const QVariant &station) const
{
return !JsonLdDocument::readProperty(station, "name").toString().isEmpty();
}
......@@ -41,6 +41,8 @@ private:
bool filterReservation(const QVariant &res) const;
bool filterFlight(const QVariant &flight) const;
bool filterAirport(const QVariant &airport) const;
bool filterTrainTrip(const QVariant &trip) const;
bool filterTrainStation(const QVariant &station) const;
QVector<QVariant> m_data;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment