back interdiff of round #2 and #1

show handles of users that reacted to issues and pulls #636

merged
opened by camsmith.dev targeting master from camsmith.dev/core: feat/user-reaction-handles

Displays the handles of users that reacted on issues and pulls, in addition to the counts. Closes https://tangled.org/@tangled.org/core/issues/246

There's a couple ways to do it

  1. Doing the db query in 1 roundtrip -- that's what I did here
  2. Doing 2 db queries, 1 for the count and 1 for the usernames

If we prefer (2), or another route, that's fine, I can change it.

files
appview
db
issues
models
pages
templates
repo
fragments
issues
pulls
fragments
pulls
state
ERROR
appview/db/reaction.go

Failed to calculate interdiff for this file.

ERROR
appview/issues/issues.go

Failed to calculate interdiff for this file.

ERROR
appview/models/reaction.go

Failed to calculate interdiff for this file.

ERROR
appview/pages/pages.go

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/repo/fragments/reaction.html

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/repo/issues/issue.html

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/repo/pulls/fragments/pullHeader.html

Failed to calculate interdiff for this file.

ERROR
appview/pulls/pulls.go

Failed to calculate interdiff for this file.

NEW
appview/state/reaction.go
···
return
}
-
count, err := db.GetReactionCount(s.db, subjectUri, reactionKind)
+
reactionMap, err := db.GetReactionMap(s.db, 20, subjectUri)
if err != nil {
-
log.Println("failed to get reaction count for ", subjectUri)
+
log.Println("failed to get reactions for ", subjectUri)
}
log.Println("created atproto record: ", resp.Uri)
···
s.pages.ThreadReactionFragment(w, pages.ThreadReactionFragmentParams{
ThreadAt: subjectUri,
Kind: reactionKind,
-
Count: count,
+
Count: reactionMap[reactionKind].Count,
+
Users: reactionMap[reactionKind].Users,
IsReacted: true,
})
···
// this is not an issue, the firehose event might have already done this
}
-
count, err := db.GetReactionCount(s.db, subjectUri, reactionKind)
+
reactionMap, err := db.GetReactionMap(s.db, 20, subjectUri)
if err != nil {
-
log.Println("failed to get reaction count for ", subjectUri)
+
log.Println("failed to get reactions for ", subjectUri)
return
}
s.pages.ThreadReactionFragment(w, pages.ThreadReactionFragmentParams{
ThreadAt: subjectUri,
Kind: reactionKind,
-
Count: count,
+
Count: reactionMap[reactionKind].Count,
+
Users: reactionMap[reactionKind].Users,
IsReacted: false,
})