From 79558f4386366eb544be91826dded337af0e229e Mon Sep 17 00:00:00 2001 From: Roman Makeev <57789105+makeevrserg@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:36:34 +0300 Subject: [PATCH] update irdb (#9) * update irdb * fix identify by name * add merge group --- .github/workflows/pr.yml | 1 + IRDB | 2 +- .../ifrmvp/backend/db/signal/table/SignalTable.kt | 2 ++ .../ifrmvp/parser/util/ParserPathResolver.kt | 4 +++- .../ifrmvp/parser/presentation/FillerController.kt | 9 +++++++-- .../route/signal/presentation/SignalRouteRegistry.kt | 5 +++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bd6584f..4de3b34 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,6 +1,7 @@ name: Pull Request CI on: + merge_group: pull_request: branches: - 'dev' diff --git a/IRDB b/IRDB index c7c5068..b048448 160000 --- a/IRDB +++ b/IRDB @@ -1 +1 @@ -Subproject commit c7c50689002490ea2df3fb7195524921f8b5ce76 +Subproject commit b048448525357be700f1b45787e1c61e74ddddba diff --git a/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt b/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt index f4f97df..7baf1aa 100644 --- a/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt +++ b/modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalTable.kt @@ -24,6 +24,7 @@ object SignalTable : LongIdTable("SIGNAL_TABLE") { init { uniqueIndex( + name, brandId, type, frequency, @@ -31,6 +32,7 @@ object SignalTable : LongIdTable("SIGNAL_TABLE") { data ) uniqueIndex( + name, brandId, type, protocol, diff --git a/modules/kenerator/paths/src/main/kotlin/com/flipperdevices/ifrmvp/parser/util/ParserPathResolver.kt b/modules/kenerator/paths/src/main/kotlin/com/flipperdevices/ifrmvp/parser/util/ParserPathResolver.kt index a88ad15..705d0ad 100644 --- a/modules/kenerator/paths/src/main/kotlin/com/flipperdevices/ifrmvp/parser/util/ParserPathResolver.kt +++ b/modules/kenerator/paths/src/main/kotlin/com/flipperdevices/ifrmvp/parser/util/ParserPathResolver.kt @@ -126,7 +126,9 @@ object ParserPathResolver { brand = brand, ifrFolderName = ifrFolderName ) - return Json.decodeFromString(file.readText()) + return kotlin.runCatching { Json.decodeFromString(file.readText()) } + .onFailure { println("Could not parse file ${file.absoluteFile}") } + .getOrThrow() } fun irFileConfigurationFile( diff --git a/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt b/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt index 5e367b2..7fdfd65 100644 --- a/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt +++ b/modules/kenerator/sql/src/main/kotlin/com/flipperdevices/ifrmvp/parser/presentation/FillerController.kt @@ -164,7 +164,10 @@ internal class FillerController(private val database: Database) : CoroutineScope this[SignalKeyTable.type] = IfrKeyIdentifier.Empty.TYPE } - is IfrKeyIdentifier.Name -> error("Identifying by name is not possible!") + is IfrKeyIdentifier.Name -> { + this[SignalKeyTable.remoteKeyName] = keyIdentifier.name + this[SignalKeyTable.type] = IfrKeyIdentifier.Name.TYPE + } is IfrKeyIdentifier.Sha256 -> { this[SignalKeyTable.remoteKeyName] = keyIdentifier.name @@ -191,7 +194,9 @@ internal class FillerController(private val database: Database) : CoroutineScope andWhere { SignalTable.hash eq keyIdentifier.hash } } - is IfrKeyIdentifier.Name -> error("Identifying by name is not possible!") + is IfrKeyIdentifier.Name -> { + andWhere { SignalTable.name eq keyIdentifier.name } + } } } .map { it[SignalTable.id] } diff --git a/web-api/src/main/kotlin/com/flipperdevices/ifrmvp/backend/route/signal/presentation/SignalRouteRegistry.kt b/web-api/src/main/kotlin/com/flipperdevices/ifrmvp/backend/route/signal/presentation/SignalRouteRegistry.kt index b82a4e9..c2fea51 100644 --- a/web-api/src/main/kotlin/com/flipperdevices/ifrmvp/backend/route/signal/presentation/SignalRouteRegistry.kt +++ b/web-api/src/main/kotlin/com/flipperdevices/ifrmvp/backend/route/signal/presentation/SignalRouteRegistry.kt @@ -119,6 +119,11 @@ internal class SignalRouteRegistry( .or { SignalKeyTable.hash.eq(identifier.hash) } } } + is IfrKeyIdentifier.Name -> { + andWhere { + SignalKeyTable.remoteKeyName.eq(identifier.name) + } + } else -> andWhere { SignalKeyTable.deviceKey.eq(order.key) } }