* @brief Numeric-sample count per parameter, keyed by @c unique_id. */
| 538 | * @brief Numeric-sample count per parameter, keyed by @c unique_id. |
| 539 | */ |
| 540 | static std::map<int, qint64> loadSampleCounts(QSqlDatabase& db, int sessionId) |
| 541 | { |
| 542 | std::map<int, qint64> counts; |
| 543 | |
| 544 | QSqlQuery q(db); |
| 545 | q.prepare("SELECT unique_id, COUNT(*) FROM readings " |
| 546 | "WHERE session_id = ? AND is_numeric = 1 GROUP BY unique_id"); |
| 547 | q.bindValue(0, sessionId); |
| 548 | |
| 549 | if (!q.exec()) { |
| 550 | qWarning() << "[Sessions::ReportData] sample-count query failed:" << q.lastError().text(); |
| 551 | return counts; |
| 552 | } |
| 553 | |
| 554 | while (q.next()) |
| 555 | counts.emplace(q.value(0).toInt(), q.value(1).toLongLong()); |
| 556 | |
| 557 | return counts; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * @brief Loads downsampled numeric time-series for every parameter. |