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

Method insertSession

app/src/Sessions/Export.cpp:274–297  ·  view source on GitHub ↗

* @brief Inserts a new session row. */

Source from the content-addressed store, hash-verified

272 * @brief Inserts a new session row.
273 */
274void Sessions::ExportWorker::insertSession(const DataModel::Frame& frame, const QDateTime& dt)
275{
276 if (!m_db) [[unlikely]]
277 return;
278
279 const auto projectJson =
280 QString::fromUtf8(QJsonDocument(buildReplayProjectJson(frame)).toJson(QJsonDocument::Compact));
281
282 QSqlQuery q(*m_db);
283 q.prepare("INSERT INTO sessions "
284 "(project_title, started_at, project_json) "
285 "VALUES (?, ?, ?)");
286 q.bindValue(0, frame.title);
287 q.bindValue(1, dt.toString(Qt::ISODate));
288 q.bindValue(2, projectJson);
289
290 if (!q.exec()) {
291 qWarning() << "[SQLite] Insert session failed:" << q.lastError().text();
292 return;
293 }
294
295 m_sessionId = q.lastInsertId().toInt();
296 Q_EMIT sessionIdAssigned(m_sessionId);
297}
298
299/**
300 * @brief Writes column definitions for the new session from the export schema.

Callers

nothing calls this directly

Calls 4

execMethod · 0.80
toJsonMethod · 0.45
textMethod · 0.45
lastErrorMethod · 0.45

Tested by

no test coverage detected