Duplication related changes offline data testing, removed unwanted code

This commit is contained in:
Mariya
2024-02-24 18:27:01 +05:30
parent 41a66766d1
commit a97fd86c86

View File

@@ -22,7 +22,6 @@ import com.example.hpostesting.data.Result
import com.example.hpostesting.data.api.DeviceCommunicationHandler
import com.example.hpostesting.data.constant.Constants
import com.example.hpostesting.data.constant.HemoCubeCommands
import com.example.hpostesting.data.encryption.AESCrypt.decrypt
import com.example.hpostesting.data.model.login.LoginRequest
import com.example.hpostesting.data.model.login.LoginResponse
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
@@ -147,19 +146,12 @@ class HomeFragment : Fragment() {
}
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { originalUserDataList ->
// Ensure the list does not contain duplicates based on _id
//val userDataList = originalUserDataList.distinctBy { it.testTime }
val userDataList = originalUserDataList
// Initialize the resultList outside of the loop to avoid duplicates
val resultList = MolbioV2ResultRequest(mutableListOf())
userDataList.forEach { userData ->
// Ensure we process each user only once
// if (!processedUserIds.contains(userData._id)) {
Log.d(": USER DATA", userDataList.count().toString() + " : " + userData._id)
originalUserDataList.forEach { userData ->
Log.d(
": USER DATA",
originalUserDataList.count().toString() + " : " + userData._id
)
if (!userData.molbioFlag && isTokenAvailable && Constants.MOLBIO_INTEGRATION) {
val currentTimeFormatted = SimpleDateFormat(
@@ -185,23 +177,10 @@ class HomeFragment : Fragment() {
expiryTime = currentTimeFormatted
)
)
// Mark this userData as processed to avoid re-processing
// processedUserIds.add(userData.testTime.toString())
// if (!userData.localFlag) {
// hemoCubeViewModel.bulkAddResultTestToDb(userData)
// userData.localFlag = true
// }
}
// Mark the userData for localFlag update, this will be handled in bulk after the loop
// }
}
Log.d("USER DATA LIST SIZE", resultList.results?.count().toString())
// Perform bulk operations after the loop
// Set localFlag to true for all usersToUpdate and perform bulk database upd
resultList.results?.forEach { result ->
val userData = result.rawData
Log.d("UserData", userData.toString())