* @brief Summarise a serialised project JSON object for dryRun replies (no model mutation). */
| 1431 | * @brief Summarise a serialised project JSON object for dryRun replies (no model mutation). |
| 1432 | */ |
| 1433 | static QJsonObject summarizeProjectJson(const QJsonObject& project) |
| 1434 | { |
| 1435 | QJsonObject out; |
| 1436 | out[QStringLiteral("title")] = project.value(QStringLiteral("title")).toString(); |
| 1437 | |
| 1438 | const auto groups = project.value(QStringLiteral("groups")).toArray(); |
| 1439 | out[QStringLiteral("groupCount")] = groups.size(); |
| 1440 | |
| 1441 | int datasetCount = 0; |
| 1442 | QJsonArray groupTitles; |
| 1443 | for (const auto& gv : groups) { |
| 1444 | const auto g = gv.toObject(); |
| 1445 | datasetCount += g.value(QStringLiteral("datasets")).toArray().size(); |
| 1446 | if (groupTitles.size() < 32) |
| 1447 | groupTitles.append(g.value(QStringLiteral("title")).toString()); |
| 1448 | } |
| 1449 | out[QStringLiteral("datasetCount")] = datasetCount; |
| 1450 | out[QStringLiteral("groupTitles")] = groupTitles; |
| 1451 | |
| 1452 | const auto sources = project.value(QStringLiteral("sources")).toArray(); |
| 1453 | out[QStringLiteral("sourceCount")] = sources.isEmpty() ? 1 : sources.size(); |
| 1454 | return out; |
| 1455 | } |
| 1456 | |
| 1457 | /** |
| 1458 | * @brief Summarise the current ProjectModel for the `wouldDiscard` half of a dryRun reply. |
no test coverage detected