Skip to content

Commit

Permalink
Delete stat records chunk by chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
omurovch committed Jun 7, 2024
1 parent 32a1a5e commit 2ac7af8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class StatsManager(
private val gson by lazy { Gson() }
private val executor = Executors.newCachedThreadPool()
private val syncInterval = 60 * 60 // 1H in seconds
private val sqliteMaxVariableNumber = 999

private fun getInitialUiStatsEnabled(): Boolean {
val uiStatsEnabled = localStorage.uiStatsEnabled
Expand Down Expand Up @@ -114,7 +115,9 @@ class StatsManager(
// Log.e("e", "send $statsArray")
marketKit.sendStats(statsArray, appConfigProvider.appVersion, appConfigProvider.appId).blockingGet()

statsDao.delete(stats.map { it.id })
stats.chunked(sqliteMaxVariableNumber).forEach { chunk ->
statsDao.delete(chunk.map { it.id })
}
localStorage.statsLastSyncTime = currentTime
}

Expand Down

0 comments on commit 2ac7af8

Please sign in to comment.