Duplication related changes offline data testing, removed unwanted code
This commit is contained in:
@@ -22,7 +22,6 @@ import com.example.hpostesting.data.Result
|
|||||||
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
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.LoginRequest
|
||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
|
||||||
@@ -147,19 +146,12 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { originalUserDataList ->
|
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())
|
val resultList = MolbioV2ResultRequest(mutableListOf())
|
||||||
|
originalUserDataList.forEach { userData ->
|
||||||
|
Log.d(
|
||||||
userDataList.forEach { userData ->
|
": USER DATA",
|
||||||
// Ensure we process each user only once
|
originalUserDataList.count().toString() + " : " + userData._id
|
||||||
// if (!processedUserIds.contains(userData._id)) {
|
)
|
||||||
Log.d(": USER DATA", userDataList.count().toString() + " : " + userData._id)
|
|
||||||
|
|
||||||
|
|
||||||
if (!userData.molbioFlag && isTokenAvailable && Constants.MOLBIO_INTEGRATION) {
|
if (!userData.molbioFlag && isTokenAvailable && Constants.MOLBIO_INTEGRATION) {
|
||||||
val currentTimeFormatted = SimpleDateFormat(
|
val currentTimeFormatted = SimpleDateFormat(
|
||||||
@@ -185,23 +177,10 @@ class HomeFragment : Fragment() {
|
|||||||
expiryTime = currentTimeFormatted
|
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())
|
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 ->
|
resultList.results?.forEach { result ->
|
||||||
val userData = result.rawData
|
val userData = result.rawData
|
||||||
Log.d("UserData", userData.toString())
|
Log.d("UserData", userData.toString())
|
||||||
|
|||||||
Reference in New Issue
Block a user