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

Method datasetsList

app/src/API/Handlers/ProjectHandler.cpp:3307–3348  ·  view source on GitHub ↗

* @brief List all datasets across all groups */

Source from the content-addressed store, hash-verified

3305 * @brief List all datasets across all groups
3306 */
3307API::CommandResponse API::Handlers::ProjectHandler::datasetsList(const QString& id,
3308 const QJsonObject& params)
3309{
3310 Q_UNUSED(params)
3311
3312 const auto& groups = DataModel::ProjectModel::instance().groups();
3313
3314 QJsonArray datasets_array;
3315 int total_datasets = 0;
3316
3317 for (const auto& group : groups) {
3318 for (const auto& dataset : group.datasets) {
3319 datasets_array.append(buildDatasetObject(dataset, group));
3320 ++total_datasets;
3321 }
3322 }
3323
3324 QString summary;
3325 if (total_datasets == 0) {
3326 summary = QStringLiteral("No datasets configured.");
3327 } else {
3328 summary = QStringLiteral("%1 datasets across %2 group%3.")
3329 .arg(total_datasets)
3330 .arg(groups.size())
3331 .arg(groups.size() == 1 ? QString() : QStringLiteral("s"));
3332 }
3333
3334 QJsonObject result;
3335 result[QStringLiteral("_summary")] = summary;
3336 result[QStringLiteral("datasets")] = datasets_array;
3337 result[QStringLiteral("datasetCount")] = total_datasets;
3338 if (total_datasets >= 10)
3339 result[QStringLiteral("_hint")] =
3340 QStringLiteral("Bulk edits across %1 datasets: use project.batch (rename/retitle/reindex/"
3341 "update many at once) or project.dataset.addMany (create N similar). "
3342 "Looping single project.dataset.update calls costs N round-trips and N "
3343 "autosave-debounce restarts. See meta.describeCommand{name:"
3344 "\"project.batch\"} for the {ops:[{command,params},...]} shape.")
3345 .arg(total_datasets);
3346
3347 return CommandResponse::makeSuccess(id, result);
3348}
3349
3350/**
3351 * @brief Find a dataset by its uniqueId across all groups.

Callers

nothing calls this directly

Calls 3

buildDatasetObjectFunction · 0.85
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected