Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
}

suspend fun saveORSCampaignToServer(orsCampaignCache: ORSCampaignCache): Boolean {
return withContext(Dispatchers.IO) {

Check warning on line 190 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQr&open=AZ4c9keCcnmh5_MSchQr&pullRequest=446
try {

val formDataJson = orsCampaignCache.formDataJson ?: ""
Expand Down Expand Up @@ -278,7 +278,7 @@
}

suspend fun getORSCampaignFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 281 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQs&open=AZ4c9keCcnmh5_MSchQs&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
try {
Expand Down Expand Up @@ -394,7 +394,7 @@
}

suspend fun savePulsePolioCampaignToServer(pulsePolioCampaignCache: PulsePolioCampaignCache): Boolean {
return withContext(Dispatchers.IO) {

Check warning on line 397 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQt&open=AZ4c9keCcnmh5_MSchQt&pullRequest=446
try {
val formDataJson = pulsePolioCampaignCache.formDataJson ?: ""
val formDataObj = try {
Expand Down Expand Up @@ -495,7 +495,7 @@


suspend fun getPulsePolioCampaignFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 498 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQu&open=AZ4c9keCcnmh5_MSchQu&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
try {
Expand Down Expand Up @@ -706,7 +706,7 @@
}

suspend fun getVHNDFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 709 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQv&open=AZ4c9keCcnmh5_MSchQv&pullRequest=446
val user =
preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
Expand Down Expand Up @@ -783,7 +783,7 @@
// Previously all-or-nothing batch. One bad chunk doesn't affect others.
// Also removed dangerous recursive retry on SocketTimeoutException.
private suspend fun pushUnSyncedRecordsVHND(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 786 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQw&open=AZ4c9keCcnmh5_MSchQw&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")

Expand Down Expand Up @@ -864,7 +864,7 @@
}

suspend fun getVHNCFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 867 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQx&open=AZ4c9keCcnmh5_MSchQx&pullRequest=446
val user =
preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
Expand Down Expand Up @@ -941,7 +941,7 @@
// Previously all-or-nothing batch. One bad chunk doesn't affect others.
// Also removed dangerous recursive retry on SocketTimeoutException.
private suspend fun pushUnSyncedRecordsVHNC(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 944 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQy&open=AZ4c9keCcnmh5_MSchQy&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")

Expand Down Expand Up @@ -1022,7 +1022,7 @@
}

suspend fun getPHCFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1025 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQz&open=AZ4c9keCcnmh5_MSchQz&pullRequest=446
val user =
preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
Expand Down Expand Up @@ -1099,7 +1099,7 @@
// Previously all-or-nothing batch. One bad chunk doesn't affect others.
// Also removed dangerous recursive retry on SocketTimeoutException.
private suspend fun pushUnSyncedRecordsPHC(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1102 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ0&open=AZ4c9keCcnmh5_MSchQ0&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")

Expand Down Expand Up @@ -1181,7 +1181,7 @@
}

suspend fun getAHDFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1184 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ1&open=AZ4c9keCcnmh5_MSchQ1&pullRequest=446
val user =
preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
Expand Down Expand Up @@ -1258,7 +1258,7 @@
// Previously all-or-nothing batch. One bad chunk doesn't affect others.
// Also removed dangerous recursive retry on SocketTimeoutException.
private suspend fun pushUnSyncedRecordsAHD(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1261 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ2&open=AZ4c9keCcnmh5_MSchQ2&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")

Expand Down Expand Up @@ -1338,7 +1338,7 @@
}

suspend fun getDewormingFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1341 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ3&open=AZ4c9keCcnmh5_MSchQ3&pullRequest=446
val user =
preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
Expand Down Expand Up @@ -1414,7 +1414,7 @@
// Previously all-or-nothing batch. One bad chunk doesn't affect others.
// Also removed dangerous recursive retry on SocketTimeoutException.
private suspend fun pushUnSyncedRecordsDeworming(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1417 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ4&open=AZ4c9keCcnmh5_MSchQ4&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")

Expand Down Expand Up @@ -1487,17 +1487,22 @@
val ahd = vlfDao.getAllAHD()
val deworming = vlfDao.countDewormingInLastSixMonths()

val formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy", Locale.ENGLISH)

Check warning on line 1490 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused "formatter" local variable.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ7&open=AZ4c9keCcnmh5_MSchQ7&pullRequest=446

return combine(vhnd, vhnc, phc, ahd, deworming) { vhndList, vhncList, phcList, ahdList, dewormingCount ->

fun isInCurrentMonth(dateStr: String?): Boolean {
return try {
val date = LocalDate.parse(dateStr, formatter)
YearMonth.from(date) == current
} catch (e: Exception) {
false
if (dateStr.isNullOrBlank()) return false
val parsedDate = try {
LocalDate.parse(dateStr, formatIndian)
} catch (e: java.time.format.DateTimeParseException) {
try {
LocalDate.parse(dateStr, formatIso)
} catch (e2: java.time.format.DateTimeParseException) {
null
}
}
return parsedDate != null && YearMonth.from(parsedDate) == current
}

mapOf(
Expand All @@ -1510,7 +1515,7 @@
}
}
suspend fun getFilariaMdaCampaignFromServer(): Int {
return withContext(Dispatchers.IO) {

Check warning on line 1518 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ5&open=AZ4c9keCcnmh5_MSchQ5&pullRequest=446
val user = preferenceDao.getLoggedInUser()
?: throw IllegalStateException("No user logged in!!")
try {
Expand Down Expand Up @@ -1588,7 +1593,7 @@


suspend fun saveMdaFilariaCampaignToServer(filariaMdaCache: FilariaMDACampaignFormResponseJsonEntity): Boolean {
return withContext(Dispatchers.IO) {

Check warning on line 1596 in app/src/main/java/org/piramalswasthya/sakhi/repositories/VLFRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4c9keCcnmh5_MSchQ6&open=AZ4c9keCcnmh5_MSchQ6&pullRequest=446
try {
val formDataJson = filariaMdaCache.formDataJson ?: ""
val formDataObj = try {
Expand Down