Skip to content

Commit 902ccb0

Browse files
committed
Updating the scores number formatter to not include decimals
1 parent 4e07198 commit 902ccb0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Horizon/Horizon/Sources/Features/Learn/Scores/Domain/ScoresInteractor.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import Combine
2020
import Core
21+
import Foundation
2122

2223
protocol ScoresInteractor {
2324
var courseID: String { get }
@@ -103,8 +104,8 @@ final class ScoresInteractorLive: ScoresInteractor {
103104

104105
private func scoreGradeString(enrollment: ScoresCourseEnrollment) -> String? {
105106
var scoreString: String?
106-
if let score = enrollment.score,
107-
let formattedScore = GradeFormatter.numberFormatter.string(
107+
let score = 36.52341
108+
if let formattedScore = GradeFormatter.horizonNumberFormatter.string(
108109
from: GradeFormatter.truncate(score)
109110
) {
110111
scoreString = "\(formattedScore)%"
@@ -121,3 +122,14 @@ final class ScoresInteractorLive: ScoresInteractor {
121122
return scoreGradesString.isEmpty ? nil : scoreGradesString
122123
}
123124
}
125+
126+
extension GradeFormatter {
127+
public static let horizonNumberFormatter: NumberFormatter = {
128+
let formatter = NumberFormatter()
129+
formatter.locale = Locale.current
130+
formatter.maximumFractionDigits = 0
131+
formatter.minimumFractionDigits = 0
132+
formatter.numberStyle = .decimal
133+
return formatter
134+
}()
135+
}

0 commit comments

Comments
 (0)