Skip to content

Commit

Permalink
Merge pull request #1709 from dhis2/androsdk-1495
Browse files Browse the repository at this point in the history
fix: [ANDROSDK-1495] Use lastUpdated in global download
  • Loading branch information
vgarciabnz authored Jan 31, 2022
2 parents b3bc7f6 + b31976a commit 2eeb9b5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ ext {
buildToolsVersion: "29.0.3",
minSdkVersion : 19,
targetSdkVersion : 29,
versionCode : 251,
versionName : "1.5.1"
versionCode : 252,
versionName : "1.5.2"
]

libraries = [
Expand Down
4 changes: 2 additions & 2 deletions core/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# Properties which are consumed by plugins/gradle-mvn-push.gradle plugin.
# They are used for publishing artifact to snapshot repository.

VERSION_NAME=1.5.1
VERSION_CODE=251
VERSION_NAME=1.5.2
VERSION_CODE=252

GROUP=org.hisp.dhis

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance

@Reusable
internal class TrackedEntityInstancesEndpointCallFactory @Inject constructor(
private val trackedEntityInstanceService: TrackedEntityInstanceService,
private val lastUpdatedManager: TrackedEntityInstanceLastUpdatedManager
private val trackedEntityInstanceService: TrackedEntityInstanceService
) {

fun getCall(query: TrackerQuery): Single<Payload<TrackedEntityInstance>> {
Expand All @@ -52,7 +51,7 @@ internal class TrackedEntityInstancesEndpointCallFactory @Inject constructor(
true,
query.page(),
query.pageSize(),
lastUpdatedManager.getLastUpdatedStr(query.commonParams()),
query.lastUpdatedStr(),
true,
true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,23 @@ internal open class TrackerSyncLastUpdatedManager<S : TrackerBaseSync>(private v
.toMap()
}

private fun getLastUpdated(commonParams: TrackerQueryCommonParams): Date? {
return getLastUpdated(commonParams.program, commonParams.orgUnitsBeforeDivision.toSet(), commonParams.limit)
}

fun getLastUpdatedStr(commonParams: TrackerQueryCommonParams): String? {
return getLastUpdated(commonParams)?.let { BaseIdentifiableObject.dateToDateStr(it) }
}

fun getLastUpdated(programId: String?, organisationUnits: Set<String>, limit: Int): Date? {
private fun getLastUpdated(commonParams: TrackerQueryCommonParams): Date? {
return getLastUpdated(commonParams.program, commonParams.orgUnitsBeforeDivision.toSet(), commonParams.limit)
}

private fun getLastUpdated(programId: String?, organisationUnits: Set<String>, limit: Int): Date? {
val orgUnitHashCode = organisationUnits.toSet().hashCode()
return if (params.uids().isEmpty()) {
val storedSync = syncMap[Pair(programId, orgUnitHashCode)]
return getLastUpdatedIfValid(storedSync, limit) ?: getDefaultLastUpdated(programId)
val programSync = syncMap[Pair(programId, orgUnitHashCode)]
val globalSync = syncMap[Pair(null, orgUnitHashCode)]

return getLastUpdatedIfValid(programSync, limit)
?: getLastUpdatedIfValid(globalSync, limit)
?: getDefaultLastUpdated(programId)
} else {
null
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/developer/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Include dependency in build.gradle.

```gradle
dependencies {
implementation "org.hisp.dhis:android-core:1.5.1"
implementation "org.hisp.dhis:android-core:1.5.2"
...
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/dhis2_android_sdk_developer_guide_INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ month: January
keywords: [DHIS2, Android]
commit:
version: master
applicable_txt: 'Applicable to version 1.5.1'
applicable_txt: 'Applicable to version 1.5.2'
---
<!--DHIS2-SECTION-ID:index-->

Expand Down

0 comments on commit 2eeb9b5

Please sign in to comment.