Use chartkick globally
* Clean up legacy charting imports * Update existing donut and line charts * Create helpers for parsing out existing chart data * Move chart partials to a more common path
This commit is contained in:
parent
3bbac3667f
commit
516e53d9df
29 changed files with 331 additions and 577 deletions
|
|
@ -32,6 +32,13 @@ class User < ApplicationRecord
|
|||
# add scope
|
||||
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)}
|
||||
|
||||
# scopes for user distributions
|
||||
scope :active, lambda {
|
||||
where('last_sign_in_at > ?', Date.today - 3.months).where(is_disabled: false)
|
||||
}
|
||||
scope :unconfirmed, -> { where('confirmed_at IS NULL') }
|
||||
scope :dead, -> { where('last_sign_in_at < ?', Date.today - 1.year) }
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
# :lockable, :timeoutable and :omniauthable
|
||||
|
|
@ -79,7 +86,6 @@ class User < ApplicationRecord
|
|||
accepts_nested_attributes_for :roles
|
||||
|
||||
scope :admin, -> { where(is_admin: true) }
|
||||
scope :active, -> { where(is_disabled: false) }
|
||||
|
||||
validates :email, presence: true
|
||||
|
||||
|
|
@ -91,6 +97,12 @@ class User < ApplicationRecord
|
|||
|
||||
validate :biography_limit
|
||||
|
||||
DISTRIBUTION_COLORS = {
|
||||
'Active' => 'green',
|
||||
'Unconfirmed' => 'red',
|
||||
'Dead' => 'black'
|
||||
}.freeze
|
||||
|
||||
##
|
||||
# Checkes if the user attended the event
|
||||
# This is used for events that require registration
|
||||
|
|
@ -152,6 +164,22 @@ class User < ApplicationRecord
|
|||
user
|
||||
end
|
||||
|
||||
##
|
||||
# Returns a hash with user distribution => {value: count of user state, color: color}
|
||||
# active: signed in during the last 3 months
|
||||
# unconfirmed: registered but not confirmed
|
||||
# dead: not signed in during the last year
|
||||
#
|
||||
# ====Returns
|
||||
# * +hash+ -> hash
|
||||
def self.distribution
|
||||
{
|
||||
'Active' => User.active.count,
|
||||
'Unconfirmed' => User.unconfirmed.count,
|
||||
'Dead' => User.dead.count
|
||||
}
|
||||
end
|
||||
|
||||
def self.find_for_database_authentication(warden_conditions)
|
||||
conditions = warden_conditions.dup
|
||||
login = conditions.delete(:login)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue