* @brief Stores the current project JSON in the project_metadata table. */
| 366 | * @brief Stores the current project JSON in the project_metadata table. |
| 367 | */ |
| 368 | void Sessions::ExportWorker::storeProjectMetadata(const DataModel::Frame& frame) |
| 369 | { |
| 370 | if (!m_db) [[unlikely]] |
| 371 | return; |
| 372 | |
| 373 | const auto json = |
| 374 | QString::fromUtf8(QJsonDocument(buildReplayProjectJson(frame)).toJson(QJsonDocument::Compact)); |
| 375 | const auto now = QDateTime::currentDateTime().toString(Qt::ISODate); |
| 376 | |
| 377 | m_db->transaction(); |
| 378 | QSqlQuery q(*m_db); |
| 379 | |
| 380 | q.prepare("INSERT OR REPLACE INTO project_metadata (key, value) VALUES ('project_json', ?)"); |
| 381 | q.bindValue(0, json); |
| 382 | q.exec(); |
| 383 | |
| 384 | q.prepare("INSERT OR REPLACE INTO project_metadata (key, value) VALUES ('project_title', ?)"); |
| 385 | q.bindValue(0, frame.title); |
| 386 | q.exec(); |
| 387 | |
| 388 | q.prepare("INSERT OR REPLACE INTO project_metadata (key, value) VALUES ('last_modified_at', ?)"); |
| 389 | q.bindValue(0, now); |
| 390 | q.exec(); |
| 391 | |
| 392 | q.prepare("INSERT INTO project_metadata (key, value) VALUES ('created_at', ?) " |
| 393 | "ON CONFLICT(key) DO NOTHING"); |
| 394 | q.bindValue(0, now); |
| 395 | q.exec(); |
| 396 | |
| 397 | m_db->commit(); |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * @brief Produces the project JSON stored with the session. |