-
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.
Merge pull request #70 from mash-up-kr/fix/status-decription
fix: Update generated text logic
- Loading branch information
Showing
3 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
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
21 changes: 12 additions & 9 deletions
21
pic-api/src/main/kotlin/com/mashup/pic/group/util/GroupViewStatusUtil.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,31 +1,34 @@ | ||
package com.mashup.pic.group.util | ||
|
||
import com.mashup.pic.domain.event.EventDto | ||
import com.mashup.pic.domain.event.EventStatus | ||
import java.time.LocalDateTime | ||
import java.time.temporal.ChronoUnit | ||
|
||
object GroupViewStatusUtil { | ||
private const val RECENT_UPDATE = "최근 업데이트가 없습니다." | ||
private const val VOTING_MESSAGE = "쉿, 투표 중" | ||
private const val PIC_ON_PROGRESS = "쉿 PIC하는 중" | ||
private const val DAYS_AGO_UPDATE = "%d일 전 업데이트" | ||
private const val WEEK_AGO_UPDATE = "일주일 전 업데이트" | ||
private const val TWO_WEEKS_AGO_UPDATE = "이주일 전 업데이트" | ||
private const val NO_RECENT_PIC = "최근 PIC이 없어요" | ||
|
||
fun generateDescription(event: EventDto?): String { | ||
return if (event != null) { | ||
val daysSinceUpdate = ChronoUnit.DAYS.between(event.date.toLocalDate(), LocalDateTime.now().toLocalDate()) | ||
fun generateDescription(lastEvent: EventDto?): String { | ||
if (lastEvent != null) { | ||
if (lastEvent.eventStatus != EventStatus.COMPLETE) { | ||
return PIC_ON_PROGRESS | ||
} | ||
|
||
val daysSinceUpdate = ChronoUnit.DAYS.between(lastEvent.date.toLocalDate(), LocalDateTime.now().toLocalDate()) | ||
|
||
when { | ||
return when { | ||
daysSinceUpdate in 1..6 -> DAYS_AGO_UPDATE.format(daysSinceUpdate) | ||
daysSinceUpdate == 7L -> WEEK_AGO_UPDATE | ||
daysSinceUpdate in 8..13 -> DAYS_AGO_UPDATE.format(daysSinceUpdate) | ||
daysSinceUpdate == 14L -> TWO_WEEKS_AGO_UPDATE | ||
daysSinceUpdate >= 15 -> NO_RECENT_PIC | ||
else -> RECENT_UPDATE | ||
else -> NO_RECENT_PIC | ||
} | ||
} else { | ||
VOTING_MESSAGE | ||
} | ||
return NO_RECENT_PIC | ||
} | ||
} |
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