* @brief Reads the dataset column metadata into a default-initialized DatasetStats vector. */
| 74 | * @brief Reads the dataset column metadata into a default-initialized DatasetStats vector. |
| 75 | */ |
| 76 | static bool loadDatasetSkeleton(QSqlDatabase& db, |
| 77 | int sessionId, |
| 78 | std::vector<Sessions::DatasetStats>& datasets, |
| 79 | const QSet<int>& selectedUniqueIds) |
| 80 | { |
| 81 | QSqlQuery colQ(db); |
| 82 | colQ.prepare("SELECT unique_id, group_title, title, units, source_title " |
| 83 | "FROM columns WHERE session_id = ? ORDER BY column_id ASC"); |
| 84 | colQ.bindValue(0, sessionId); |
| 85 | if (!colQ.exec()) |
| 86 | return false; |
| 87 | |
| 88 | while (colQ.next()) { |
| 89 | const int uid = colQ.value(0).toInt(); |
| 90 | if (!selectedUniqueIds.isEmpty() && !selectedUniqueIds.contains(uid)) |
| 91 | continue; |
| 92 | |
| 93 | Sessions::DatasetStats ds; |
| 94 | ds.uniqueId = uid; |
| 95 | ds.group = colQ.value(1).toString(); |
| 96 | ds.title = colQ.value(2).toString(); |
| 97 | ds.units = colQ.value(3).toString(); |
| 98 | ds.sourceTitle = colQ.value(4).toString(); |
| 99 | ds.numericSamples = 0; |
| 100 | ds.stringSamples = 0; |
| 101 | ds.minValue = 0.0; |
| 102 | ds.maxValue = 0.0; |
| 103 | ds.mean = 0.0; |
| 104 | ds.stddev = 0.0; |
| 105 | ds.firstValue = 0.0; |
| 106 | ds.lastValue = 0.0; |
| 107 | datasets.push_back(std::move(ds)); |
| 108 | } |
| 109 | |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @brief Locates the DatasetStats row matching a unique id, or end() if absent. |