Commit 2a8bd6e0 authored by Volker Krause's avatar Volker Krause
Browse files

Better auto transfer anchor time deltas

The previous ones were a bit too optimisitc in some cases.
parent d6963e11
Pipeline #166386 skipped
......@@ -40,7 +40,7 @@
"@value": "2000-01-01T13:00:00+01:00",
"timezone": "Europe/Berlin"
},
"anchorTimeDelta": 3600,
"anchorTimeDelta": 5400,
"floatingLocationType": "FavoriteLocation",
"from": {
"@type": "Location",
......
......@@ -152,7 +152,7 @@
"@value": "1996-10-16T17:50:00+02:00",
"timezone": "Europe/Berlin"
},
"anchorTimeDelta": 3600,
"anchorTimeDelta": 5400,
"floatingLocationType": "FavoriteLocation",
"from": {
"@type": "Location",
......@@ -390,7 +390,7 @@
"@value": "1996-10-17T17:35:00+03:00",
"timezone": "Europe/Helsinki"
},
"anchorTimeDelta": 3600,
"anchorTimeDelta": 5400,
"floatingLocationType": "Reservation",
"from": {
"@type": "Location",
......
......@@ -76,7 +76,7 @@ private Q_SLOTS:
auto transfer = mgr.transfer(batchId, Transfer::Before);
QCOMPARE(transfer.state(), Transfer::Pending);
QCOMPARE(transfer.anchorTime(), QDateTime({2017, 9, 10}, {6, 15}, QTimeZone("Europe/Berlin")));
QCOMPARE(transfer.anchorTimeDelta(), 3600);
QCOMPARE(transfer.anchorTimeDelta(), 5400);
QCOMPARE(transfer.alignment(), Transfer::Before);
QCOMPARE(transfer.reservationId(), batchId);
QVERIFY(transfer.from().hasCoordinate());
......
......@@ -417,17 +417,32 @@ bool TransferManager::isNotInTripGroup(const QString &resId) const
return m_tgMgr->tripGroupIdForReservation(resId).isEmpty();
}
// default transfer anchor deltas (in minutes)
enum { FlightDelta, TrainDelta, BusDelta, FallbackDelta };
static constexpr const int default_deltas[][2] = {
{ 90, 30 }, // Flight
{ 20, 10 }, // Train
{ 15, 10 }, // Bus
{ 30, 15 }, // anything else
};
void TransferManager::determineAnchorDeltaDefault(Transfer &transfer, const QVariant &res) const
{
if (transfer.state() != Transfer::UndefinedState) {
return;
}
int delta;
if (JsonLd::isA<FlightReservation>(res)) {
transfer.setAnchorTimeDelta(transfer.alignment() == Transfer::Before ? 60 * 60 : 30 * 60);
delta = default_deltas[FlightDelta][transfer.alignment()];
} else if (JsonLd::isA<TrainReservation>(res)) {
delta = default_deltas[TrainDelta][transfer.alignment()];
} else if (JsonLd::isA<BusReservation>(res)) {
delta = default_deltas[BusDelta][transfer.alignment()];
} else {
transfer.setAnchorTimeDelta(10 * 60);
delta = default_deltas[FallbackDelta][transfer.alignment()];
}
transfer.setAnchorTimeDelta(delta * 60);
}
QDateTime TransferManager::anchorTimeBefore(const QString &resId, const QVariant &res) const
......
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