Skip to content

Commit 7b60335

Browse files
committed
Add "Top Mastodon domains" in user statistics
This is mostly cut and paste from commit 3ac001b.
1 parent b4bd4d2 commit 7b60335

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

app/models/statistics/users.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,9 @@ def top_email_domains
109109
def top_xmpp_domains
110110
select_all "SELECT SUBSTRING_INDEX(jabber_id,'@', -1) AS domain, COUNT(*) AS cnt FROM accounts LEFT JOIN users ON accounts.user_id=users.id WHERE jabber_id LIKE '%@%' AND current_sign_in_at > DATE_SUB(CURDATE(),INTERVAL 90 DAY) AND role<>'inactive' GROUP BY domain HAVING cnt > 3 ORDER BY cnt DESC LIMIT 10;"
111111
end
112+
113+
def top_mastodon_domains
114+
# We assume Mastodon URLs will always start with "https://"
115+
select_all "SELECT SUBSTRING_INDEX(SUBSTRING(mastodon_url, 9),'/', 1) AS domain, COUNT(*) AS cnt FROM accounts LEFT JOIN users ON accounts.user_id=users.id WHERE mastodon_url LIKE 'https://%/%' AND current_sign_in_at > DATE_SUB(CURDATE(),INTERVAL 90 DAY) AND role<>'inactive' GROUP BY domain HAVING cnt > 3 ORDER BY cnt DESC LIMIT 10;"
116+
end
112117
end

app/views/statistics/users.html.haml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
%li= link_to("Informations personnelles", "#stats_infosperso")
2020
%li= link_to("Domaines des courriels", "#stats_courriel")
2121
%li= link_to("Domaines XMPP", "#stats_xmpp")
22+
%li= link_to("Domaines Mastodon", "#stats_mastodon")
2223
%li= link_to("Utilisation des fonctionnalités", "#stats_fonctionnalites")
2324
%li= link_to("Style (CSS)", "#stats_css")
2425
%li= link_to("Karmas des utilisatrices et utilisateurs", "#stats_karma")
@@ -252,6 +253,24 @@
252253
%td
253254
#{@stats.pctrecent(domain["cnt"])}
254255

256+
%h2#stats_mastodon Domaines Mastodon
257+
%p
258+
Sur #{pluralize @stats.nb_recently_used_accounts, "compte valide et utilisé", "comptes valides et utilisés"} au cours des trois derniers mois :
259+
%table
260+
- maxval = @stats.nb_recently_used_accounts
261+
%tr
262+
%th Domaines à plus de trois comptes
263+
%th Nombre de comptes
264+
%th Actifs
265+
- @stats.top_mastodon_domains.each do |domain|
266+
%tr
267+
%td.stat
268+
= domain["domain"]
269+
%td
270+
.stat.misc(style="width: #{(width_stats * domain["cnt"] / maxval).to_i}px;")= domain["cnt"]
271+
%td
272+
#{@stats.pctrecent(domain["cnt"])}
273+
255274
%h2#stats_fonctionnalites Utilisation des fonctionnalités
256275
%p
257276
Sur #{pluralize @stats.nb_recently_used_accounts, "compte valide et utilisé", "comptes valides"} au cours des trois derniers mois :

0 commit comments

Comments
 (0)