Skip to content

Commit

Permalink
V2 prepare
Browse files Browse the repository at this point in the history
- Use batch inserts to make parser faster
  • Loading branch information
makeevrserg committed Jul 24, 2024
1 parent 1a0c3a9 commit b41e4a7
Show file tree
Hide file tree
Showing 32 changed files with 250 additions and 525 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface DatabaseFactory {
return when (dbConnection) {
is DBConnection.H2 -> {
Database.connect(
url = "jdbc:h2:${dbConnection.path};DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false",
url = "jdbc:h2:${dbConnection.path};DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL",
driver = dbConnection.driver
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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.db.signal.table.InfraredFileToSignalTable
import com.flipperdevices.ifrmvp.backend.db.signal.table.SignalKeyTable
import com.flipperdevices.ifrmvp.backend.db.signal.table.SignalTable
import com.flipperdevices.ifrmvp.backend.db.signal.table.UiPresetTable
import com.flipperdevices.ifrmvp.backend.envkonfig.model.DBConnection
Expand All @@ -32,6 +33,7 @@ internal class SignalDatabaseFactory(
InfraredFileTable,
InfraredFileToSignalTable,
SignalTable,
SignalKeyTable,
UiPresetTable,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.flipperdevices.ifrmvp.backend.db.signal.table

import com.flipperdevices.ifrmvp.backend.model.DeviceKey
import org.jetbrains.exposed.dao.id.LongIdTable

object SignalKeyTable : LongIdTable("SIGNAL_KEY") {
val infraredFileId = reference("ir_file_id", InfraredFileTable)
val signalId = reference("signal_id", SignalTable)

/**
* The name of brand folder
*/
val deviceKey = enumeration<DeviceKey>("device_key")
val remoteKeyName = text("remote_key_name")
}
1 change: 1 addition & 0 deletions modules/kenerator/configuration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies {
implementation(projects.modules.database)
implementation(projects.modules.infrared)
implementation(projects.modules.kenerator.sql)
implementation(projects.modules.kenerator.paths)
}

application {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.flipperdevices.ifrmvp.generator.config

import com.flipperdevices.ifrmvp.generator.config.category.api.AllCategoryConfigGenerator
import com.flipperdevices.ifrmvp.generator.config.category.model.CategoryType
import com.flipperdevices.ifrmvp.backend.model.CategoryType
import com.flipperdevices.ifrmvp.generator.config.device.api.DefaultDeviceConfigGenerator
import com.flipperdevices.ifrmvp.generator.config.device.api.any.AnyDeviceKeyNamesProvider
import com.flipperdevices.ifrmvp.parser.util.ParserPathResolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.flipperdevices.ifrmvp.generator.config.category.api

import com.flipperdevices.ifrmvp.backend.model.DeviceKey
import com.flipperdevices.ifrmvp.generator.config.category.api.DeviceKeyExt.getAllowedCategories
import com.flipperdevices.ifrmvp.generator.config.category.model.CategoryConfiguration
import com.flipperdevices.ifrmvp.generator.config.category.model.CategoryType
import com.flipperdevices.ifrmvp.backend.model.CategoryConfiguration
import com.flipperdevices.ifrmvp.backend.model.CategoryType
import com.flipperdevices.ifrmvp.model.buttondata.IconButtonData
import com.flipperdevices.ifrmvp.model.buttondata.TextButtonData

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.flipperdevices.ifrmvp.generator.config.category.api

import com.flipperdevices.ifrmvp.backend.model.DeviceKey
import com.flipperdevices.ifrmvp.generator.config.category.model.CategoryType
import com.flipperdevices.ifrmvp.backend.model.CategoryType

object DeviceKeyExt {
@Suppress("LongMethod", "CyclomaticComplexMethod")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.flipperdevices.ifrmvp.generator.config.device.api

import com.flipperdevices.ifrmvp.generator.config.device.api.DeviceKeyNamesProvider.Companion.getKey
import com.flipperdevices.ifrmvp.generator.config.device.model.DeviceConfiguration
import com.flipperdevices.ifrmvp.backend.model.DeviceConfiguration
import java.io.File

class DefaultDeviceConfigGenerator(private val keyNamesProvider: DeviceKeyNamesProvider) : DeviceConfigGenerator {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.flipperdevices.ifrmvp.generator.config.device.api

import com.flipperdevices.bridge.dao.api.model.FlipperFileFormat
import com.flipperdevices.ifrmvp.generator.config.device.model.DeviceConfiguration
import com.flipperdevices.ifrmvp.backend.model.DeviceConfiguration
import com.flipperdevices.infrared.editor.model.InfraredRemote
import com.flipperdevices.infrared.editor.viewmodel.InfraredKeyParser
import java.io.File
Expand Down
16 changes: 16 additions & 0 deletions modules/kenerator/paths/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo

plugins {
id("org.jetbrains.kotlin.jvm")
alias(libs.plugins.kotlin.serialization)
}

dependencies {
implementation(libs.kotlin.serialization.json)
implementation(kotlin("test"))
// Local
implementation(projects.modules.buildKonfig)
implementation(projects.modules.core)
implementation(projects.modules.model)
implementation(projects.modules.infrared)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.flipperdevices.ifrmvp.parser.util

import com.flipperdevices.ifrmvp.backend.envkonfig.EnvKonfig
import com.flipperdevices.ifrmvp.backend.model.CategoryConfiguration
import com.flipperdevices.ifrmvp.backend.model.CategoryMeta
import com.flipperdevices.ifrmvp.backend.model.DeviceConfiguration
import kotlinx.serialization.json.Json
import java.io.File
import kotlin.io.encoding.Base64
Expand Down Expand Up @@ -37,6 +39,15 @@ object ParserPathResolver {
return categoriesFolder.resolve(category)
}

fun categoryConfiguration(category: String): CategoryConfiguration {
val file = categoryConfigurationFile(category = category)
return Json.decodeFromString(file.readText())
}

fun categoryConfigurationFile(category: String): File {
return categoryPath(category).resolve("config.json")
}

/**
* Get all brands of current category
* @param category the name of category
Expand Down Expand Up @@ -105,6 +116,27 @@ object ParserPathResolver {
return folder.resolve("$ifrFolderName.ir")
}

fun irFileConfiguration(
category: String,
brand: String,
ifrFolderName: String
): DeviceConfiguration {
val file = irFileConfigurationFile(
category = category,
brand = brand,
ifrFolderName = ifrFolderName
)
return Json.decodeFromString(file.readText())
}

fun irFileConfigurationFile(
category: String,
brand: String,
ifrFolderName: String
): File {
return brandPath(category, brand).resolve(ifrFolderName).resolve("config.json")
}

/**
* Get specific ui preset file
* @param category category name of brand
Expand Down
1 change: 1 addition & 0 deletions modules/kenerator/sql/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {
implementation(projects.modules.model)
implementation(projects.modules.database)
implementation(projects.modules.infrared)
implementation(projects.modules.kenerator.paths)
}

application {
Expand Down

This file was deleted.

Loading

0 comments on commit b41e4a7

Please sign in to comment.