-
Notifications
You must be signed in to change notification settings - Fork 18
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
create tracking channel message count feature module #151
create tracking channel message count feature module #151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review done.
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/tw/waterballsa/utopia/automaticchannelcommenttracking/domain/UsersMessageCount.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review done.
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
...aterballsa/utopia/automaticchannelcommenttracking/AutomaticChannelCommentTrackingListener.kt
Outdated
Show resolved
Hide resolved
private val TAIPEI_ZONE_ID: ZoneId = ZoneId.of("Asia/Taipei") | ||
private val DATE_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這兩個屬性有必要自己宣告型別嗎?
with(event) { | ||
incrementMessageCount(message) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有一行就直接 incrementMessageCount(event.message)
private fun incrementMessageCount(message: Message) { | ||
commentCountRepository.incrementCountByQuery(Query(message.toDate(), message.author.id, message.channel.id)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這邊 message
使用那麼多次就可以搭配 Scope Function 了
if (tag != BUFFER_COMMAND_TAG) { | ||
return | ||
} | ||
|
||
if (member.isAlphaMember().not()) { | ||
reply("你沒有權限").queue() | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
組成一個 when
|
||
|
||
companion object { | ||
private val jsonMapper = ObjectMapper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這邊依賴注入
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review done.
tag != BUFFER_COMMAND_TAG -> { | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用 lambda 展開,直接 return
if (member.isAlphaMember()) { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這是多餘的,前面有防呆了
val year = getOption(YEAR)?.asInt ?: return Query.IGNORE | ||
val month = getOption(MONTH)?.asInt ?: return Query.IGNORE | ||
val day = getOption(DAY)?.asInt ?: return Query.IGNORE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query.IGNORE 是個一眼就無法明白的寫法,Query.IGNORE 想要做什麼?
|
||
private fun getDate(year: Int, month: Int, day: Int): String { | ||
return try { | ||
LocalDate.of(year, month, day)?.format(DATE_FORMAT) ?: return Query.IGNORE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q:沒必要去 format 成字串吧?
while (true) { | ||
val history = getHistoryBefore(messageIterator, 100).complete().retrievedHistory.filterNotNull() | ||
messages.addAll(history) | ||
history.ifEmpty { return messages } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這是 while 條件式,那 while 外就應該宣告一個變數裝它
private fun TextChannel.getAllMessages(): List<Message> { | ||
val messages = mutableListOf<Message>(retrieveMessageById(latestMessageId).complete()) | ||
|
||
var messageIterator = latestMessageId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageIterator -> latestMessageId
#149
Why need this change? / Root cause:
Changes made:
Test Scope / Change impact: