diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt index c93b5ef..4368a7f 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt @@ -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())