Skip to content

Commit

Permalink
fix: change longest session record type to SessionRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeberrex committed Jul 14, 2024
1 parent 0db1e5e commit 9fbb7d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RecordAchievement(
when (params.recordType) {
RecordType.LONGEST_SESSION -> {
val session = records.longestSession
val elapsedTime = session?.let { differenceInMinutes(it.createdAt, it.endedAt) }
val elapsedTime = session?.let { differenceInMinutes(it.length) }
if ((elapsedTime ?: 0L) >= params.threshold.toLong()) {
emitter.emit(event.update.updated.name)
}
Expand Down Expand Up @@ -69,11 +69,6 @@ class RecordAchievement(
}
}

private fun differenceInMinutes(start: Date, end: Date?): Long {
if (end == null) return 0L

val differenceInMillis = end.time - start.time
return TimeUnit.MILLISECONDS.toMinutes(differenceInMillis)
private fun differenceInMinutes(millis: Long): Long {
return TimeUnit.MILLISECONDS.toMinutes(millis)
}


Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ data class PlayerStats(

data class PlayerRecords(
// var highestKillstreak: Int = 0, -- this can be calculated from profile
var longestSession: Session? = null,
var longestSession: SessionRecord? = null,
// var longestProjectileHit: ProjectileRecord? = null,
var longestProjectileKill: ProjectileRecord? = null,
var fastestWoolCapture: LongRecord? = null,
Expand All @@ -167,6 +167,8 @@ data class PlayerRecords(
var deathsInMatch: IntRecord? = null,
)

data class SessionRecord(val sessionId: String, val length: Long)

data class ProjectileRecord(val matchId: String, val distance: Int)

data class FirstBloodRecord(val matchId: String, val victim: SimplePlayer, val time: Long)
Expand Down

0 comments on commit 9fbb7d6

Please sign in to comment.