diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-20 18:39:52 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-20 18:39:52 +0200 |
commit | b89fc2271b05fc2834c89a1549a6dc3e8fbe9255 (patch) | |
tree | e74e94a4d221797bb6e7bae8ba7954f07fadf08d /common/typeindex.cpp | |
parent | ed78ccd0f6cfc8f1e821c997fa9547bc90dde510 (diff) | |
download | sink-b89fc2271b05fc2834c89a1549a6dc3e8fbe9255.tar.gz sink-b89fc2271b05fc2834c89a1549a6dc3e8fbe9255.zip |
Fixed cleanup of date indexes
Diffstat (limited to 'common/typeindex.cpp')
-rw-r--r-- | common/typeindex.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 1a50bfe..05bbf5c 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -27,6 +27,9 @@ | |||
27 | 27 | ||
28 | static QByteArray getByteArray(const QVariant &value) | 28 | static QByteArray getByteArray(const QVariant &value) |
29 | { | 29 | { |
30 | if (value.type() == QVariant::DateTime) { | ||
31 | return value.toDateTime().toString().toLatin1(); | ||
32 | } | ||
30 | if (value.isValid() && !value.toByteArray().isEmpty()) { | 33 | if (value.isValid() && !value.toByteArray().isEmpty()) { |
31 | return value.toByteArray(); | 34 | return value.toByteArray(); |
32 | } | 35 | } |
@@ -82,11 +85,8 @@ template <> | |||
82 | void TypeIndex::addProperty<QDateTime>(const QByteArray &property) | 85 | void TypeIndex::addProperty<QDateTime>(const QByteArray &property) |
83 | { | 86 | { |
84 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { | 87 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
85 | const auto date = value.toDateTime(); | ||
86 | // Trace() << "Indexing " << mType + ".index." + property << date.toString(); | 88 | // Trace() << "Indexing " << mType + ".index." + property << date.toString(); |
87 | if (date.isValid()) { | 89 | Index(indexName(property), transaction).add(getByteArray(value), identifier); |
88 | Index(indexName(property), transaction).add(date.toString().toLatin1(), identifier); | ||
89 | } | ||
90 | }; | 90 | }; |
91 | mIndexer.insert(property, indexer); | 91 | mIndexer.insert(property, indexer); |
92 | mProperties << property; | 92 | mProperties << property; |
@@ -123,11 +123,7 @@ void TypeIndex::remove(const QByteArray &identifier, const Sink::ApplicationDoma | |||
123 | { | 123 | { |
124 | for (const auto &property : mProperties) { | 124 | for (const auto &property : mProperties) { |
125 | const auto value = bufferAdaptor.getProperty(property); | 125 | const auto value = bufferAdaptor.getProperty(property); |
126 | // FIXME don't always convert to byte array | 126 | Index(indexName(property), transaction).remove(getByteArray(value), identifier); |
127 | const auto data = getByteArray(value); | ||
128 | if (!data.isEmpty()) { | ||
129 | Index(indexName(property), transaction).remove(data, identifier); | ||
130 | } | ||
131 | } | 127 | } |
132 | for (auto it = mSortedProperties.constBegin(); it != mSortedProperties.constEnd(); it++) { | 128 | for (auto it = mSortedProperties.constBegin(); it != mSortedProperties.constEnd(); it++) { |
133 | const auto propertyValue = bufferAdaptor.getProperty(it.key()); | 129 | const auto propertyValue = bufferAdaptor.getProperty(it.key()); |