mirror of
https://github.com/ev-map/EVMap.git
synced 2026-04-30 19:14:22 -04:00
OSM: try to speed up download process
This commit is contained in:
@@ -18,6 +18,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.vonforst.evmap.api.ChargepointApi
|
||||
import net.vonforst.evmap.api.ChargepointList
|
||||
import net.vonforst.evmap.api.StringProvider
|
||||
@@ -534,8 +535,14 @@ class ChargeLocationsRepository(
|
||||
val time = Instant.now()
|
||||
val result = api.fullDownload()
|
||||
try {
|
||||
result.chargers.chunked(100).forEach {
|
||||
chargeLocationsDao.insert(*it.toTypedArray())
|
||||
var insertJob: Job? = null
|
||||
result.chargers.chunked(1024).forEach {
|
||||
insertJob?.join()
|
||||
insertJob = withContext(Dispatchers.IO) {
|
||||
scope.launch {
|
||||
chargeLocationsDao.insert(*it.toTypedArray())
|
||||
}
|
||||
}
|
||||
fullDownloadProgress.value = result.progress
|
||||
}
|
||||
val region = Mbr(
|
||||
|
||||
Reference in New Issue
Block a user