diff --git a/core/src/main/java/org/hisp/dhis/android/core/trackedentity/search/TrackedEntityInstanceLocalQueryHelper.java b/core/src/main/java/org/hisp/dhis/android/core/trackedentity/search/TrackedEntityInstanceLocalQueryHelper.java index d655be365b..b660f7aa59 100644 --- a/core/src/main/java/org/hisp/dhis/android/core/trackedentity/search/TrackedEntityInstanceLocalQueryHelper.java +++ b/core/src/main/java/org/hisp/dhis/android/core/trackedentity/search/TrackedEntityInstanceLocalQueryHelper.java @@ -29,8 +29,6 @@ package org.hisp.dhis.android.core.trackedentity.search; import org.hisp.dhis.android.core.arch.db.querybuilders.internal.WhereClauseBuilder; -import org.hisp.dhis.android.core.arch.helpers.CollectionsHelper; -import org.hisp.dhis.android.core.arch.helpers.internal.EnumHelper; import org.hisp.dhis.android.core.arch.repositories.scope.internal.FilterItemOperator; import org.hisp.dhis.android.core.arch.repositories.scope.internal.RepositoryScopeFilterItem; import org.hisp.dhis.android.core.common.AssignedUserMode; @@ -60,7 +58,6 @@ final class TrackedEntityInstanceLocalQueryHelper { private static String TEI_UID = dot(TEI_ALIAS, "uid"); private static String TEI_ALL = dot(TEI_ALIAS, "*"); - private static String TEI_STATE = dot(TEI_ALIAS, DataColumns.STATE); private static String TEI_LAST_UPDATED = dot(TEI_ALIAS, "lastUpdated"); private static String ENROLLMENT_DATE = EnrollmentTableInfo.Columns.ENROLLMENT_DATE; @@ -132,16 +129,7 @@ static String getSqlQuery(TrackedEntityInstanceQueryRepositoryScope scope, List< } // TODO In case a program uid is provided, the server orders by enrollmentStatus. - String order1 = CollectionsHelper.commaAndSpaceSeparatedArrayValues( - CollectionsHelper.withSingleQuotationMarksArray( - EnumHelper.asStringList(State.TO_POST, State.TO_UPDATE, State.UPLOADING))); - String order2 = CollectionsHelper.commaAndSpaceSeparatedArrayValues( - CollectionsHelper.withSingleQuotationMarksArray( - EnumHelper.asStringList(State.SYNCED, State.SYNCED_VIA_SMS, State.SENT_VIA_SMS))); - queryStr += " ORDER BY CASE " + - "WHEN " + TEI_STATE + " IN (" + order1 + ") THEN 1 " + - "WHEN " + TEI_STATE + " IN (" + order2 + ") THEN 2 ELSE 3 END ASC, " + - TEI_LAST_UPDATED + " DESC "; + queryStr += " ORDER BY " + TEI_LAST_UPDATED + " DESC "; if (limit > 0) { queryStr += " LIMIT " + limit;