Commit f73e433d authored by Volker Krause's avatar Volker Krause
Browse files

Consider all location request parameters for computing the cache key

parent 335a2dc7
......@@ -86,14 +86,16 @@ private Q_SLOTS:
{
LocationRequest req;
req.setCoordinate(-52.5, -13.5);
QCOMPARE(req.cacheKey(), QLatin1String("-52500000x-13500000"));
QCOMPARE(req.cacheKey(), QLatin1String("73be02317c4a7a43aff31f3186b18c22c6466250"));
req.setTypes(Location::RentedVehicle|Location::RentedVehicleStation);
QCOMPARE(req.cacheKey(), QLatin1String("4dfaecadb1a7d03106fe585b119948c158509807"));
}
{
LocationRequest req;
req.setName(QStringLiteral("Randa"));
QCOMPARE(req.cacheKey(), QLatin1String("8fb4b1073d1c288ae089ce8eb7ad0c16e478e919"));
QCOMPARE(req.cacheKey(), QLatin1String("c4053bc0f4582f2977f3e43cad07b6587e6b6935"));
req.setName(QStringLiteral("RANDA"));
QCOMPARE(req.cacheKey(), QLatin1String("8fb4b1073d1c288ae089ce8eb7ad0c16e478e919"));
QCOMPARE(req.cacheKey(), QLatin1String("c4053bc0f4582f2977f3e43cad07b6587e6b6935"));
}
}
};
......
......@@ -9,6 +9,9 @@
#include "datatypes/json_p.h"
#include "datatypes/locationutil_p.h"
#include <QCryptographicHash>
#include <QDebug>
#include <QMetaEnum>
#include <QSharedData>
#include <QStringList>
......@@ -103,7 +106,13 @@ void LocationRequest::setName(const QString &name)
QString LocationRequest::cacheKey() const
{
return LocationUtil::cacheKey(d->location);
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(LocationUtil::cacheKey(d->location).toUtf8());
const auto me = QMetaEnum::fromType<Location::Types>();
hash.addData(me.valueToKeys(types()));
hash.addData(QByteArray::number(maximumDistance()));
hash.addData(QByteArray::number(maximumResults()));
return QString::fromUtf8(hash.result().toHex());
}
QJsonObject LocationRequest::toJson(const LocationRequest &req)
......
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