Skip to content

Commit

Permalink
Add ChallengeTargetType
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Nov 9, 2023
1 parent b9b8a84 commit feb7a69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ data class Challenge(
@SerialName("current_interval")
val currentInterval: Int?
) {
val targetType: ChallengeTargetType?
get() = ChallengeTargetType.getByValue(targetTypeValue)

val status: ChallengeStatus?
get() = ChallengeStatus.getByValue(statusValue)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ enum class ChallengeStatus(val value: String) {
fun getByValue(value: String): ChallengeStatus? =
VALUES.firstOrNull { it.value == value }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.hyperskill.app.challenges.domain.model

enum class ChallengeTargetType(val value: Int) {
TOPIC(2),
STEP(14),
PROJECT(29),
STAGE_ON_PRODUCTION(70),
STAGE_ON_RELEASE(71);
// Stage has different mapping on production and release
// https://vyahhi.myjetbrains.com/youtrack/issue/ALT-9537/Backend-Customisable-challenges#focus=Comments-74-265582.0-0

companion object {
private val VALUES: Array<ChallengeTargetType> = values()

fun getByValue(value: Int): ChallengeTargetType? =
VALUES.firstOrNull { it.value == value }
}
}

0 comments on commit feb7a69

Please sign in to comment.