···6060// GetMostFollowed returns the DIDs with the most followers, most-followed first.
6161func GetMostFollowed(e Execer, limit int) ([]string, error) {
6262 query := `
6363- select subject_did, count(*) as followers
6363+ select subject_did, count(distinct did) as followers
6464 from follows
6565 group by subject_did
6666 order by followers desc
···8888 var followers, following int64
8989 err := e.QueryRow(
9090 `SELECT
9191- COUNT(CASE WHEN subject_did = ? THEN 1 END) AS followers,
9292- COUNT(CASE WHEN did = ? THEN 1 END) AS following
9191+ COUNT(DISTINCT CASE WHEN subject_did = ? THEN did END) AS followers,
9292+ COUNT(DISTINCT CASE WHEN did = ? THEN subject_did END) AS following
9393 FROM follows;`, did, did).Scan(&followers, &following)
9494 if err != nil {
9595 return models.FollowStats{}, err
···123123 coalesce(f.followers, 0) as followers,
124124 coalesce(g.following, 0) as following
125125 from (
126126- select subject_did as did, count(*) as followers
126126+ select subject_did as did, count(distinct did) as followers
127127 from follows
128128 where subject_did in (%s)
129129 group by subject_did
130130 ) f
131131 full outer join (
132132- select did as did, count(*) as following
132132+ select did as did, count(distinct subject_did) as following
133133 from follows
134134 where did in (%s)
135135 group by did