Skip to content
Extraits de code Groupes Projets
Valider e4e1bea6 rédigé par SansPseudoFix's avatar SansPseudoFix Validation de Augier
Parcourir les fichiers

Feature : Statistics design

parent 4d8790d6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -77,3 +77,6 @@ ...@@ -77,3 +77,6 @@
/* code */ /* code */
@import 'new_styles/code'; @import 'new_styles/code';
/* statistics */
@import 'new_styles/statistics'
\ No newline at end of file
.page-statistics {
h1{ text-align: center; }
h3{
margin: 0px;
padding: 10px;
background-color: $green;
}
.span-3 {
width: 30%;
height: 150px;
text-align: center;
border: 1px solid $border-grey;
margin-bottom: 10px;
border-radius: 5px;
.data{
word-wrap: break-word;
overflow: hidden;
margin-top: 25px;
font-size: 25px;
line-height: 30px;
}
.serv-disabled{
background-color: $background-grey;
}
}
}
\ No newline at end of file
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class StatisticsController < ApplicationController class StatisticsController < ApplicationController
respond_to :html, :json
use_bootstrap_for :statistics
respond_to :json
def statistics def statistics
@statistics = StatisticsPresenter.new
respond_to do |format| respond_to do |format|
format.json { render :json => StatisticsPresenter.new } format.json { render json: @statistics }
format.html { render layout: "application" }
end end
end end
end
end \ No newline at end of file
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module StatisticsHelper
def registrations_status statistics
if statistics.open_registrations?
I18n.t('statistics.open')
else
I18n.t('statistics.closed')
end
end
def service_status service, available_services
if available_services.include? service
I18n.t('statistics.enabled')
else
I18n.t('statistics.disabled')
end
end
def service_class service, available_services
if available_services.include? service
"serv-enabled"
else
"serv-disabled"
end
end
end
\ No newline at end of file
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class StatisticsPresenter class StatisticsPresenter
def as_json(options={}) def as_json options={}
result = { base_data.merge(user_counts)
'name' => AppConfig.settings.pod_name, .merge(post_counts)
'network' => "Diaspora", .merge(comment_counts)
'version' => AppConfig.version_string, .merge(all_services)
'registrations_open' => AppConfig.settings.enable_registrations, .merge(legacy_services) # Remove in 0.6
'services' => [] end
def base_data
{
'name' => name,
'network' => 'Diaspora',
'version' => version,
'registrations_open' => open_registrations?,
'services' => available_services
} }
if AppConfig.privacy.statistics.user_counts? end
result['total_users'] = User.count
result['active_users_halfyear'] = User.halfyear_actives.count
result['active_users_monthly'] = User.monthly_actives.count
end
if AppConfig.privacy.statistics.post_counts?
result['local_posts'] = self.local_posts
end
if AppConfig.privacy.statistics.comment_counts?
result['local_comments'] = self.local_comments
end
result["services"] = Configuration::KNOWN_SERVICES.select {|service| AppConfig["services.#{service}.enable"]}.map(&:to_s)
Configuration::KNOWN_SERVICES.each do |service, options|
result[service.to_s] = AppConfig["services.#{service}.enable"]
end
result def name
AppConfig.settings.pod_name
end
def version
AppConfig.version_string
end
def open_registrations?
AppConfig.settings.enable_registrations
end
def user_counts
return {} unless expose_user_counts?
{
'total_users' => total_users,
'active_users_monthly' => monthly_users,
'active_users_halfyear' => halfyear_users
}
end
def expose_user_counts?
AppConfig.privacy.statistics.user_counts?
end
def total_users
@total_users ||= User.joins(:person)
.where(people: {closed_account: false})
.where.not(username: nil)
.count
end
def monthly_users
@monthly_users ||= User.halfyear_actives.count
end
def halfyear_users
@halfyear_users ||= User.monthly_actives.count
end
def post_counts
return {} unless expose_posts_counts?
{
'local_posts' => local_posts
}
end end
def local_posts def local_posts
Post.where(:type => "StatusMessage").joins(:author).where("owner_id IS NOT null").count @local_posts ||= Post.where(type: "StatusMessage")
.joins(:author)
.where("owner_id IS NOT null")
.count
end
def expose_posts_counts?
AppConfig.privacy.statistics.post_counts?
end
def comment_counts
return {} unless expose_comment_counts?
{
'local_comments' => local_comments
}
end end
def expose_comment_counts?
AppConfig.privacy.statistics.comment_counts?
end
def local_comments def local_comments
Comment.joins(:author).where("owner_id IS NOT null").count @local_comments ||= Comment.joins(:author)
.where("owner_id IS NOT null")
.count
end
def all_services_helper
result = {}
Configuration::KNOWN_SERVICES.each {|service, options|
result[service.to_s] = AppConfig["services.#{service}.enable"]
}
result
end
def all_services
@all_services ||= all_services_helper
end
def available_services
Configuration::KNOWN_SERVICES.select {|service|
AppConfig["services.#{service}.enable"]
}.map(&:to_s)
end
def legacy_services
Configuration::KNOWN_SERVICES.each_with_object({}) {|service, result|
result[service.to_s] = AppConfig["services.#{service}.enable"]
}
end end
end end
\ No newline at end of file
.span-3
%h3{:class => activated}
= name
.data
= value
\ No newline at end of file
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%header
.row-fluid
%h1
= t('_statistics')
= render 'statistics/statistic', name: t('statistics.name'), value: @statistics.name, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.version'), value: @statistics.version, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.registrations'), value: registrations_status(@statistics), activated: "serv-enabled"
- if @statistics.expose_user_counts?
= render 'statistics/statistic', name: t('statistics.total_users'), value: @statistics.total_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_halfyear'), value: @statistics.halfyear_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_monthly'), value: @statistics.monthly_users, activated: "serv-enabled"
- if @statistics.expose_posts_counts?
= render 'statistics/statistic', name: t('statistics.local_posts'), value: @statistics.local_posts, activated: "serv-enabled"
- if @statistics.expose_comment_counts?
= render 'statistics/statistic', name: t('statistics.local_comments'), value: @statistics.local_comments, activated: "serv-enabled"
.row-fluid
%h1
= t('statistics.services')
- Configuration::KNOWN_SERVICES.each do |service|
= render 'statistics/statistic', name: "#{service.capitalize}", value: service_status(service, @statistics.available_services), activated: service_class(service, @statistics.available_services)
\ No newline at end of file
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%header
.row-fluid
%h1
= t('_statistics')
= render 'statistics/statistic', name: t('statistics.name'), value: @statistics.name, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.version'), value: @statistics.version, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.registrations'), value: registrations_status(@statistics), activated: "serv-enabled"
- if @statistics.expose_user_counts?
= render 'statistics/statistic', name: t('statistics.total_users'), value: @statistics.total_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_halfyear'), value: @statistics.halfyear_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_monthly'), value: @statistics.monthly_users, activated: "serv-enabled"
- if @statistics.expose_posts_counts?
= render 'statistics/statistic', name: t('statistics.local_posts'), value: @statistics.local_posts, activated: "serv-enabled"
- if @statistics.expose_comment_counts?
= render 'statistics/statistic', name: t('statistics.local_comments'), value: @statistics.local_comments, activated: "serv-enabled"
.row-fluid
%h1
= t('statistics.services')
- Configuration::KNOWN_SERVICES.each do |service|
= render 'statistics/statistic', name: "#{service.capitalize}", value: service_status(service, @statistics.available_services), activated: service_class(service, @statistics.available_services)
\ No newline at end of file
...@@ -47,6 +47,7 @@ en: ...@@ -47,6 +47,7 @@ en:
_contacts: "Contacts" _contacts: "Contacts"
welcome: "Welcome!" welcome: "Welcome!"
_terms: "terms" _terms: "terms"
_statistics: "Statistics"
#for reference translation, the real activerecord english transations are actually #for reference translation, the real activerecord english transations are actually
#in en-US, en-GB, and en-AU yml files #in en-US, en-GB, and en-AU yml files
...@@ -1380,3 +1381,19 @@ en: ...@@ -1380,3 +1381,19 @@ en:
default: "The secret code did not match with the image" default: "The secret code did not match with the image"
user: "The secret image and code were different" user: "The secret image and code were different"
failed: "Human verification failed" failed: "Human verification failed"
statistics:
name: "Name"
network: "Network"
services: "Services"
total_users: "Total users"
active_users_halfyear: "Active users half year"
active_users_monthly: "Active users monthly"
local_posts: "Local posts"
local_comments: "Local comments"
version: "Version"
registrations: "Registrations"
enabled: "Available"
disabled: "Not available"
open: "Open"
closed: "Closed"
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter