Skip to content

Commit 9996d3f

Browse files
authored
release: 1.5.6 (#168)
2 parents 87f8fe2 + 10825e3 commit 9996d3f

File tree

7 files changed

+82
-6
lines changed

7 files changed

+82
-6
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Get rank
2+
3+
type에 해당하는 랭킹의 카운트를 응답합니다.
4+
5+
## Request
6+
### Http method: `GET`
7+
### URL: `https://render.gitanimals.org/ranks/total`
8+
### Parameter
9+
- type: WEEKLY_GUILD_CONTRIBUTIONS, WEEKLY_USER_CONTRIBUTIONS // 조회할 랭크의 타입을 입력합니다.
10+
11+
## Response
12+
13+
```json
14+
{
15+
"count": 1999
16+
}
17+
```

src/main/kotlin/org/gitanimals/core/redis/RedisPubSubChannel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ object RedisPubSubChannel {
99
const val SLACK_REPLIED = "SLACK_REPLIED"
1010

1111
const val DEAD_LETTER_OCCURRED = "DEAD_LETTER_OCCURRED"
12+
13+
const val NEW_PET_DROP_RATE_DISTRIBUTION = "NEW_PET_DROP_RATE_DISTRIBUTION"
1214
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.gitanimals.notification.app
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper
4+
import org.gitanimals.core.redis.TraceableMessageListener
5+
import org.gitanimals.notification.app.event.NewPetDropRateDistributionEvent
6+
import org.gitanimals.notification.domain.Notification
7+
import org.slf4j.LoggerFactory
8+
import org.springframework.beans.factory.annotation.Qualifier
9+
import org.springframework.data.redis.connection.Message
10+
import org.springframework.data.redis.core.StringRedisTemplate
11+
import org.springframework.stereotype.Component
12+
13+
@Component
14+
class NewPetDropRateDistributionMessageListener(
15+
private val redisTemplate: StringRedisTemplate,
16+
private val objectMapper: ObjectMapper,
17+
@Qualifier("gitAnimalsReportSlackNotification") private val dailyReportSlackNotification: Notification,
18+
) : TraceableMessageListener(redisTemplate, objectMapper) {
19+
20+
private val logger = LoggerFactory.getLogger(this::class.simpleName)
21+
22+
override fun onMessage(message: Message) {
23+
runCatching {
24+
val newPetDropRateDistributionEvent = objectMapper.readValue(
25+
redisTemplate.stringSerializer.deserialize(message.body),
26+
NewPetDropRateDistributionEvent::class.java,
27+
)
28+
29+
dailyReportSlackNotification.notify(
30+
message = """
31+
:pepe: *${newPetDropRateDistributionEvent.type} drop rate distribution reports* :pepe:
32+
${
33+
newPetDropRateDistributionEvent.distributions.sortedBy { it.dropRate }
34+
.joinToString("\n") { "- ${it.dropRate}: ${it.count}" }
35+
}
36+
""".trimIndent()
37+
)
38+
}.onFailure {
39+
logger.error("[NewPetDropRateDistributionMessageListener] Fail to notify dropRate message: $message", it)
40+
}
41+
}
42+
}
43+

src/main/kotlin/org/gitanimals/notification/app/SlackNotificationHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import org.springframework.beans.factory.annotation.Qualifier
1313
@SagaHandler
1414
class SlackNotificationHandler(
1515
@Qualifier("gitAnimalsNewUserSlackNotification") private val newUserSlackNotification: Notification,
16-
@Qualifier("gitAnimalsDailyReportSlackNotification") private val dailyReportSlackNotification: Notification,
16+
@Qualifier("gitAnimalsReportSlackNotification") private val dailyReportSlackNotification: Notification,
1717
) {
1818

1919
@SagaStartListener(event = NewUserCreated::class, successWith = SuccessWith.END)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.gitanimals.notification.app.event
2+
3+
data class NewPetDropRateDistributionEvent(
4+
val traceId: Long,
5+
val type: String,
6+
val distributions: List<Distribution>,
7+
) {
8+
data class Distribution(
9+
val dropRate: Double,
10+
val count: Int,
11+
)
12+
}

src/main/kotlin/org/gitanimals/notification/infra/RedisMessageListenerConfiguration.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package org.gitanimals.notification.infra
22

33
import org.gitanimals.core.redis.RedisPubSubChannel
4-
import org.gitanimals.notification.app.NotApprovedQuizCreatedMessageListener
5-
import org.gitanimals.notification.app.QuizCreatedMessageListener
6-
import org.gitanimals.notification.app.SlackDeadLetterMessageListener
7-
import org.gitanimals.notification.app.SlackRepliedMessageListener
4+
import org.gitanimals.notification.app.*
85
import org.springframework.context.annotation.Bean
96
import org.springframework.context.annotation.Configuration
107
import org.springframework.data.redis.connection.RedisConnectionFactory
@@ -18,6 +15,7 @@ class RedisMessageListenerConfiguration(
1815
private val notApprovedQuizCreatedMessageListener: NotApprovedQuizCreatedMessageListener,
1916
private val slackRepliedMessageListener: SlackRepliedMessageListener,
2017
private val slackDeadLetterMessageListener: SlackDeadLetterMessageListener,
18+
private val newPetDropRateDistributionMessageListener: NewPetDropRateDistributionMessageListener,
2119
) {
2220

2321
@Bean
@@ -40,6 +38,10 @@ class RedisMessageListenerConfiguration(
4038
slackDeadLetterMessageListener,
4139
ChannelTopic(RedisPubSubChannel.DEAD_LETTER_OCCURRED),
4240
)
41+
this.addMessageListener(
42+
newPetDropRateDistributionMessageListener,
43+
ChannelTopic(RedisPubSubChannel.NEW_PET_DROP_RATE_DISTRIBUTION)
44+
)
4345
}
4446
}
4547
}

src/main/kotlin/org/gitanimals/notification/infra/SlackNotifiactions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class GitAnimalsNewUserSlackNotification(
8181
) : SlackNotification(token, "C079NJ6PVBQ", objectMapper)
8282

8383
@Component
84-
class GitAnimalsDailyReportSlackNotification(
84+
class GitAnimalsReportSlackNotification(
8585
objectMapper: ObjectMapper,
8686
@Value(value = "\${slack.token}") token: String,
8787
) : SlackNotification(token, "C07BPB42R8D", objectMapper)

0 commit comments

Comments
 (0)