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

Fix/get all reacted users #18

Merged
merged 14 commits into from
Mar 21, 2023
Merged

Fix/get all reacted users #18

merged 14 commits into from
Mar 21, 2023

Conversation

sho0126hiro
Copy link
Member

Overview

  • When more than 50 people had the same reaction (same skin tone) to a message, the conversation reply API we are using now was not able to get all reaction data.
  • I solved this problem.

Changes

  • I allowed ListUsersEmailByReaction to judge whether it has to use reactions.get API for fetching full reactions and to fetch all reactions as necessary before filtering reacted users using getReactionUserIDs.
  • I added a field to model.SlackReaction to allow this determine.
  • Testings were added.

Operation check

  • I confirmed that the bot has no problem on dev environment.

@sho0126hiro sho0126hiro self-assigned this Mar 18, 2023
Copy link
Contributor

@hotakahattori hotakahattori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

少しコメントしました。

そもそもなんだけど、この処理は GetParentMessage の中でやっても良いかなと思うんだけど、どう思う?
ドメインとしては不完全な message 受け取っても仕方ないし、API の仕様気にしてそれの refetch とかドメインで考えたくない気もする。

Comment on lines 115 to 117
func (s *slackReactionUsersService) getFullReactions(ctx context.Context, channelID, ts string) ([]*model.SlackReaction, error) {
return s.slackRepository.GetReactions(ctx, channelID, ts, true)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この処理 func に切り出すほどの処理だった?

Copy link
Member Author

@sho0126hiro sho0126hiro Mar 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trueを直で引数に指定するのが、マジックナンバーみたいに見えるから関数に切り出した感じ(意味がわかるように)。
どっちでも良いとは思ってるけどどうでしょう?

Copy link
Member Author

@sho0126hiro sho0126hiro Mar 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここでture直書きにしておきました
fix implementation

return reactedUserEmails, nil
}

// isReactionRefetchNeeded returns true if more fetches is required
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どういう時に refetch が必要なのか、軽くコメント入れておいてくれると助かる。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとう!入れておきました
add comment

Comment on lines 99 to 100
UserIDs: []string{"user02", "user03"},
Count: 4, // number of counts that need to be re-fetched
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これって len(UserIDs) > Count のパターンってありえないんだっけ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありえないと思う。APIドキュメントには明示されていなかったけど、実データとして確認しているのは
len(UserIDs) =< Count の時だけかな。
判定部分が != になっていたから、判定部を修正しておきました

fix condition

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 fix implementationisIncompleteReactionにロジックを移したので、ここのコメントと判定部を修正しておきました

@sho0126hiro
Copy link
Member Author

sho0126hiro commented Mar 19, 2023

そもそもなんだけど、この処理は GetParentMessage の中でやっても良いかなと思うんだけど、どう思う?
ドメインとしては不完全な message 受け取っても仕方ないし、API の仕様気にしてそれの refetch とかドメインで考えたくない気もする。

@hotakahattori repository層、まだテスト全然書けていないから、serviceに載せて保護しようかなと思ったけど、確かにそんな気がする。修正しました
fix implementation

Copy link
Contributor

@hotakahattori hotakahattori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

少しコメントしたけど、approve しておきます!

Comment on lines 70 to 71
}
for _, reaction := range parentMessage.Reactions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

変数宣言と使用箇所が無駄に離れてる

Suggested change
}
for _, reaction := range parentMessage.Reactions {
}
var reactions []*model.SlackReaction
for _, reaction := range parentMessage.Reactions {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応しておきました move reactions(var)

@@ -18,7 +18,8 @@ package repository

import (
"context"
"fmt"

slack2 "github.com/slack-go/slack"

"github.com/moneyforward/auriga/app/pkg/slack"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こっち pkgslack とかにしとく?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sho0126hiro
Copy link
Member Author

直したのでマージします

@sho0126hiro sho0126hiro merged commit 0afc4cb into develop Mar 21, 2023
@sho0126hiro sho0126hiro mentioned this pull request Mar 21, 2023
@sho0126hiro sho0126hiro deleted the fix/get_all_reacted_users branch December 13, 2023 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants