Skip to content

Commit

Permalink
Top XMPP domains in stats
Browse files Browse the repository at this point in the history
Fix #2048 Statistiques sur les domaines XMPP
  • Loading branch information
Oumph committed Jan 3, 2023
1 parent 2e62220 commit 3ac001b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/statistics/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ def by_state
def top_email_domains
select_all "SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(email,'@', -1),'.',1) AS domain, COUNT(*) AS cnt FROM accounts WHERE 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;"
end

def top_xmpp_domains
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;"
end
end
19 changes: 19 additions & 0 deletions app/views/statistics/users.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
%li= link_to("Étiquettes (tags)", "#stats_tags")
%li= link_to("Informations personnelles", "#stats_infosperso")
%li= link_to("Domaines des courriels", "#stats_courriel")
%li= link_to("Domaines XMPP", "#stats_xmpp")
%li= link_to("Utilisation des fonctionnalités", "#stats_fonctionnalites")
%li= link_to("Style (CSS)", "#stats_css")
%li= link_to("Karmas des utilisatrices et utilisateurs", "#stats_karma")
Expand Down Expand Up @@ -233,6 +234,24 @@
%td
#{@stats.pctrecent(domain["cnt"])}

%h2#stats_xmpp Domaines XMPP
%p
Sur #{pluralize @stats.nb_recently_used_accounts, "compte valide et utilisé", "comptes valides et utilisés"} au cours des trois derniers mois :
%table
- maxval = @stats.nb_recently_used_accounts
%tr
%th Domaines à plus de trois comptes
%th Nombre de comptes
%th Actifs
- @stats.top_xmpp_domains.each do |domain|
%tr
%td.stat
= domain["domain"]
%td
.stat.misc(style="width: #{(width_stats * domain["cnt"] / maxval).to_i}px;")= domain["cnt"]
%td
#{@stats.pctrecent(domain["cnt"])}

%h2#stats_fonctionnalites Utilisation des fonctionnalités
%p
Sur #{pluralize @stats.nb_recently_used_accounts, "compte valide et utilisé", "comptes valides"} au cours des trois derniers mois :
Expand Down

0 comments on commit 3ac001b

Please sign in to comment.