pmaports/kde/itinerary/0001-Revert-Consider-Reservation-reservationStatus.patch

360 lines
14 KiB
Diff
Raw Normal View History

From 6039e31d753fa6dd88572ce5aa28a71a0199ab0b Mon Sep 17 00:00:00 2001
From: Luca Weiss <luca@z3ntu.xyz>
Date: Fri, 27 Mar 2020 18:01:53 +0100
Subject: [PATCH] Revert "Consider Reservation::reservationStatus"
This reverts commit 85adf9354c1497d5b49b72e25123792138de5689.
---
.../data/timeline/flight-cancelation.json | 35 --------
.../data/timeline/flight-cancelation.model | 86 -------------------
autotests/statisticstest.cpp | 1 -
autotests/timelinedelegatecontrollertest.cpp | 17 ----
src/app/TimelineDelegate.qml | 8 +-
src/app/statisticsmodel.cpp | 5 --
src/app/timelinedelegatecontroller.cpp | 13 ---
src/app/timelinedelegatecontroller.h | 4 -
src/app/timelinemodel.cpp | 24 ++----
9 files changed, 7 insertions(+), 186 deletions(-)
delete mode 100644 autotests/data/timeline/flight-cancelation.json
delete mode 100644 autotests/data/timeline/flight-cancelation.model
diff --git a/autotests/data/timeline/flight-cancelation.json b/autotests/data/timeline/flight-cancelation.json
deleted file mode 100644
index db8017b..0000000
--- a/autotests/data/timeline/flight-cancelation.json
+++ /dev/null
@@ -1,35 +0,0 @@
-[{
- "internal-comment": "sample from https://developers.google.com/gmail/markup/reference/flight-reservation#cancel_a_flight",
- "@context": "http://schema.org",
- "@type": "FlightReservation",
- "reservationNumber": "RXJ34P",
- "reservationStatus": "http://schema.org/Cancelled",
- "underName": {
- "@type": "Person",
- "name": "Eva Green"
- },
- "reservationFor": {
- "@type": "Flight",
- "flightNumber": "110",
- "airline": {
- "@type": "Airline",
- "name": "United",
- "iataCode": "UA"
- },
- "departureAirport": {
- "@type": "Airport",
- "name": "San Francisco Airport",
- "iataCode": "SFO"
- },
- "departureTime": "1996-10-16T20:15:00-07:00",
- "arrivalAirport": {
- "@type": "Airport",
- "name": "John F. Kennedy International Airport",
- "iataCode": "JFK"
- },
- "arrivalTime": "1996-10-16T06:30:00-04:00"
- },
- "checkinUrl": "http://united.com/onlinecheckin.html",
- "modifiedTime": "1996-05-01T08:30:00-08:00",
- "modifyReservationUrl": "http://united.com/modifyreservation.html"
-}]
diff --git a/autotests/data/timeline/flight-cancelation.model b/autotests/data/timeline/flight-cancelation.model
deleted file mode 100644
index 59f8462..0000000
--- a/autotests/data/timeline/flight-cancelation.model
+++ /dev/null
@@ -1,86 +0,0 @@
-[
- {
- "isToday": true,
- "isTodayEmpty": true,
- "rangeType": 0,
- "sectionHeader": "Today",
- "type": 1
- },
- {
- "isToday": false,
- "rangeType": 0,
- "reservations": [
- {
- "@context": "http://schema.org",
- "@type": "FlightReservation",
- "modifiedTime": "1996-05-01T08:30:00-08:00",
- "potentialAction": [
- {
- "@type": "CheckInAction",
- "target": "http://united.com/onlinecheckin.html"
- },
- {
- "@type": "UpdateAction",
- "target": "http://united.com/modifyreservation.html"
- }
- ],
- "reservationFor": {
- "@type": "Flight",
- "airline": {
- "@type": "Airline",
- "iataCode": "UA",
- "name": "United"
- },
- "arrivalAirport": {
- "@type": "Airport",
- "address": {
- "@type": "PostalAddress",
- "addressCountry": "US"
- },
- "geo": {
- "@type": "GeoCoordinates",
- "latitude": 40.63970184326172,
- "longitude": -73.77890014648438
- },
- "iataCode": "JFK",
- "name": "John F. Kennedy International Airport"
- },
- "arrivalTime": {
- "@type": "QDateTime",
- "@value": "1996-10-17T06:30:00-04:00",
- "timezone": "America/New_York"
- },
- "departureAirport": {
- "@type": "Airport",
- "address": {
- "@type": "PostalAddress",
- "addressCountry": "US"
- },
- "geo": {
- "@type": "GeoCoordinates",
- "latitude": 37.618900299072266,
- "longitude": -122.375
- },
- "iataCode": "SFO",
- "name": "San Francisco Airport"
- },
- "departureDay": "1996-10-16",
- "departureTime": {
- "@type": "QDateTime",
- "@value": "1996-10-16T20:15:00-07:00",
- "timezone": "America/Los_Angeles"
- },
- "flightNumber": "110"
- },
- "reservationNumber": "RXJ34P",
- "reservationStatus": "http://schema.org/ReservationCancelled",
- "underName": {
- "@type": "Person",
- "name": "Eva Green"
- }
- }
- ],
- "sectionHeader": "Wednesday, 10/16/96",
- "type": 6
- }
-]
diff --git a/autotests/statisticstest.cpp b/autotests/statisticstest.cpp
index 87dc586..159ed7f 100644
--- a/autotests/statisticstest.cpp
+++ b/autotests/statisticstest.cpp
@@ -72,7 +72,6 @@ private Q_SLOTS:
resMgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
resMgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/../tests/akademy2017.json")));
resMgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/../tests/akademy2018-program.json")));
- resMgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/data/flight-cancelation.json"))); // canceled flight, should not change stats
stats.setTimeRange({}, {});
QVERIFY(!changeSpy.isEmpty());
diff --git a/autotests/timelinedelegatecontrollertest.cpp b/autotests/timelinedelegatecontrollertest.cpp
index 3716a3d..7c91378 100644
--- a/autotests/timelinedelegatecontrollertest.cpp
+++ b/autotests/timelinedelegatecontrollertest.cpp
@@ -69,7 +69,6 @@ private Q_SLOTS:
QCOMPARE(controller.isLocationChange(), false);
QCOMPARE(controller.isPublicTransport(), false);
QVERIFY(!controller.journeyRequest().isValid());
- QCOMPARE(controller.isCanceled(), false);
controller.setBatchId(QStringLiteral("foo"));
QCOMPARE(controller.isCurrent(), false);
@@ -77,7 +76,6 @@ private Q_SLOTS:
QCOMPARE(controller.effectiveEndTime(), QDateTime());
QCOMPARE(controller.isLocationChange(), false);
QCOMPARE(controller.isPublicTransport(), false);
- QCOMPARE(controller.isCanceled(), false);
ReservationManager mgr;
controller.setReservationManager(&mgr);
@@ -86,7 +84,6 @@ private Q_SLOTS:
QCOMPARE(controller.effectiveEndTime(), QDateTime());
QCOMPARE(controller.isLocationChange(), false);
QCOMPARE(controller.isPublicTransport(), false);
- QCOMPARE(controller.isCanceled(), false);
}
void testProgress()
@@ -114,7 +111,6 @@ private Q_SLOTS:
QCOMPARE(controller.progress(), 0.0f);
QCOMPARE(controller.isLocationChange(), true);
QCOMPARE(controller.isPublicTransport(), true);
- QCOMPARE(controller.isCanceled(), false);
trip.setArrivalTime(QDateTime::currentDateTime().addDays(1));
res.setReservationFor(trip);
@@ -232,19 +228,6 @@ private Q_SLOTS:
QCOMPARE(updateSpy.size(), 0);
QCOMPARE(rmSpy.size(), 3);
}
-
- void testCancel()
- {
- ReservationManager mgr;
- clearReservations(&mgr);
- mgr.importReservation(readFile(QLatin1String(SOURCE_DIR "/data/timeline/flight-cancelation.json")));
-
- TimelineDelegateController controller;
- controller.setReservationManager(&mgr);
- controller.setBatchId(mgr.batches().at(0));
- QCOMPARE(controller.isCanceled(), true);
- QCOMPARE(controller.connectionWarning(), false);
- }
};
QTEST_GUILESS_MAIN(TimelineDelegateControllerTest)
diff --git a/src/app/TimelineDelegate.qml b/src/app/TimelineDelegate.qml
index 9d782be..d138822 100644
--- a/src/app/TimelineDelegate.qml
+++ b/src/app/TimelineDelegate.qml
@@ -55,13 +55,7 @@ Kirigami.AbstractCard {
id: headerBackground
Kirigami.Theme.colorSet: controller.isCurrent ? Kirigami.Theme.Selection : Kirigami.Theme.Complementary
Kirigami.Theme.inherit: false
- color: {
- if (controller.connectionWarning)
- return Kirigami.Theme.negativeTextColor;
- if (controller.isCanceled)
- return Kirigami.Theme.disabledTextColor;
- return Kirigami.Theme.backgroundColor;
- }
+ color: controller.connectionWarning ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.backgroundColor
implicitHeight: headerLayout.implicitHeight + Kirigami.Units.largeSpacing * 2
anchors.leftMargin: -root.leftPadding
anchors.topMargin: -root.topPadding
diff --git a/src/app/statisticsmodel.cpp b/src/app/statisticsmodel.cpp
index 00baa55..70adfd4 100644
--- a/src/app/statisticsmodel.cpp
+++ b/src/app/statisticsmodel.cpp
@@ -283,11 +283,6 @@ void StatisticsModel::recompute()
isPrev = dt.date() < m_begin;
}
- // don't count canceled reservations
- if (JsonLd::canConvert<Reservation>(res) && JsonLd::convert<Reservation>(res).reservationStatus() == Reservation::ReservationCancelled) {
- continue;
- }
-
if (LocationUtil::isLocationChange(res)) {
computeStats(res, isPrev ? m_prevStatData : m_statData);
} else if (JsonLd::isA<LodgingReservation>(res)) {
diff --git a/src/app/timelinedelegatecontroller.cpp b/src/app/timelinedelegatecontroller.cpp
index 6d1fe31..01f6fc4 100644
--- a/src/app/timelinedelegatecontroller.cpp
+++ b/src/app/timelinedelegatecontroller.cpp
@@ -504,17 +504,4 @@ bool TimelineDelegateController::connectionWarning() const
return curDepDt < prevArrDt;
}
-bool TimelineDelegateController::isCanceled() const
-{
- if (!m_resMgr || m_batchId.isEmpty()) {
- return false;
- }
-
- const auto res = m_resMgr->reservation(m_batchId);
- if (!JsonLd::canConvert<Reservation>(res)) {
- return false;
- }
- return JsonLd::convert<Reservation>(res).reservationStatus() == Reservation::ReservationCancelled;
-}
-
#include "moc_timelinedelegatecontroller.cpp"
diff --git a/src/app/timelinedelegatecontroller.h b/src/app/timelinedelegatecontroller.h
index 85ace1b..976cdde 100644
--- a/src/app/timelinedelegatecontroller.h
+++ b/src/app/timelinedelegatecontroller.h
@@ -71,9 +71,6 @@ class TimelineDelegateController : public QObject
/** Inbound connection is unlikely to work. */
Q_PROPERTY(bool connectionWarning READ connectionWarning NOTIFY connectionWarningChanged)
- /** Reservation has been canceled (by user or provider, we usually don't know which). */
- Q_PROPERTY(bool isCanceled READ isCanceled NOTIFY contentChanged)
-
public:
TimelineDelegateController(QObject *parent = nullptr);
~TimelineDelegateController();
@@ -103,7 +100,6 @@ public:
Q_INVOKABLE void applyJourney(const QVariant &journey);
bool connectionWarning() const;
- bool isCanceled() const;
Q_SIGNALS:
void setupChanged();
diff --git a/src/app/timelinemodel.cpp b/src/app/timelinemodel.cpp
index 5a88ffb..30b6974 100644
--- a/src/app/timelinemodel.cpp
+++ b/src/app/timelinemodel.cpp
@@ -78,10 +78,6 @@ static GeoCoordinates geoCoordinate(const QVariant &res)
return LocationUtil::geo(LocationUtil::location(res));
}
-static bool isCanceled(const QVariant &res)
-{
- return JsonLd::canConvert<Reservation>(res) && JsonLd::convert<Reservation>(res).reservationStatus() == Reservation::ReservationCancelled;
-}
TimelineModel::TimelineModel(QObject *parent)
: QAbstractListModel(parent)
@@ -474,10 +470,6 @@ void TimelineModel::updateInformationElements()
continue;
}
const auto res = m_resMgr->reservation((*it).batchId());
- if (isCanceled(res)) {
- ++it;
- continue;
- }
auto newCountry = homeCountry;
newCountry.setIsoCode(LocationHelper::destinationCountry(res));
@@ -525,11 +517,9 @@ void TimelineModel::updateWeatherElements()
continue;
}
const auto res = m_resMgr->reservation((*it).batchId());
- if (!isCanceled(res)) {
- const auto newGeo = geoCoordinate(res);
- if (LocationUtil::isLocationChange(res) || newGeo.isValid()) {
- geo = newGeo;
- }
+ const auto newGeo = geoCoordinate(res);
+ if (LocationUtil::isLocationChange(res) || newGeo.isValid()) {
+ geo = newGeo;
}
++it;
@@ -558,11 +548,9 @@ void TimelineModel::updateWeatherElements()
continue;
}
const auto res = m_resMgr->reservation((*it).batchId());
- if (!isCanceled(res)) {
- const auto newGeo = geoCoordinate(res);
- if (LocationUtil::isLocationChange(res) || newGeo.isValid()) {
- geo = newGeo;
- }
+ const auto newGeo = geoCoordinate(res);
+ if (LocationUtil::isLocationChange(res) || newGeo.isValid()) {
+ geo = newGeo;
}
++it;
--
2.26.0