Skip to content

Commit a3b80c9

Browse files
committed
Extend (live) user statistics beyond ExternalUsers
The graphs shown at /statistics/graphs only included external users without providing a clear information on that. Now, we show activity of any contributor for these graphs.
1 parent 256f09e commit a3b80c9

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

app/helpers/statistics_helper.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def contributor_statistics
4848
},
4949
{
5050
key: 'currently_active',
51-
name: t('statistics.entries.users.currently_active'),
51+
name: t('statistics.entries.contributors.currently_active'),
5252
data: Submission.from(Submission.where(created_at: 5.minutes.ago..).distinct.select(:contributor_id, :contributor_type)).count,
5353
url: statistics_graphs_path,
5454
},
@@ -113,15 +113,12 @@ def rfc_statistics
113113
]
114114
end
115115

116-
# TODO: Need to consider and support programming groups
117116
def user_activity_live_data
118117
[
119118
{
120119
key: 'active_in_last_hour',
121-
name: t('statistics.entries.users.currently_active'),
122-
data: ExternalUser.joins(:submissions)
123-
.where(submissions: {created_at: DateTime.now - 5.minutes..})
124-
.distinct('external_users.id').count,
120+
name: t('statistics.entries.contributors.currently_active'),
121+
data: Submission.where(created_at: DateTime.now - 5.minutes..).distinct.select(:contributor_id, :contributor_type).count,
125122
},
126123
{
127124
key: 'submissions_per_minute',
@@ -215,15 +212,13 @@ def ranged_rfc_data(interval = 'year', from = DateTime.new(0), to = DateTime.now
215212
]
216213
end
217214

218-
# TODO: Need to consider and support programming groups
219215
def ranged_user_data(interval = 'year', from = DateTime.new(0), to = DateTime.now)
220216
[
221217
{
222218
key: 'active',
223-
name: t('statistics.entries.users.active'),
224-
data: ExternalUser.joins(:submissions)
225-
.where(submissions: {created_at: from..to})
226-
.select(ExternalUser.sanitize_sql(['date_trunc(?, submissions.created_at) AS "key", count(distinct external_users.id) AS "value"', interval]))
219+
name: t('statistics.entries.contributors.active'),
220+
data: Submission.where(created_at: from..to)
221+
.select(Submission.sanitize_sql(['date_trunc(?, created_at) AS "key", count(distinct CONCAT(contributor_type, contributor_id)) AS "value"', interval]))
227222
.group('key').order('key'),
228223
},
229224
{

config/locales/de/statistic.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ de:
77
to: Bis
88
update: Aktualisieren
99
entries:
10+
contributors:
11+
active: Aktive Mitwirkende
12+
currently_active: Aktiv (5 Minuten)
1013
exercises:
1114
autosaves_per_minute: Aktuelle Autosaves (1h)
1215
average_number_of_submissions: Durchschnittliche Zahl von Abgaben
@@ -18,9 +21,6 @@ de:
1821
percent_solved: Beantwortete Anfragen
1922
percent_unsolved: Unbeantwortete Anfragen
2023
with_comments: Anfragen mit Kommentaren
21-
users:
22-
active: Aktive Personen
23-
currently_active: Aktiv (5 Minuten)
2424
graphs:
2525
history: Historie
2626
rfc_activity: Kommentaranfragenaktivität

config/locales/en/statistic.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ en:
77
to: To
88
update: Update
99
entries:
10+
contributors:
11+
active: Active Contributors
12+
currently_active: Active (5 minutes)
1013
exercises:
1114
autosaves_per_minute: Current Autosave Volume (1h)
1215
average_number_of_submissions: Average Number of Submissions
@@ -18,9 +21,6 @@ en:
1821
percent_solved: Solved Requests
1922
percent_unsolved: Unsolved Requests
2023
with_comments: RfCs with Comments
21-
users:
22-
active: Active Users
23-
currently_active: Active (5 minutes)
2424
graphs:
2525
history: History
2626
rfc_activity: RfC Activity

0 commit comments

Comments
 (0)