-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Infrared signal selection (#1)
## Background: This PR introduces new version of infrared signal selection with fixed several issues of previous version ## Changes: - Database normalization fix - Configuration generator for categories - Configuration generator for devices - Fix brands sorting - Fix exception on non-existing brands - Fix duplicate signals - Improve parser speed - Fix device configuration sha hash generation
- Loading branch information
1 parent
3878a74
commit 732cfaa
Showing
138 changed files
with
2,163 additions
and
1,288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ build | |
|
||
jars | ||
output | ||
.env | ||
.env | ||
DB_FILE.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule IRDB
updated
5013 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ org.gradle.parallel=true | |
makeevrserg.project.name=IfrBackend | ||
makeevrserg.project.url=https://github.com/makeevrserg/IfrSample | ||
makeevrserg.project.group=com.flipperdevices.ifrmvp.backend | ||
makeevrserg.project.version.string=0.1.0 | ||
makeevrserg.project.version.string=0.2.0 | ||
makeevrserg.project.description=Api for IfrSample | ||
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected] | ||
# Java | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## This file must *NOT* be checked into Version Control Systems, | ||
# as it contains information specific to your local configuration. | ||
# | ||
# Location of the SDK. This is only used by Gradle. | ||
# For customization when using a Version Control System, please read the | ||
# header note. | ||
#Thu May 23 11:47:58 MSK 2024 | ||
sdk.dir=/Users/romanmakeev/Library/Android/sdk |
8 changes: 0 additions & 8 deletions
8
...pi-status/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/BrandTable.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...us/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/CategoryMetaTable.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...-status/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/IfrFileTable.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...tus/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/SignalOrderTable.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...status/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/table/UiPresetTable.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
modules/database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/dao/TableDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.flipperdevices.ifrmvp.backend.db.signal.dao | ||
|
||
import com.flipperdevices.ifrmvp.backend.model.BrandModel | ||
import com.flipperdevices.ifrmvp.backend.model.DeviceCategory | ||
import com.flipperdevices.ifrmvp.backend.model.IfrFileModel | ||
|
||
interface TableDao { | ||
suspend fun getCategoryById(categoryId: Long): DeviceCategory | ||
suspend fun getBrandById(brandId: Long): BrandModel | ||
suspend fun ifrFileById(irFileId: Long): IfrFileModel | ||
|
||
companion object { | ||
suspend fun TableDao.getCategoryByBrandId(brandId: Long): DeviceCategory { | ||
val brandModel = getBrandById(brandId) | ||
return getCategoryById(brandModel.categoryId) | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
.../database/src/main/kotlin/com/flipperdevices/ifrmvp/backend/db/signal/dao/TableDaoImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.flipperdevices.ifrmvp.backend.db.signal.dao | ||
|
||
import com.flipperdevices.ifrmvp.backend.db.signal.exception.TableDaoException | ||
import com.flipperdevices.ifrmvp.backend.db.signal.table.BrandTable | ||
import com.flipperdevices.ifrmvp.backend.db.signal.table.CategoryMetaTable | ||
import com.flipperdevices.ifrmvp.backend.db.signal.table.CategoryTable | ||
import com.flipperdevices.ifrmvp.backend.db.signal.table.InfraredFileTable | ||
import com.flipperdevices.ifrmvp.backend.model.BrandModel | ||
import com.flipperdevices.ifrmvp.backend.model.CategoryManifest | ||
import com.flipperdevices.ifrmvp.backend.model.CategoryMeta | ||
import com.flipperdevices.ifrmvp.backend.model.DeviceCategory | ||
import com.flipperdevices.ifrmvp.backend.model.IfrFileModel | ||
import org.jetbrains.exposed.sql.Database | ||
import org.jetbrains.exposed.sql.selectAll | ||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction | ||
|
||
internal class TableDaoImpl(private val database: Database) : TableDao { | ||
override suspend fun getCategoryById( | ||
categoryId: Long | ||
): DeviceCategory = newSuspendedTransaction(db = database) { | ||
CategoryTable | ||
.selectAll() | ||
.where { CategoryTable.id eq categoryId } | ||
.limit(1) | ||
.map { r -> | ||
DeviceCategory( | ||
id = r[CategoryTable.id].value, | ||
folderName = r[CategoryTable.folderName], | ||
meta = CategoryMetaTable.selectAll() | ||
.where { CategoryMetaTable.categoryId eq categoryId } | ||
.limit(1) | ||
.map { | ||
CategoryMeta( | ||
iconPngBase64 = it[CategoryMetaTable.iconPngBase64], | ||
iconSvgBase64 = it[CategoryMetaTable.iconSvgBase64], | ||
manifest = CategoryManifest( | ||
displayName = it[CategoryMetaTable.displayName], | ||
singularDisplayName = it[CategoryMetaTable.singularDisplayName], | ||
) | ||
) | ||
}.firstOrNull() ?: throw TableDaoException.CategoryMeta(categoryId) | ||
) | ||
}.firstOrNull() ?: throw TableDaoException.CategoryNotFound(categoryId) | ||
} | ||
|
||
override suspend fun getBrandById( | ||
brandId: Long | ||
): BrandModel = newSuspendedTransaction(db = database) { | ||
BrandTable | ||
.selectAll() | ||
.where { BrandTable.id eq brandId } | ||
.limit(1) | ||
.map { | ||
BrandModel( | ||
id = it[BrandTable.id].value, | ||
folderName = it[BrandTable.folderName], | ||
categoryId = it[BrandTable.categoryId].value | ||
) | ||
}.firstOrNull() ?: throw TableDaoException.BrandNotFound(brandId) | ||
} | ||
|
||
override suspend fun ifrFileById( | ||
irFileId: Long | ||
): IfrFileModel = newSuspendedTransaction(db = database) { | ||
InfraredFileTable | ||
.selectAll() | ||
.where { InfraredFileTable.id eq irFileId } | ||
.limit(1) | ||
.map { | ||
IfrFileModel( | ||
id = it[InfraredFileTable.id].value, | ||
brandId = it[InfraredFileTable.brandId].value, | ||
fileName = it[InfraredFileTable.fileName], | ||
folderName = it[InfraredFileTable.folderName] | ||
) | ||
}.firstOrNull() ?: throw TableDaoException.IrFileNotFound(irFileId) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...p/backend/db/signal/di/SignalApiModule.kt → ...p/backend/db/signal/di/SignalApiModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package com.flipperdevices.ifrmvp.backend.db.signal.di | ||
|
||
import com.flipperdevices.ifrmvp.backend.db.signal.dao.TableDao | ||
import com.flipperdevices.ifrmvp.backend.db.signal.dao.TableDaoImpl | ||
import com.flipperdevices.ifrmvp.backend.db.signal.di.factory.SignalDatabaseFactory | ||
import com.flipperdevices.ifrmvp.backend.envkonfig.model.DBConnection | ||
import org.jetbrains.exposed.sql.Database | ||
|
||
interface SignalApiModule { | ||
val database: Database | ||
val tableDao: TableDao | ||
|
||
class Default( | ||
signalDbConnection: DBConnection | ||
) : SignalApiModule { | ||
override val database: Database by lazy { | ||
SignalDatabaseFactory(signalDbConnection).create() | ||
} | ||
override val tableDao: TableDao by lazy { | ||
TableDaoImpl(database) | ||
} | ||
} | ||
} |
Oops, something went wrong.