Look at last sync date when deciding when to record tag outstanding entries during migration

pull/14/head
Sam Bosley 12 years ago
parent 7ff1890285
commit 510ade7311

@ -170,6 +170,7 @@ public final class Task extends RemoteModel {
TABLE, "creatorId", Property.PROP_FLAG_USER_ID); TABLE, "creatorId", Property.PROP_FLAG_USER_ID);
/** Last Sync date */ /** Last Sync date */
@Deprecated
public static final LongProperty LAST_SYNC = new LongProperty( public static final LongProperty LAST_SYNC = new LongProperty(
TABLE, "lastSync", Property.PROP_FLAG_DATE); TABLE, "lastSync", Property.PROP_FLAG_DATE);

@ -125,8 +125,19 @@ public class AstridNewSyncMigrator {
// Then ensure that every remote model has a remote id, by generating one using the uuid generator for all those without one // Then ensure that every remote model has a remote id, by generating one using the uuid generator for all those without one
// -------------- // --------------
try { try {
Query tagsQuery = Query.select(TagData.ID, TagData.UUID).where(Criterion.or(TagData.UUID.eq(RemoteModel.NO_UUID), TagData.UUID.isNull())); Query tagsQuery = Query.select(TagData.ID, TagData.UUID, TagData.MODIFICATION_DATE).where(Criterion.or(TagData.UUID.eq(RemoteModel.NO_UUID), TagData.UUID.isNull()));
assertUUIDsExist(tagsQuery, new TagData(), tagDataDao, tagOutstandingDao, new TagOutstanding(), NameMaps.syncableProperties(NameMaps.TABLE_ID_TAGS), null); assertUUIDsExist(tagsQuery, new TagData(), tagDataDao, tagOutstandingDao, new TagOutstanding(), NameMaps.syncableProperties(NameMaps.TABLE_ID_TAGS), new UUIDAssertionExtras<TagData>() {
private static final String LAST_TAG_FETCH_TIME = "actfm_lastTag"; //$NON-NLS-1$
private final long lastFetchTime = Preferences.getLong(LAST_TAG_FETCH_TIME, 0);
@Override
public void beforeSave(TagData instance) {/**/}
@Override
public boolean shouldCreateOutstandingEntries(TagData instance) {
return lastFetchTime == 0 || (instance.containsNonNullValue(TagData.MODIFICATION_DATE) && instance.getValue(TagData.MODIFICATION_DATE) > lastFetchTime);
}
});
Query tasksQuery = Query.select(Task.ID, Task.UUID, Task.RECURRENCE, Task.FLAGS, Task.MODIFICATION_DATE, Task.LAST_SYNC).where(Criterion.all); Query tasksQuery = Query.select(Task.ID, Task.UUID, Task.RECURRENCE, Task.FLAGS, Task.MODIFICATION_DATE, Task.LAST_SYNC).where(Criterion.all);
assertUUIDsExist(tasksQuery, new Task(), taskDao, taskOutstandingDao, new TaskOutstanding(), NameMaps.syncableProperties(NameMaps.TABLE_ID_TASKS), new UUIDAssertionExtras<Task>() { assertUUIDsExist(tasksQuery, new Task(), taskDao, taskOutstandingDao, new TaskOutstanding(), NameMaps.syncableProperties(NameMaps.TABLE_ID_TASKS), new UUIDAssertionExtras<Task>() {
@ -156,7 +167,7 @@ public class AstridNewSyncMigrator {
@Override @Override
public boolean shouldCreateOutstandingEntries(Task instance) { public boolean shouldCreateOutstandingEntries(Task instance) {
if (!instance.containsNonNullValue(Task.MODIFICATION_DATE)) if (!instance.containsNonNullValue(Task.MODIFICATION_DATE) || instance.getValue(Task.LAST_SYNC) == 0)
return true; return true;
return instance.getValue(Task.LAST_SYNC) < instance.getValue(Task.MODIFICATION_DATE); return instance.getValue(Task.LAST_SYNC) < instance.getValue(Task.MODIFICATION_DATE);
} }

Loading…
Cancel
Save