Skip to content

Commit

Permalink
Merge pull request #70 from mash-up-kr/fix/status-decription
Browse files Browse the repository at this point in the history
fix: Update generated text logic
  • Loading branch information
210-reverof authored Aug 18, 2024
2 parents dd95727 + 06cbed7 commit c78a613
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController
class EventController(
private val eventApplicationService: EventApplicationService
) {
@Operation(summary = "이벤트 생성")
@Operation(summary = "이벤트 생성 (최초 이미지 업로드 포함)")
@PostMapping
fun createEvent(
@AuthenticationPrincipal user: UserInfo,
Expand All @@ -38,7 +38,7 @@ class EventController(
)
}

@Operation(summary = "이미지 업로드")
@Operation(summary = "이벤트 이미지 업로드")
@PostMapping("/images")
fun uploadImageOptions(
@AuthenticationPrincipal user: UserInfo,
Expand Down
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class RedisMessageListener(
when (ChannelTopic.from(eventInfo.topic)) {
ChannelTopic.EVENT_OPEN -> eventService.endEventUploading(eventInfo.eventId)
ChannelTopic.VOTE_OPEN -> {
eventService.endEventVoting(eventInfo.eventId)
resultService.generateResult(eventInfo.eventId)
eventService.endEventVoting(eventInfo.eventId)
}
}
}
Expand Down

0 comments on commit c78a613

Please sign in to comment.