···
log.Printf("getting profile data for %s: %s", did, err)
64
-
followersCount, followingCount, err := db.GetFollowerFollowingCount(s.db, did)
64
+
followStats, err := db.GetFollowerFollowingCount(s.db, did)
log.Printf("getting follow stats for %s: %s", did, err)
···
UserHandle: ident.Handle.String(),
FollowStatus: followStatus,
83
-
FollowersCount: followersCount,
84
-
FollowingCount: followingCount,
83
+
FollowersCount: followStats.Followers,
84
+
FollowingCount: followStats.Following,
···
215
+
loggedInUser := pageWithProfile.LoggedInUser
follows, err := fetchFollows(s.db, id.DID.String())
···
223
+
return &FollowsPageParams{
224
+
LoggedInUser: loggedInUser,
225
+
Follows: []pages.FollowCard{},
226
+
Card: pageWithProfile.Card,
followDids := make([]string, 0, len(follows))
···
profiles, err := db.GetProfiles(s.db, db.FilterIn("did", followDids))
log.Printf("getting profile for %s: %s", followDids, err)
236
-
loggedInUser := pageWithProfile.LoggedInUser
240
+
followStatsMap, err := db.GetFollowerFollowingCounts(s.db, followDids)
242
+
log.Printf("getting follow counts for %s: %s", followDids, err)
var loggedInUserFollowing map[string]struct{}
following, err := db.GetFollowing(s.db, loggedInUser.Did)
···
followCards := make([]pages.FollowCard, 0, len(follows))
for _, did := range followDids {
253
-
followersCount, followingCount, err := db.GetFollowerFollowingCount(s.db, did)
255
-
log.Printf("getting follow stats for %s: %s", did, err)
261
+
followStats, exists := followStatsMap[did]
263
+
followStats = db.FollowStats{}
followStatus := db.IsNotFollowing
if loggedInUserFollowing != nil {
···
followCards = append(followCards, pages.FollowCard{
FollowStatus: followStatus,
275
-
FollowersCount: followersCount,
276
-
FollowingCount: followingCount,
283
+
FollowersCount: followStats.Followers,
284
+
FollowingCount: followStats.Following,
···
func (s *State) followersPage(w http.ResponseWriter, r *http.Request) {
followPage := s.followPage(w, r, db.GetFollowers, func(f db.Follow) string { return f.UserDid })
298
+
if followPage == nil {
s.pages.FollowersPage(w, pages.FollowersPageParams{
LoggedInUser: followPage.LoggedInUser,
···
func (s *State) followingPage(w http.ResponseWriter, r *http.Request) {
followPage := s.followPage(w, r, db.GetFollowing, func(f db.Follow) string { return f.SubjectDid })
311
+
if followPage == nil {
s.pages.FollowingPage(w, pages.FollowingPageParams{
LoggedInUser: followPage.LoggedInUser,