File tree Expand file tree Collapse file tree
app/src/main/java/org/ole/planet/myplanet/services/sync Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -280,27 +280,18 @@ class TransactionSyncManager @Inject constructor(
280280 arr.size()
281281 )
282282 } else if (table == " login_activities" ) {
283+ databaseService.executeTransactionAsync { mRealm: Realm ->
283284 val insertStartTime = System .currentTimeMillis()
284- val docs = mutableListOf<JsonObject >()
285- for (j in arr) {
286- var jsonDoc = j.asJsonObject
287- jsonDoc = getJsonObject(" doc" , jsonDoc)
288- val id = getString(" _id" , jsonDoc)
289- if (! id.startsWith(" _design" )) {
290- docs.add(jsonDoc)
291- }
292- }
293- docs.forEach { jsonDoc ->
294- activitiesRepository.insertActivity(jsonDoc)
295- }
285+ activitiesRepository.bulkInsertLoginActivitiesFromSync(mRealm, arr)
296286 val insertDuration = System .currentTimeMillis() - insertStartTime
297287 org.ole.planet.myplanet.utils.SyncTimeLogger .logRealmOperation(
298288 " insert_batch" ,
299289 table,
300290 insertDuration,
301291 arr.size()
302292 )
303- } else {
293+ }
294+ } else {
304295 // Use async transaction to avoid blocking (ANR-safe)
305296 databaseService.executeTransactionAsync { mRealm: Realm ->
306297 val insertStartTime = System .currentTimeMillis()
You can’t perform that action at this time.
0 commit comments