Mesh Packet Limit (#1245)

* Separated the device and environment metrics into their own files.

* Place a limit to the amount of MeshPackets we retrieve from the logs table.

* Making detekt happy with the naming.
This commit is contained in:
Robert-0410 2024-09-14 14:48:05 -07:00 committed by GitHub
parent dff7221502
commit 0c52bef43b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 742 additions and 686 deletions

View file

@ -27,7 +27,7 @@ class MeshLogRepository @Inject constructor(private val meshLogDaoLazy: dagger.L
}
@OptIn(ExperimentalCoroutinesApi::class)
fun getMeshPacketsFrom(nodeNum: Int) = meshLogDao.getAllLogsInReceiveOrder(Int.MAX_VALUE)
fun getMeshPacketsFrom(nodeNum: Int) = meshLogDao.getAllLogs(MAX_MESH_PACKETS)
.mapLatest { list -> list.mapNotNull { it.meshPacket }.filter { it.from == nodeNum } }
.distinctUntilChanged()
.flowOn(Dispatchers.IO)
@ -48,5 +48,6 @@ class MeshLogRepository @Inject constructor(private val meshLogDaoLazy: dagger.L
companion object {
private const val MAX_ITEMS = 500
private const val MAX_MESH_PACKETS = 10000
}
}
}