* @brief Loads the first or last numeric value per dataset; ties broken by reading_id. */
| 180 | * @brief Loads the first or last numeric value per dataset; ties broken by reading_id. |
| 181 | */ |
| 182 | static void loadEdgeValues(QSqlDatabase& db, |
| 183 | int sessionId, |
| 184 | std::vector<Sessions::DatasetStats>& datasets, |
| 185 | bool first) |
| 186 | { |
| 187 | const QString aggregator = first ? QStringLiteral("MIN") : QStringLiteral("MAX"); |
| 188 | QSqlQuery q(db); |
| 189 | q.prepare(QStringLiteral("SELECT unique_id, final_numeric_value FROM readings " |
| 190 | "WHERE reading_id IN (" |
| 191 | " SELECT %1(reading_id) FROM readings " |
| 192 | " WHERE session_id = ? AND is_numeric = 1 " |
| 193 | " GROUP BY unique_id)") |
| 194 | .arg(aggregator)); |
| 195 | q.bindValue(0, sessionId); |
| 196 | if (!q.exec()) |
| 197 | return; |
| 198 | |
| 199 | while (q.next()) { |
| 200 | const int uid = q.value(0).toInt(); |
| 201 | auto it = findDatasetByUid(datasets, uid); |
| 202 | if (it == datasets.end()) |
| 203 | continue; |
| 204 | |
| 205 | if (first) |
| 206 | it->firstValue = SerialStudio::toDouble(q.value(1)); |
| 207 | else |
| 208 | it->lastValue = SerialStudio::toDouble(q.value(1)); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * @brief Appends the alphabetically-sorted tag labels for a session into out.tags. |
no test coverage detected