-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WTA #71: Added separate classes for editor, language and os stats.
- Loading branch information
Showing
8 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...mmon/src/main/java/com/jacob/wakatimeapp/core/common/data/mappers/SecondaryStatsMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.jacob.wakatimeapp.core.common.data.mappers // ktlint-disable filename | ||
|
||
import com.jacob.wakatimeapp.core.common.data.dtos.EditorDTO | ||
import com.jacob.wakatimeapp.core.common.data.dtos.LanguageDTO | ||
import com.jacob.wakatimeapp.core.common.data.dtos.OperatingSystemDTO | ||
import com.jacob.wakatimeapp.core.models.Time | ||
import com.jacob.wakatimeapp.core.models.secondarystats.Editor | ||
import com.jacob.wakatimeapp.core.models.secondarystats.Language | ||
import com.jacob.wakatimeapp.core.models.secondarystats.OperatingSystem | ||
|
||
fun LanguageDTO.toModel() = Language( | ||
name = name, | ||
time = Time.fromDecimal(decimal.toFloat()), | ||
) | ||
|
||
fun EditorDTO.toModel() = Editor( | ||
name = name, | ||
time = Time.fromDecimal(decimal.toFloat()), | ||
) | ||
|
||
fun OperatingSystemDTO.toModel() = OperatingSystem( | ||
name = name, | ||
time = Time.fromDecimal(decimal.toFloat()), | ||
) |
14 changes: 14 additions & 0 deletions
14
core/models/src/main/java/com/jacob/wakatimeapp/core/models/secondarystats/Editor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.jacob.wakatimeapp.core.models.secondarystats | ||
|
||
import com.jacob.wakatimeapp.core.models.Time | ||
|
||
data class Editor(override val name: String, override val time: Time) : SecondaryStat | ||
|
||
data class Editors(override val values: List<Editor>) : SecondaryStats<Editor> { | ||
|
||
override fun plus(other: SecondaryStats<Editor>) = Editors(values + other.values) | ||
|
||
companion object { | ||
val NONE = Editors(emptyList()) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core/models/src/main/java/com/jacob/wakatimeapp/core/models/secondarystats/Language.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.jacob.wakatimeapp.core.models.secondarystats | ||
|
||
import com.jacob.wakatimeapp.core.models.Time | ||
|
||
data class Language(override val name: String, override val time: Time) : SecondaryStat | ||
|
||
data class Languages(override val values: List<Language>) : SecondaryStats<Language> { | ||
|
||
companion object { | ||
val NONE = Languages(emptyList()) | ||
} | ||
|
||
override fun plus(other: SecondaryStats<Language>) = Languages(values + other.values) | ||
} |
16 changes: 16 additions & 0 deletions
16
.../models/src/main/java/com/jacob/wakatimeapp/core/models/secondarystats/OperatingSystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.jacob.wakatimeapp.core.models.secondarystats | ||
|
||
import com.jacob.wakatimeapp.core.models.Time | ||
|
||
data class OperatingSystem(override val name: String, override val time: Time) : SecondaryStat | ||
|
||
data class OperatingSystems(override val values: List<OperatingSystem>) : | ||
SecondaryStats<OperatingSystem> { | ||
|
||
override fun plus(other: SecondaryStats<OperatingSystem>) = | ||
OperatingSystems(values + other.values) | ||
|
||
companion object { | ||
val NONE = OperatingSystems(emptyList()) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core/models/src/main/java/com/jacob/wakatimeapp/core/models/secondarystats/SecondaryStat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.jacob.wakatimeapp.core.models.secondarystats | ||
|
||
import com.jacob.wakatimeapp.core.models.Time | ||
|
||
interface SecondaryStat { | ||
val name: String | ||
val time: Time | ||
} | ||
|
||
interface SecondaryStats<T : SecondaryStat> { | ||
val values: Iterable<T> | ||
|
||
operator fun plus(other: SecondaryStats<T>): SecondaryStats<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
...s/src/main/java/com/jacob/wakatimeapp/details/domain/models/DetailedProjectStatsUiData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package com.jacob.wakatimeapp.details.domain.models | ||
|
||
import com.jacob.wakatimeapp.core.models.Time | ||
import com.jacob.wakatimeapp.core.models.secondarystats.Editors | ||
import com.jacob.wakatimeapp.core.models.secondarystats.Languages | ||
import com.jacob.wakatimeapp.core.models.secondarystats.OperatingSystems | ||
import kotlinx.datetime.LocalDate | ||
|
||
data class DetailedProjectStatsUiData( | ||
val totalProjectTime: TotalProjectTime, | ||
val averageTime: Time, | ||
val dailyProjectStats: Map<LocalDate, Time>, | ||
val languages: List<String>, | ||
val operatingSystems: List<String>, | ||
val editors: List<String>, | ||
val languages: Languages, | ||
val operatingSystems: OperatingSystems, | ||
val editors: Editors, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters