Skip to content

Commit 4977ff5

Browse files
committed
[BE-ReactionWatchTask] Add user's login to compare with reaction's owner login
1 parent 34cfa3e commit 4977ff5

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/main/scala/org/occidere/githubwatcher/service/GithubApiService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object GithubApiService {
2525
def getReactionsOfIssuesCreatedByUser: List[Reaction] = getBodies("issues", Map("per_page" -> "100", "filter" -> "created", "state" -> "all"))
2626
.map(x => MAPPER.convertValue(x + ("originDataType" -> ISSUE.toString), classOf[Reaction]))
2727

28-
def getReactionsOfCommentsInRepository(login: String, repo: String): List[Reaction] = getBodies(s"repos/$login/$repo/issues/comments")
28+
def getReactionsOfCommentsInRepository(repoOwnerLogin: String, repo: String)(login: String): List[Reaction] = getBodies(s"repos/$repoOwnerLogin/$repo/issues/comments")
2929
.map(x => MAPPER.convertValue(x + ("originDataType" -> COMMENT.toString), classOf[Reaction]))
3030
.filter(_.login == login)
3131

src/main/scala/org/occidere/githubwatcher/task/ReactionWatchTask.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object ReactionWatchTask extends Task with GithubWatcherLogger {
2222

2323
// Merge issues' reactions with fetched reactions from Repo
2424
val latestReactions = reactionsFromIssues.distinctBy(x => s"${x.repoOwnerLogin}/${x.repoName}".hashCode)
25-
.flatMap(x => GithubApiService.getReactionsOfCommentsInRepository(x.repoOwnerLogin, x.repoName)) ++ reactionsFromIssues
25+
.flatMap(x => GithubApiService.getReactionsOfCommentsInRepository(x.repoOwnerLogin, x.repoName)(userId)) ++ reactionsFromIssues
2626

2727
// Data from DB (Elasticsearch)
2828
val prevReactions = ElasticService.findAllReactionsByLogin(userId).map(x => x.uniqueKey -> x).toMap

src/test/scala/org/occidere/githubwatcher/service/GithubApiServiceTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class GithubApiServiceTest extends AnyFlatSpec with PrivateMethodTester with sho
6565
}
6666

6767
"getReactionsOfCommentsInRepository" should "return nonNull List of Reactions" in {
68-
val reactions = githubApiService.getReactionsOfCommentsInRepository("YoungStudyShopping", "leetcode_study")
68+
val reactions = githubApiService.getReactionsOfCommentsInRepository("YoungStudyShopping", "leetcode_study")("occidere")
6969

7070
println(reactions.size)
7171
println(reactions.find(_.totalCount > 0).orNull)

0 commit comments

Comments
 (0)