Skip to content

Commit

Permalink
fix: [ANDROAPP-6398] Tei dashbard takes too long to load if option se…
Browse files Browse the repository at this point in the history
…t is too big

Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan authored and andresmr committed Nov 13, 2024
1 parent 0dfdaee commit a49d92c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {
return FragmentTeiDataBinding.inflate(inflater, container, false).also { binding ->
this.binding = binding
dashboardViewModel.groupByStage.observe(viewLifecycleOwner) { group ->
showLoadingProgress(false)
showLoadingProgress(true)
presenter.onGroupingChanged(group)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class TeiDataRepositoryImpl(
override fun displayOrganisationUnit(programUid: String): Boolean {
return d2.organisationUnitModule().organisationUnits()
.byProgramUids(listOf(programUid))
.blockingGet().size > 1
.blockingCount() > 1
}

override fun enrollmentOrgUnitInCaptureScope(enrollmentOrgUnit: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fun List<ProgramRuleVariable>.toRuleVariableList(
dataElementRepository: DataElementCollectionRepository,
optionRepository: OptionCollectionRepository,
): List<RuleVariable> {
return filter {
when {
return mapNotNull {
val allowVariable = when {
it.dataElement() != null -> {
dataElementRepository.uid(it.dataElement()?.uid()).blockingExists()
}
Expand All @@ -75,8 +75,11 @@ fun List<ProgramRuleVariable>.toRuleVariableList(

else -> isCalculatedValue(it)
}
}.map {
it.toRuleVariable(attributeRepository, dataElementRepository, optionRepository)
if (allowVariable) {
it.toRuleVariable(attributeRepository, dataElementRepository, optionRepository)
} else {
null
}
}
}

Expand Down Expand Up @@ -348,14 +351,7 @@ fun ProgramRuleVariable.toRuleVariable(
}

val useCodeForOptionSet = useCodeForOptionSet() ?: false
val options = getOptions(
useCodeForOptionSet,
dataElement()?.uid(),
trackedEntityAttribute()?.uid(),
attributeRepository,
dataElementRepository,
optionRepository,
)
val options = emptyList<Option>()

return when (programRuleVariableSourceType()) {
ProgramRuleVariableSourceType.CALCULATED_VALUE ->
Expand Down

0 comments on commit a49d92c

Please sign in to comment.