* @brief Return the most recent N checkpoints for the current project. */
| 954 | * @brief Return the most recent N checkpoints for the current project. |
| 955 | */ |
| 956 | API::CommandResponse API::Handlers::AssistantHandler::listCheckpoints(const QString& id, |
| 957 | const QJsonObject& params) |
| 958 | { |
| 959 | const int limit = params.value(QStringLiteral("limit")).toInt(20); |
| 960 | const auto rows = Misc::BackupManager::instance().list(limit); |
| 961 | |
| 962 | QJsonArray arr; |
| 963 | for (const auto& v : rows) { |
| 964 | const auto row = v.toMap(); |
| 965 | QJsonObject entry; |
| 966 | entry[QStringLiteral("path")] = row.value(QStringLiteral("path")).toString(); |
| 967 | entry[QStringLiteral("timestamp")] = row.value(QStringLiteral("timestamp")).toString(); |
| 968 | entry[QStringLiteral("sizeBytes")] = |
| 969 | static_cast<qint64>(row.value(QStringLiteral("sizeBytes")).toLongLong()); |
| 970 | entry[QStringLiteral("label")] = row.value(QStringLiteral("label")).toString(); |
| 971 | arr.append(entry); |
| 972 | } |
| 973 | |
| 974 | QJsonObject result; |
| 975 | result[QStringLiteral("checkpoints")] = arr; |
| 976 | result[QStringLiteral("count")] = arr.size(); |
| 977 | result[QStringLiteral("directory")] = Misc::BackupManager::instance().backupDirectory(); |
| 978 | return CommandResponse::makeSuccess(id, result); |
| 979 | } |
| 980 | |
| 981 | //-------------------------------------------------------------------------------------------------- |
| 982 | // Registration |
nothing calls this directly
no test coverage detected