summaryrefslogtreecommitdiffstats
path: root/common/typeindex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/typeindex.cpp')
-rw-r--r--common/typeindex.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/common/typeindex.cpp b/common/typeindex.cpp
index 1dd54e8..47512e8 100644
--- a/common/typeindex.cpp
+++ b/common/typeindex.cpp
@@ -70,14 +70,12 @@ static QByteArray toSortableByteArray(const QVariant &value)
70 return QByteArray::number(std::numeric_limits<unsigned int>::max()); 70 return QByteArray::number(std::numeric_limits<unsigned int>::max());
71 } 71 }
72 72
73 switch (value.type()) { 73 if (value.canConvert<QDateTime>()) {
74 case QMetaType::QDateTime: 74 return toSortableByteArrayImpl(value.toDateTime());
75 return toSortableByteArrayImpl(value.toDateTime());
76 default:
77 SinkWarning() << "Not knowing how to convert a" << value.typeName()
78 << "to a sortable key, falling back to default conversion";
79 return getByteArray(value);
80 } 75 }
76 SinkWarning() << "Not knowing how to convert a" << value.typeName()
77 << "to a sortable key, falling back to default conversion";
78 return getByteArray(value);
81} 79}
82 80
83TypeIndex::TypeIndex(const QByteArray &type, const Sink::Log::Context &ctx) : mLogCtx(ctx), mType(type) 81TypeIndex::TypeIndex(const QByteArray &type, const Sink::Log::Context &ctx) : mLogCtx(ctx), mType(type)
@@ -104,13 +102,11 @@ QByteArray TypeIndex::sampledPeriodIndexName(const QByteArray &rangeBeginPropert
104 102
105static unsigned int bucketOf(const QVariant &value) 103static unsigned int bucketOf(const QVariant &value)
106{ 104{
107 switch (value.type()) { 105 if (value.canConvert<QDateTime>()) {
108 case QMetaType::QDateTime: 106 return value.value<QDateTime>().date().toJulianDay() / 7;
109 return value.value<QDateTime>().date().toJulianDay() / 7;
110 default:
111 SinkError() << "Not knowing how to get the bucket of a" << value.typeName();
112 return {};
113 } 107 }
108 SinkError() << "Not knowing how to get the bucket of a" << value.typeName();
109 return {};
114} 110}
115 111
116static void update(TypeIndex::Action action, const QByteArray &indexName, const QByteArray &key, const QByteArray &value, Sink::Storage::DataStore::Transaction &transaction) 112static void update(TypeIndex::Action action, const QByteArray &indexName, const QByteArray &key, const QByteArray &value, Sink::Storage::DataStore::Transaction &transaction)