use of com.wingjay.jianshi.db.model.EventLog in project jianshi by wingjay.
the class SyncManager method syncLog.
public synchronized void syncLog() {
final List<EventLog> logItems = SQLite.select().from(EventLog.class).queryList();
JsonObject syncLog = new JsonObject();
JsonArray array = new JsonArray();
for (EventLog eventLog : logItems) {
array.add(new Gson().toJsonTree(eventLog));
}
syncLog.add("log_items", array);
userService.syncLog(syncLog).subscribe(new Action1<JsonDataResponse<JsonObject>>() {
@Override
public void call(JsonDataResponse<JsonObject> jsonObjectJsonDataResponse) {
if (jsonObjectJsonDataResponse.getRc() == Constants.ServerResultCode.RESULT_OK) {
JsonObject object = jsonObjectJsonDataResponse.getData();
int syncedCount = object.get("synced_count").getAsInt();
Timber.i("synced log count %d", syncedCount);
for (EventLog eventLog : logItems) {
SQLite.delete(EventLog.class).where(EventLog_Table.id.eq(eventLog.getId())).execute();
syncedCount--;
if (syncedCount <= 0) {
break;
}
}
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
Timber.e(throwable, "SyncLog failed");
}
});
}
use of com.wingjay.jianshi.db.model.EventLog in project jianshi by wingjay.
the class Blaster method log.
public static void log(String eventName, String pageSource) {
EventLog eventLog = new EventLog();
eventLog.setEventName(eventName);
eventLog.setPageSource(pageSource);
eventLog.setTimeCreated(DateUtil.getCurrentTimeStamp());
eventLog.save();
}
Aggregations