Skip to content

Commit

Permalink
fix(metrics): replace telemetry times with receive time
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Oct 25, 2024
1 parent 5cf9741 commit a3b4b70
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class MeshLogRepository @Inject constructor(private val meshLogDaoLazy: dagger.L
meshLogDao.getAllLogsInReceiveOrder(maxItems)
}

private fun parseTelemetryLog(log: MeshLog): Telemetry? =
runCatching { Telemetry.parseFrom(log.fromRadio.packet.decoded.payload) }.getOrNull()
private fun parseTelemetryLog(log: MeshLog): Telemetry? = runCatching {
Telemetry.parseFrom(log.fromRadio.packet.decoded.payload)
.toBuilder().setTime((log.received_date / MILLIS_TO_SECONDS).toInt()).build()
}.getOrNull()

@OptIn(ExperimentalCoroutinesApi::class)
fun getTelemetryFrom(nodeNum: Int): Flow<List<Telemetry>> =
Expand Down Expand Up @@ -61,5 +63,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
private const val MILLIS_TO_SECONDS = 1000
}
}

0 comments on commit a3b4b70

Please sign in to comment.