Implement basic statistics
This commit is contained in:
@ -61,6 +61,10 @@ div.negative-result {
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// StatisticsController:
|
// StatisticsController:
|
||||||
|
|
||||||
|
#statistics-container {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
.statistics-wrapper {
|
.statistics-wrapper {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
@ -81,7 +85,11 @@ div.negative-result {
|
|||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
line-height: 100px;
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .title {
|
||||||
|
height: 42px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class StatisticsController < ApplicationController
|
class StatisticsController < ApplicationController
|
||||||
|
include StatisticsHelper
|
||||||
|
|
||||||
def policy_class
|
def policy_class
|
||||||
StatisticsPolicy
|
StatisticsPolicy
|
||||||
@ -6,6 +7,10 @@ class StatisticsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
authorize self
|
authorize self
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json { render(json: statistics_data) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
74
app/helpers/statistics_helper.rb
Normal file
74
app/helpers/statistics_helper.rb
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
module StatisticsHelper
|
||||||
|
|
||||||
|
def statistics_data
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'users',
|
||||||
|
name: t('statistics.sections.users'),
|
||||||
|
entries: user_statistics
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'exercises',
|
||||||
|
name: t('statistics.sections.exercises'),
|
||||||
|
entries: exercise_statistics
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'request_for_comments',
|
||||||
|
name: t('statistics.sections.request_for_comments'),
|
||||||
|
entries: rfc_statistics
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_statistics
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'internal_users',
|
||||||
|
title: t('activerecord.models.internal_user.other'),
|
||||||
|
data: InternalUser.count
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'external_users',
|
||||||
|
title: t('activerecord.models.external_user.other'),
|
||||||
|
data: ExternalUser.count
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def exercise_statistics
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'exercises',
|
||||||
|
title: t('activerecord.models.exercise.other'),
|
||||||
|
data: Exercise.count
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'average_submissions',
|
||||||
|
title: t('statistics.entries.exercises.average_number_of_submissions'),
|
||||||
|
data: Submission.count / Exercise.count
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def rfc_statistics
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'rfcs',
|
||||||
|
title: t('activerecord.models.request_for_comment.other'),
|
||||||
|
data: RequestForComment.count
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'percent_solved',
|
||||||
|
title: t('statistics.entries.request_for_comments.percent_solved'),
|
||||||
|
data: (100.0 / RequestForComment.count * RequestForComment.where(solved: true).count).round(2),
|
||||||
|
unit: '%'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'comments',
|
||||||
|
title: t('activerecord.models.comment.other'),
|
||||||
|
data: Comment.count
|
||||||
|
},
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -1,3 +1,9 @@
|
|||||||
h1 = t('shared.statistics')
|
|
||||||
|
|
||||||
.statistics-wrapper
|
#statistics-container
|
||||||
|
- statistics_data.each do | section |
|
||||||
|
h2 = section[:name]
|
||||||
|
.statistics-wrapper
|
||||||
|
- section[:entries].each do | entry |
|
||||||
|
div
|
||||||
|
.title = entry[:title]
|
||||||
|
.data = entry[:data].to_s + (entry[:unit] or '')
|
||||||
|
@ -676,3 +676,13 @@ de:
|
|||||||
subscriptions:
|
subscriptions:
|
||||||
successfully_unsubscribed: "Ihr Abonnement für weitere Kommentare auf dieser Kommentaranfrage wurde erfolgreich beendet."
|
successfully_unsubscribed: "Ihr Abonnement für weitere Kommentare auf dieser Kommentaranfrage wurde erfolgreich beendet."
|
||||||
subscription_not_existent: "Das Abonnement, von dem Sie sich abmelden wollen, existiert nicht."
|
subscription_not_existent: "Das Abonnement, von dem Sie sich abmelden wollen, existiert nicht."
|
||||||
|
statistics:
|
||||||
|
sections:
|
||||||
|
users: "Benutzer"
|
||||||
|
exercises: "Aufgaben"
|
||||||
|
request_for_comments: "Kommentaranfragen"
|
||||||
|
entries:
|
||||||
|
exercises:
|
||||||
|
average_number_of_submissions: "Durchschnittliche Zahl von Abgaben"
|
||||||
|
request_for_comments:
|
||||||
|
percent_solved: "Beantwortete Anfragen"
|
||||||
|
@ -676,3 +676,13 @@ en:
|
|||||||
subscriptions:
|
subscriptions:
|
||||||
successfully_unsubscribed: "You successfully unsubscribed from this Request for Comment"
|
successfully_unsubscribed: "You successfully unsubscribed from this Request for Comment"
|
||||||
subscription_not_existent: "The subscription you want to unsubscribe from does not exist."
|
subscription_not_existent: "The subscription you want to unsubscribe from does not exist."
|
||||||
|
statistics:
|
||||||
|
sections:
|
||||||
|
users: "Users"
|
||||||
|
exercises: "Exercises"
|
||||||
|
request_for_comments: "Requests for Comment"
|
||||||
|
entries:
|
||||||
|
exercises:
|
||||||
|
average_number_of_submissions: "Average Number of Submissions"
|
||||||
|
request_for_comments:
|
||||||
|
percent_solved: "Solved Requests"
|
||||||
|
Reference in New Issue
Block a user