avoid commented practice chapters - fixes #2955
This commit is contained in:
parent
cd69cb17f0
commit
dd7aaf8aa4
|
@ -23,9 +23,9 @@ final class PracticeApi(
|
|||
def getStudyWithFirstOngoingChapter(user: Option[User], studyId: Study.Id): Fu[Option[UserStudy]] = for {
|
||||
up <- get(user)
|
||||
chapters <- studyApi.chapterMetadatas(studyId)
|
||||
chapterId = up.progress firstOngoingIn chapters.map(_.id)
|
||||
studyOption <- chapterId.fold(studyApi byIdWithFirstChapter studyId) {
|
||||
studyApi.byIdWithChapter(studyId, _)
|
||||
chapter = up.progress firstOngoingIn chapters
|
||||
studyOption <- chapter.fold(studyApi byIdWithFirstChapter studyId) { chapter =>
|
||||
studyApi.byIdWithChapter(studyId, chapter.id)
|
||||
}
|
||||
} yield makeUserStudy(studyOption, up, chapters)
|
||||
|
||||
|
|
|
@ -28,8 +28,12 @@ case class PracticeProgress(
|
|||
def countDone(chapterIds: List[Chapter.Id]): Int =
|
||||
chapterIds count chapters.contains
|
||||
|
||||
def firstOngoingIn(chapterIds: List[Chapter.Id]): Option[Chapter.Id] =
|
||||
chapterIds.find(c => !chapters.contains(c)) orElse chapterIds.headOption
|
||||
def firstOngoingIn(metas: List[Chapter.Metadata]): Option[Chapter.Metadata] =
|
||||
metas.find { c =>
|
||||
!chapters.contains(c.id) && !PracticeStructure.isChapterNameCommented(c.name)
|
||||
} orElse metas.find { c =>
|
||||
!PracticeStructure.isChapterNameCommented(c.name)
|
||||
}
|
||||
}
|
||||
|
||||
object PracticeProgress {
|
||||
|
|
Loading…
Reference in a new issue