+13
-22
@@ -25,7 +25,7 @@
|
||||
namespace {
|
||||
|
||||
constexpr auto application_id = std::int64_t{0x56414D50};
|
||||
constexpr auto catalogue_schema_version = std::int64_t{1};
|
||||
constexpr auto catalogue_schema_version = std::int64_t{2};
|
||||
|
||||
auto connection_config(vamp_zero::database_config const &config) -> noto::connection_config {
|
||||
auto result = noto::file_connection_config(config.path, "product-vamp");
|
||||
@@ -183,9 +183,8 @@ auto vamp_zero::async_load_practice_library(boost::asio::any_io_executor executo
|
||||
if (!connected) {
|
||||
co_return std::unexpected(connected.error());
|
||||
}
|
||||
auto selected = co_await connection.async_prepare("SELECT id, practice_type_id, practice_type_title, lesson_group_id, lesson_group_title, title, composer, "
|
||||
"key_signature, source_path, measure_count, total_pages, authored_key_signature, exercise_id FROM practice_exercises ORDER BY practice_type_id COLLATE NOCASE, "
|
||||
"lesson_group_id COLLATE NOCASE, source_path COLLATE NOCASE, title COLLATE NOCASE, id COLLATE NOCASE");
|
||||
auto selected = co_await connection.async_prepare("SELECT id, title, composer, key_signature, source_path, measure_count, total_pages, authored_key_signature, exercise_id "
|
||||
"FROM practice_exercises ORDER BY exercise_id, id");
|
||||
if (!selected) {
|
||||
auto close = co_await connection.async_close();
|
||||
if (!close) {
|
||||
@@ -205,35 +204,27 @@ auto vamp_zero::async_load_practice_library(boost::asio::any_io_executor executo
|
||||
break;
|
||||
}
|
||||
auto const &row = **next;
|
||||
if (row.size() != 13U || count_value(row[9]) == 0U || count_value(row[10]) == 0U || text_value(row[12]).empty()) {
|
||||
if (row.size() != 9U || count_value(row[5]) == 0U || count_value(row[6]) == 0U || text_value(row[8]).empty() || text_value(row[3]).empty()) {
|
||||
status = std::unexpected(vamp_zero::make_error(vamp_zero::error_code::PERSISTENCE, "invalid practice metadata"));
|
||||
break;
|
||||
}
|
||||
auto type_id = text_value(row[1]);
|
||||
auto lesson_id = text_value(row[3]);
|
||||
auto source = resolve_source_path(assets_path, text_value(row[8]));
|
||||
auto source = resolve_source_path(assets_path, text_value(row[4]));
|
||||
if (!source) {
|
||||
status = std::unexpected(source.error());
|
||||
break;
|
||||
}
|
||||
auto source_path = std::move(*source);
|
||||
auto key_signature = text_value(row[7]).empty() ? std::string{"C"} : text_value(row[7]);
|
||||
auto variant = vamp_zero::practice_exercise::score_variant{
|
||||
.id = text_value(row[0]),
|
||||
.key_signature = key_signature,
|
||||
.source_path = source_path,
|
||||
.measure_count = count_value(row[9]),
|
||||
.total_pages = count_value(row[10]),
|
||||
.key_signature = text_value(row[3]),
|
||||
.source_path = std::move(*source),
|
||||
.measure_count = count_value(row[5]),
|
||||
.total_pages = count_value(row[6]),
|
||||
};
|
||||
exercises.push_back({
|
||||
.id = text_value(row[12]),
|
||||
.practice_type_id = std::move(type_id),
|
||||
.practice_type_title = text_value(row[2]),
|
||||
.lesson_group_id = std::move(lesson_id),
|
||||
.lesson_group_title = text_value(row[4]),
|
||||
.title = text_value(row[5]),
|
||||
.composer = text_value(row[6]),
|
||||
.authored_key_signature = text_value(row[11]),
|
||||
.id = text_value(row[8]),
|
||||
.title = text_value(row[1]),
|
||||
.composer = text_value(row[2]),
|
||||
.authored_key_signature = text_value(row[7]),
|
||||
.variants = {std::move(variant)},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user