Skip to content

Commit

Permalink
ALTAPPS-582: Fix filter topics for current track
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Feb 8, 2023
1 parent de724ab commit 313b613
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ data class TopicProgress(
@SerialName("is_skipped")
val isSkipped: Boolean,
@SerialName("capacity")
val capacity: Float? = null
val capacity: Float? = null,
@SerialName("is_in_current_track")
val isInCurrentTrack: Boolean
)

val TopicProgress.completenessPercentage: Float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ class TopicsToDiscoverNextInteractor(
val topicsProgresses = topicsProgressesResult.await().getOrThrow()

val topicProgressById = topicsProgresses.associateBy { it.id }
val topicsWithProgresses = topics.map { it.copy(progress = topicProgressById[it.progressId]) }
val topicsWithCurrentTrackProgresses = topics
.map { it.copy(progress = topicProgressById[it.progressId]) }
.filter { it.progress?.isInCurrentTrack ?: false }

val topicsByStagePosition = topicsWithProgresses
val topicsByStagePosition = topicsWithCurrentTrackProgresses
.filter { it.progress?.stagePosition != null }
.groupBy { it.progress!!.stagePosition!! }

Expand All @@ -72,7 +74,7 @@ class TopicsToDiscoverNextInteractor(
.getValue(minStagePositionKey)
.take(TOPICS_TO_DISCOVER_NEXT_PREFIX_COUNT)
} else {
topicsWithProgresses.take(TOPICS_TO_DISCOVER_NEXT_PREFIX_COUNT)
topicsWithCurrentTrackProgresses.take(TOPICS_TO_DISCOVER_NEXT_PREFIX_COUNT)
}
}
}
Expand Down

0 comments on commit 313b613

Please sign in to comment.