Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qa/20 29 31 39 통계 관련 수정사항 #140

Merged
merged 4 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ class StatisticsRepositoryImpl @Inject constructor(
) : StatisticsRepository {
override suspend fun getMyStatistics(): MyStatistics {
val originalStatistic = statisticsService.getMyStatistics().getOrThrow().toModel()
val sortedRecentSpent = originalStatistic.recentSpent.sortedBy { it.title.toInt() }
.map { StatisticsElement(title = it.title.substring(it.title.length - 2).toInt().toString(), value = it.value) }
val sortedRecentSpent = originalStatistic.recentSpent
.filter {
currentYear == it.title.substring(0 until 4).toInt()
}
.map {
StatisticsElement(
title = it.title.substring(it.title.length - 2).toInt().toString(),
value = it.value / 10000,
)
}
.sortedBy { it.title.toInt() }

return MyStatistics(
highestAmountReceived = originalStatistic.highestAmountReceived,
Expand All @@ -23,8 +32,8 @@ class StatisticsRepositoryImpl @Inject constructor(
mostRelationship = originalStatistic.mostRelationship,
mostSpentMonth = originalStatistic.mostSpentMonth % 100,
recentSpent = sortedRecentSpent,
recentTotalSpent = originalStatistic.recentTotalSpent,
recentMaximumSpent = originalStatistic.recentMaximumSpent,
recentTotalSpent = sortedRecentSpent.sumOf { it.value },
recentMaximumSpent = sortedRecentSpent.maxOfOrNull { it.value } ?: 0,
)
}

Expand All @@ -34,8 +43,17 @@ class StatisticsRepositoryImpl @Inject constructor(
relationshipId = relationshipId,
categoryId = categoryId,
).getOrThrow().toModel()
val sortedRecentSpent = originalStatistic.recentSpent.sortedBy { it.title.toInt() }
.map { StatisticsElement(title = it.title.substring(it.title.length - 2).toInt().toString(), value = it.value) }
val sortedRecentSpent = originalStatistic.recentSpent
.filter {
currentYear == it.title.substring(0 until 4).toInt()
}
.map {
StatisticsElement(
title = it.title.substring(it.title.length - 2).toInt().toString(),
value = it.value / 10000,
)
}
.sortedBy { it.title.toInt() }

return SusuStatistics(
averageSent = originalStatistic.averageSent,
Expand All @@ -45,8 +63,12 @@ class StatisticsRepositoryImpl @Inject constructor(
mostSpentMonth = originalStatistic.mostSpentMonth % 100,
mostRelationship = originalStatistic.mostRelationship,
mostCategory = originalStatistic.mostCategory,
recentTotalSpent = originalStatistic.recentTotalSpent,
recentMaximumSpent = originalStatistic.recentMaximumSpent,
recentTotalSpent = sortedRecentSpent.sumOf { it.value },
recentMaximumSpent = sortedRecentSpent.maxOfOrNull { it.value } ?: 0,
)
}

companion object {
private val currentYear = java.time.LocalDate.now().year
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ fun RecentSpentGraph(
number = totalAmount,
style = SusuTheme.typography.title_xs,
color = Blue60,
prefix = stringResource(id = R.string.statistics_total_man_prefix),
postfix = stringResource(id = R.string.statistics_total_man_postfix),
)
} else {
Text(
text = stringResource(R.string.statistics_total_man_format, stringResource(R.string.word_unknown)),
text = stringResource(R.string.statistics_man_format, stringResource(R.string.word_unknown)),
style = SusuTheme.typography.title_xs,
color = Gray40,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
Expand Down Expand Up @@ -133,6 +134,7 @@ fun MyStatisticsContent(
money = uiState.statistics.highestAmountSent.value,
isActive = !isBlind,
)
Spacer(modifier = Modifier.height(SusuTheme.spacing.spacing_xxxl))
}

if (uiState.isLoading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
Expand Down Expand Up @@ -184,6 +185,7 @@ fun SusuStatisticsScreen(
isActive = !isBlind,
)
}
Spacer(modifier = Modifier.height(SusuTheme.spacing.spacing_xxxl))
}

if (uiState.isAgeSheetOpen) {
Expand Down
2 changes: 1 addition & 1 deletion feature/statistics/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="statistics_recent_8_total_money">최근 8개월 간 쓴 금액</string>
<string name="statistics_total_man_format">총 %s만원</string>
<string name="statistics_man_format">%s만원</string>
<string name="statistics_total_man_prefix">총 </string>
<string name="statistics_total_man_postfix">만원</string>
<string name="statistics_tab_my">나의 수수</string>
Expand Down
Loading