MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / loadEdgeValues

Function loadEdgeValues

app/src/Sessions/ReportData.cpp:182–210  ·  view source on GitHub ↗

* @brief Loads the first or last numeric value per dataset; ties broken by reading_id. */

Source from the content-addressed store, hash-verified

180 * @brief Loads the first or last numeric value per dataset; ties broken by reading_id.
181 */
182static 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.

Callers 1

buildFromSessionMethod · 0.85

Calls 4

findDatasetByUidFunction · 0.85
execMethod · 0.80
nextMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected