diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java index e8835f250..19565c719 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java @@ -40,7 +40,7 @@ import com.todoroo.astrid.utility.Constants; public class ActFmInvoker { /** NOTE: these values are development values & will not work on production */ - private static final String URL = "//192.168.0.122/api/"; + private static final String URL = "//192.168.0.122:3000/api/"; private static final String APP_ID = "a4732a32859dbcd3e684331acd36432c"; private static final String APP_SECRET = "e389bfc82a0d932332f9a8bd8203735f"; diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java index 0813c95f3..bf2f84070 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java @@ -13,6 +13,7 @@ import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Functions; +import com.todoroo.andlib.sql.Order; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; @@ -295,7 +296,7 @@ public class AstridNewSyncMigrator { } // -------------- - // Finally, ensure that all tag metadata entities have all important fields filled in + // Ensure that all tag metadata entities have all important fields filled in // -------------- try { Query incompleteQuery = Query.select(Metadata.PROPERTIES).where(Criterion.and( @@ -338,6 +339,42 @@ public class AstridNewSyncMigrator { } catch (Exception e) { Log.e(LOG_TAG, "Error validating task to tag metadata", e); } + + // -------------- + // Finally, create oustanding entries for tags on unsynced tasks + // -------------- + try { + Long[] ids = tasksThatNeedTagSync.toArray(new Long[tasksThatNeedTagSync.size()]); + TodorooCursor tagsAdded = metadataService.query(Query.select(Metadata.PROPERTIES) + .where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), Metadata.TASK.in(ids))).orderBy(Order.asc(Metadata.TASK))); + try { + Metadata m = new Metadata(); + for (tagsAdded.moveToFirst(); !tagsAdded.isAfterLast(); tagsAdded.moveToNext()) { + m.clear(); + m.readFromCursor(tagsAdded); + Long deletionDate = m.getValue(Metadata.DELETION_DATE); + String tagUuid = m.getValue(TaskToTagMetadata.TAG_UUID); + if (!RemoteModel.isValidUuid(tagUuid)) + continue; + + TaskOutstanding to = new TaskOutstanding(); + to.setValue(OutstandingEntry.ENTITY_ID_PROPERTY, m.getValue(Metadata.TASK)); + to.setValue(OutstandingEntry.CREATED_AT_PROPERTY, DateUtilities.now()); + String addedOrRemoved = NameMaps.TAG_ADDED_COLUMN; + if (deletionDate != null && deletionDate > 0) + addedOrRemoved = NameMaps.TAG_REMOVED_COLUMN; + + to.setValue(OutstandingEntry.COLUMN_STRING_PROPERTY, addedOrRemoved); + to.setValue(OutstandingEntry.VALUE_STRING_PROPERTY, tagUuid); + taskOutstandingDao.createNew(to); + } + } finally { + tagsAdded.close(); + } + } catch (Exception e) { + Log.e(LOG_TAG, "Error creating tag_added outstanding entries", e); + } + Preferences.setBoolean(PREF_SYNC_MIGRATION, true); ActFmSyncMonitor monitor = ActFmSyncMonitor.getInstance(); synchronized (monitor) {