Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
froks committed Apr 19, 2024
1 parent cbb3226 commit 26d0ff1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@ class DltAnalyzerWindow {
) { progress ->
if (progress.progress != null) {
SwingUtilities.invokeLater {
if (progress.progress != null) {
progressBar.isIndeterminate = false
progressBar.value = (progress.progress!! * 100f).roundToInt()
} else {
progressBar.isIndeterminate = true
}
progressBar.isIndeterminate = false
progressBar.value = (progress.progress!! * 100f).roundToInt()
progressBar.string = progress.progressText
}
} else if (!progressBar.isIndeterminate) {
Expand Down
6 changes: 3 additions & 3 deletions dlt-analyzer-app/src/main/kotlin/analyzer/ui/sxs/LogPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import analyzer.asIcon
import analyzer.formatDefault
import analyzer.plugin.DltTargetAware
import db.DltLog
import db.DltTableDataAccess
import db.DltTarget
import jiconfont.icons.google_material_design_icons.GoogleMaterialDesignIcons
import org.ktorm.dsl.inList
Expand Down Expand Up @@ -45,16 +44,17 @@ class LogPanel : JPanel(BorderLayout()), DltTargetAware {
logger.info("Updating Text")
if (this.appId != appId || force) {
thread(isDaemon = true) {
val dltTarget = this.dltTarget
if (dltTarget == null) {
SwingUtilities.invokeLater {
textArea.text = "No dlt target is selected"
}
return@thread
}
textArea.text = "Loading data"
val dao = DltTableDataAccess(dltTarget!!.dataSource)

val appIds = appId.split(',', ' ', ';').filter { it.isNotBlank() }
val data = dao.readData(listOf(DltLog.appId.inList(appIds)))
val data = dltTarget.dataAccess.readData(listOf(DltLog.appId.inList(appIds)))
val text = data.joinToString("\n") {
if (appIds.size > 1) {
"[${it.timestamp.formatDefault()} ${it.appId.padEnd(4, ' ')} ${it.messageType.shortText.padEnd(5, ' ')}] ${it.message.trimEnd()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ class DltTableModel(private var dltTarget: DltTarget, private var internalFilter

private val CACHED_ENTRIES_COUNT = 1_000

private var tableAccess: DltTableDataAccess
private var tableAccess: DltTableDataAccess = dltTarget.dataAccess
private var rowCount: Int = 0

private var listOffset = 0
private var cachedEntries: List<DltMessageDto> = emptyList()
private var cachedEntriesColor: MutableMap<Int, Color> = mutableMapOf()

init {
tableAccess = DltTableDataAccess(dltTarget.dataSource)
rowCount = tableAccess.getEntryCount(filterList.sqlWhere()).toInt()
}

Expand Down
6 changes: 4 additions & 2 deletions dlt-database/src/main/kotlin/db/DltManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ object DltManager {

if (reuseExisting) {
logger.info("Reusing existing database file ${dbFile.absolutePath}")
dataAccess.createIndexes()
}


if (!reuseExisting) {
dataAccess.initialize()
}
Expand Down Expand Up @@ -120,4 +120,6 @@ data class DltTarget(
val dltFile: File?,
val dataSource: DataSource,
var isLoaded: Boolean = false,
)
) {
val dataAccess by lazy { DltTableDataAccess(dataSource) }
}
20 changes: 8 additions & 12 deletions dlt-database/src/main/kotlin/db/DltTableDataAccess.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ class DltTableDataAccess(private val dataSource: DataSource) {
limit: Int? = null
): List<DltMessageDto> {
val list = mutableListOf<DltMessageDto>()
val duration = measureTimeMillis {
database
.from(DltLog)
.select()
.whereWithOrConditions { list -> list.addAll(sqlClausesOr) }
.orderBy(DltLog.id.asc())
.limit(offset, limit)
.mapTo(list) { row -> DltLog.createEntity(row) }
}

logger.debug("Reading data for took $duration ms")
database
.from(DltLog)
.select()
.whereWithOrConditions { list -> list.addAll(sqlClausesOr) }
.orderBy(DltLog.id.asc())
.limit(offset, limit)
.mapTo(list) { row -> DltLog.createEntity(row) }

return list
}

Expand All @@ -94,8 +92,6 @@ class DltTableDataAccess(private val dataSource: DataSource) {
.select(count(DltLog.id))
.whereWithOrConditions { list -> list.addAll(sqlClausesOr) }

logger.info("Retrieving count ${sql.sql}")

return database.executeQuery(sql.expression).use {
it.first()
it.getLong(1)
Expand Down

0 comments on commit 26d0ff1

Please sign in to comment.