add logger to FreshRSS sync

This commit is contained in:
Shinokuni 2019-10-26 18:30:24 +02:00
parent e2d497f32a
commit 13f3132238
1 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package com.readrops.app.repositories;
import android.app.Application;
import android.util.Log;
import android.util.TimingLogger;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -88,6 +89,8 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
} else
syncType = SyncType.INITIAL_SYNC;
TimingLogger logger = new TimingLogger(TAG, "FreshRSS sync timer");
return Single.<FreshRSSSyncData>create(emitter -> {
syncData.setReadItemsIds(database.itemDao().getReadChanges(account.getId()));
syncData.setUnreadItemsIds(database.itemDao().getUnreadChanges(account.getId()));
@ -95,14 +98,21 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
emitter.onSuccess(syncData);
}).flatMap(syncData1 -> api.sync(syncType, syncData1, account.getWriteToken()))
.flatMapObservable(syncResult -> {
logger.addSplit("server queries");
insertFolders(syncResult.getFolders());
logger.addSplit("folders insertion");
insertFeeds(syncResult.getFeeds());
logger.addSplit("feeds insertion");
insertItems(syncResult.getItems(), syncType == SyncType.INITIAL_SYNC);
logger.addSplit("items insertion");
account.setLastModified(syncResult.getLastUpdated());
database.accountDao().updateLastModified(account.getId(), syncResult.getLastUpdated());
database.itemDao().resetReadChanges(account.getId());
logger.dumpToLog();
return Observable.empty();
});