diff options
Diffstat (limited to 'tests/hawd')
-rw-r--r-- | tests/hawd/dataset.cpp | 15 | ||||
-rw-r--r-- | tests/hawd/dataset.h | 4 | ||||
-rw-r--r-- | tests/hawd/modules/json.cpp | 1 |
3 files changed, 19 insertions, 1 deletions
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp index 62fa0d7..3325850 100644 --- a/tests/hawd/dataset.cpp +++ b/tests/hawd/dataset.cpp | |||
@@ -31,6 +31,7 @@ namespace HAWD | |||
31 | 31 | ||
32 | static const QString s_annotationKey("__annotation__"); | 32 | static const QString s_annotationKey("__annotation__"); |
33 | static const QString s_hashKey("__commithash__"); | 33 | static const QString s_hashKey("__commithash__"); |
34 | static const QString s_timestampKey("__timestamp"); | ||
34 | static const int s_fieldWidth(20); | 35 | static const int s_fieldWidth(20); |
35 | 36 | ||
36 | Dataset::Row::Row(const Row &other) | 37 | Dataset::Row::Row(const Row &other) |
@@ -118,6 +119,8 @@ void Dataset::Row::fromBinary(QByteArray data) | |||
118 | m_annotation = value.toString(); | 119 | m_annotation = value.toString(); |
119 | } else if (key == s_hashKey) { | 120 | } else if (key == s_hashKey) { |
120 | m_commitHash = value.toString(); | 121 | m_commitHash = value.toString(); |
122 | } else if (key == s_timestampKey) { | ||
123 | m_timeStamp = value.toDateTime(); | ||
121 | } else { | 124 | } else { |
122 | setValue(key, value); | 125 | setValue(key, value); |
123 | } | 126 | } |
@@ -141,6 +144,10 @@ QByteArray Dataset::Row::toBinary() const | |||
141 | stream << s_hashKey << QVariant(m_commitHash); | 144 | stream << s_hashKey << QVariant(m_commitHash); |
142 | } | 145 | } |
143 | 146 | ||
147 | if (!m_timeStamp.isValid()) { | ||
148 | stream << s_timestampKey << QVariant(m_timeStamp); | ||
149 | } | ||
150 | |||
144 | if (!m_annotation.isEmpty()) { | 151 | if (!m_annotation.isEmpty()) { |
145 | stream << s_annotationKey << QVariant(m_annotation); | 152 | stream << s_annotationKey << QVariant(m_annotation); |
146 | } | 153 | } |
@@ -189,11 +196,19 @@ QString Dataset::Row::commitHash() const | |||
189 | 196 | ||
190 | QDateTime Dataset::Row::timestamp() const | 197 | QDateTime Dataset::Row::timestamp() const |
191 | { | 198 | { |
199 | if (m_timeStamp.isValid()) { | ||
200 | return m_timeStamp; | ||
201 | } | ||
192 | QDateTime dt; | 202 | QDateTime dt; |
193 | dt.setMSecsSinceEpoch(m_key); | 203 | dt.setMSecsSinceEpoch(m_key); |
194 | return dt; | 204 | return dt; |
195 | } | 205 | } |
196 | 206 | ||
207 | void Dataset::Row::setTimestamp(const QDateTime &dt) | ||
208 | { | ||
209 | m_timeStamp = dt; | ||
210 | } | ||
211 | |||
197 | QString Dataset::Row::toString(const QStringList &cols, int standardCols, const QString &seperator) const | 212 | QString Dataset::Row::toString(const QStringList &cols, int standardCols, const QString &seperator) const |
198 | { | 213 | { |
199 | if (m_data.isEmpty()) { | 214 | if (m_data.isEmpty()) { |
diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h index 9660709..f24cacf 100644 --- a/tests/hawd/dataset.h +++ b/tests/hawd/dataset.h | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include <QHash> | 29 | #include <QHash> |
30 | #include <QVariant> | 30 | #include <QVariant> |
31 | #include <QDateTime> | ||
31 | 32 | ||
32 | namespace HAWD | 33 | namespace HAWD |
33 | { | 34 | { |
@@ -52,6 +53,7 @@ public: | |||
52 | QDateTime timestamp() const; | 53 | QDateTime timestamp() const; |
53 | void annotate(const QString ¬e); | 54 | void annotate(const QString ¬e); |
54 | void setCommitHash(const QString &hash); | 55 | void setCommitHash(const QString &hash); |
56 | void setTimestamp(const QDateTime &dt); | ||
55 | qint64 key() const; | 57 | qint64 key() const; |
56 | QByteArray toBinary() const; | 58 | QByteArray toBinary() const; |
57 | QString toString(const QStringList &cols = QStringList(), int standardCols = All, const QString &seperator = "|") const; | 59 | QString toString(const QStringList &cols = QStringList(), int standardCols = All, const QString &seperator = "|") const; |
@@ -66,6 +68,7 @@ public: | |||
66 | QHash<QString, QVariant> m_data; | 68 | QHash<QString, QVariant> m_data; |
67 | QString m_annotation; | 69 | QString m_annotation; |
68 | QString m_commitHash; | 70 | QString m_commitHash; |
71 | QDateTime m_timeStamp; | ||
69 | const Dataset *m_dataset; | 72 | const Dataset *m_dataset; |
70 | friend class Dataset; | 73 | friend class Dataset; |
71 | }; | 74 | }; |
@@ -82,7 +85,6 @@ public: | |||
82 | void eachRow(const std::function<void(const Row &row)> &resultHandler); | 85 | void eachRow(const std::function<void(const Row &row)> &resultHandler); |
83 | Row row(qint64 key = 0); | 86 | Row row(qint64 key = 0); |
84 | Row lastRow(); | 87 | Row lastRow(); |
85 | //TODO: row cursor | ||
86 | 88 | ||
87 | private: | 89 | private: |
88 | DatasetDefinition m_definition; | 90 | DatasetDefinition m_definition; |
diff --git a/tests/hawd/modules/json.cpp b/tests/hawd/modules/json.cpp index d299761..092c977 100644 --- a/tests/hawd/modules/json.cpp +++ b/tests/hawd/modules/json.cpp | |||
@@ -63,6 +63,7 @@ bool Json::toJson(const QStringList &commands, State &state) | |||
63 | 63 | ||
64 | QJsonObject json; | 64 | QJsonObject json; |
65 | json.insert("dataset", datasetName); | 65 | json.insert("dataset", datasetName); |
66 | json.insert("name", definition.name()); | ||
66 | json.insert("description", definition.description()); | 67 | json.insert("description", definition.description()); |
67 | 68 | ||
68 | const auto columns = definition.columns(); | 69 | const auto columns = definition.columns(); |