fix: node search by keeping denormalized name columns up to date and backfilling existing nodes (#3839)

This commit is contained in:
Mac DeCourcy 2025-11-28 09:38:30 -08:00 committed by GitHub
parent ef9c0dc844
commit 1c0dc486e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 44 additions and 1 deletions

View file

@ -37,4 +37,6 @@ interface NodeInfoWriteDataSource {
suspend fun upsert(metadata: MetadataEntity)
suspend fun setNodeNotes(num: Int, notes: String)
suspend fun backfillDenormalizedNames()
}

View file

@ -57,4 +57,7 @@ constructor(
override suspend fun setNodeNotes(num: Int, notes: String) =
withContext(dispatchers.io) { dbManager.withDb { it.nodeInfoDao().setNodeNotes(num, notes) } }
override suspend fun backfillDenormalizedNames() =
withContext(dispatchers.io) { dbManager.withDb { it.nodeInfoDao().backfillDenormalizedNames() } }
}

View file

@ -54,6 +54,13 @@ constructor(
private val nodeInfoWriteDataSource: NodeInfoWriteDataSource,
private val dispatchers: CoroutineDispatchers,
) {
init {
// Backfill denormalized name columns for existing nodes on startup
processLifecycle.coroutineScope.launchWhenCreated {
withContext(dispatchers.io) { nodeInfoWriteDataSource.backfillDenormalizedNames() }
}
}
// hardware info about our local device (can be null)
val myNodeInfo: StateFlow<MyNodeEntity?> =
nodeInfoReadDataSource