Skip to content

Commit

Permalink
Cleanup condition logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
sufyanAbbasi committed Feb 26, 2024
1 parent 899a15e commit 5ec779b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.google.android.ground.model.task

import timber.log.Timber

/** The task ID. */
typealias TaskId = String
/** The selected option ID for each task. */
Expand Down Expand Up @@ -47,7 +45,6 @@ constructor(

/** Given the user's task selections, determine whether the condition is fulfilled. */
fun fulfilledBy(taskSelections: TaskSelections): Boolean {
Timber.v("taskSelections: %s", taskSelections)
return when (matchType) {
MatchType.MATCH_ANY -> expressions.any { it.fulfilledBy(taskSelections) }
MatchType.MATCH_ALL -> expressions.all { it.fulfilledBy(taskSelections) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ internal object ConditionConverter {
} else if (it.taskId == null) {
Timber.e("Empty task ID encountered, skipping expression.")
null
} else if (it.optionIds == null) {
Timber.e("Empty option IDs encountered, skipping expression.")
null
} else {
Expression(
expressionType = expressionType,
taskId = it.taskId,
optionIds = it.optionIds.toSet(),
optionIds = it.optionIds?.toSet() ?: setOf(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ internal object TaskConverter {
// Default index to -1 to degrade gracefully on older dev db instances and surveys.
val multipleChoice: MultipleChoice? =
if (type == Task.Type.MULTIPLE_CHOICE) toMultipleChoice(em) else null
Timber.v("task condition: ", em.condition)
return Task(
id,
em.index ?: -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ class DataCollectionViewModel
tasks.subList(startIndex, tasks.size)
}.let { tasks ->
tasks.asSequence().filter {
Timber.v("condition: %s", it.condition)
it.condition == null || evaluateCondition(it.condition)
}
}
Expand All @@ -216,17 +215,11 @@ class DataCollectionViewModel
/** Displays the task at the relative position to the current one. Supports negative steps. */
fun step(stepCount: Int) {
val reverse = stepCount < 0
Timber.v(
"current: %s, reverse: %s, tasks: %s",
currentTaskId.value,
reverse,
tasks.map { it.id })
val task = getTaskSequence(
startId = currentTaskId.value,
preceding = reverse
).take(Math.abs(stepCount) + 1).last()
savedStateHandle[TASK_POSITION_ID] = task.id
Timber.v("next: %s", task.id)
}

/** Returns true if the given task index is last if set, or the current active task. */
Expand Down

0 comments on commit 5ec779b

Please sign in to comment.