Class: Dashboard

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/dashboard.rb

Overview

A Plain Old Ruby Object (PORO) responsible for organizing various Organization dashboard details. Uses many scopes defined on Organization and User.

Instance Method Summary collapse

Constructor Details

#initialize(current_user, organization) ⇒ Dashboard

Returns a new instance of Dashboard

Parameters:

  • current_user (User)

    identifies the user for whom we are creating a dashboard

  • organization (Organization)

    Identifies the organization for which we are creating a dashboard



9
10
11
12
# File 'app/presenters/dashboard.rb', line 9

def initialize(current_user, organization)
  @current_user = current_user
  @organization = organization
end

Instance Method Details

#current_user_approved_representation_countInteger

Returns total number of approved representations written by the current user

Returns:

  • (Integer)

    total number of approved representations written by the current user



105
106
107
# File 'app/presenters/dashboard.rb', line 105

def current_user_approved_representation_count
  current_user.authored_representations.approved.count
end

#current_user_assigned_items_countInteger

Returns total number of items assigned to the user

Returns:

  • (Integer)

    total number of items assigned to the user



126
127
128
# File 'app/presenters/dashboard.rb', line 126

def current_user_assigned_items_count
  current_user_assigned_items_queue.count
end

#current_user_open_assignments_countItnger

Returns total number of resources assigned to the user which do not have a representation

Returns:

  • (Itnger)

    total number of resources assigned to the user which do not have a representation



115
116
117
# File 'app/presenters/dashboard.rb', line 115

def current_user_open_assignments_count
  current_user.assigned_resources.unrepresented.count
end

#current_user_queue_empty?Boolean

Returns whether or not the user has any assigned items

Returns:

  • (Boolean)

    whether or not the user has any assigned items



131
132
133
# File 'app/presenters/dashboard.rb', line 131

def current_user_queue_empty?
  current_user_assigned_items_queue.empty?
end

#current_user_representation_countInteger

Returns total number of representations written by the current user

Returns:

  • (Integer)

    total number of representations written by the current user



100
101
102
# File 'app/presenters/dashboard.rb', line 100

def current_user_representation_count
  current_user.authored_representations.count
end

#current_user_represented_resources_countInteger

Returns total number of resources represented by the current user

Returns:

  • (Integer)

    total number of resources represented by the current user



95
96
97
# File 'app/presenters/dashboard.rb', line 95

def current_user_represented_resources_count
  current_user.resources.represented_by(current_user).count
end

#current_user_top_assigned_items_queueActiveRecord::Associations::CollectionProxy

Returns a subset of the most important resources assigned to the user for representation

Returns:

  • (ActiveRecord::Associations::CollectionProxy)

    a subset of the most important resources assigned to the user for representation



121
122
123
# File 'app/presenters/dashboard.rb', line 121

def current_user_top_assigned_items_queue
  current_user_assigned_items_queue.first(top_items_queue_size)
end

#current_user_unapproved_representation_countInteger

Returns total number of unapproved representations written by the current user

Returns:

  • (Integer)

    total number of unapproved representations written by the current user



110
111
112
# File 'app/presenters/dashboard.rb', line 110

def current_user_unapproved_representation_count
  current_user.authored_representations.not_approved.count
end

#organization_approved_representation_countInteger

Returns total number of approved representations owned by the organization

Returns:

  • (Integer)

    total number of approved representations owned by the organization



30
31
32
# File 'app/presenters/dashboard.rb', line 30

def organization_approved_representation_count
  organization.representations.approved.count
end

#organization_assigned_countInteger

Returns total number of resources owned by the organization which have been assigned to a user for representation

Returns:

  • (Integer)

    total number of resources owned by the organization which have been assigned to a user for representation



60
61
62
# File 'app/presenters/dashboard.rb', line 60

def organization_assigned_count
  organization.resources.assigned.count
end

#organization_latest_resource_timestampObject

Identifies the time when the most recently-created resource was added to the database, if any have been created



66
67
68
# File 'app/presenters/dashboard.rb', line 66

def organization_latest_resource_timestamp
  organization.resources.latest_timestamp
end

#organization_open_assignment_countInteger

Returns total number of resources that have been assigned to a user for representation, which are as-yet-unrepresented

Returns:

  • (Integer)

    total number of resources that have been assigned to a user for representation, which are as-yet-unrepresented



40
41
42
# File 'app/presenters/dashboard.rb', line 40

def organization_open_assignment_count
  organization.resources.assigned_unrepresented.count
end

#organization_ready_to_review_countInteger

Returns total number of ready-to-review representations owned by the organization

Returns:

  • (Integer)

    total number of ready-to-review representations owned by the organization



50
51
52
# File 'app/presenters/dashboard.rb', line 50

def organization_ready_to_review_count
  organization_ready_to_review_queue.count
end

#organization_representation_countInteger

Returns total number of representations owned by the organization

Returns:

  • (Integer)

    total number of representations owned by the organization



20
21
22
# File 'app/presenters/dashboard.rb', line 20

def organization_representation_count
  organization.representations.count
end

#organization_represented_resource_countInteger

Returns total number of represented resources owned by the organization

Returns:

  • (Integer)

    total number of represented resources owned by the organization



25
26
27
# File 'app/presenters/dashboard.rb', line 25

def organization_represented_resource_count
  organization.resources.represented.count
end

#organization_resource_countInteger

Returns total number of resources owned by the organization

Returns:

  • (Integer)

    total number of resources owned by the organization



15
16
17
# File 'app/presenters/dashboard.rb', line 15

def organization_resource_count
  organization.resources.count
end

#organization_top_ready_to_review_items_queueActiveRecord::Associations::CollectionProxy

Note:

You can control how many items are shown from the queue via the Rails.configuration.x.dashboard_top_items_queue_size setting in config/application.rb

Returns a subset of the most important resources assigned to the user for representation

Returns:

  • (ActiveRecord::Associations::CollectionProxy)

    a subset of the most important resources assigned to the user for representation



90
91
92
# File 'app/presenters/dashboard.rb', line 90

def organization_top_ready_to_review_items_queue
  organization_ready_to_review_queue.first(top_items_queue_size)
end

#organization_top_unassigned_items_queueActiveRecord::Associations::CollectionProxy

Note:

You can control how many items are shown from the queue via the Rails.configuration.x.dashboard_top_items_queue_size setting in config/application.rb

Returns a subset of the most important resources assigned to the user for representation

Returns:

  • (ActiveRecord::Associations::CollectionProxy)

    a subset of the most important resources assigned to the user for representation



84
85
86
# File 'app/presenters/dashboard.rb', line 84

def organization_top_unassigned_items_queue
  organization_unassigned_queue.first(top_items_queue_size)
end

#organization_top_unrepresented_items_queueActiveRecord::Associations::CollectionProxy

Note:

You can control how many items are shown from the queue via the Rails.configuration.x.dashboard_top_items_queue_size setting in config/application.rb

Returns a subset of the most important resources assigned to the user for representation

Returns:

  • (ActiveRecord::Associations::CollectionProxy)

    a subset of the most important resources assigned to the user for representation



78
79
80
# File 'app/presenters/dashboard.rb', line 78

def organization_top_unrepresented_items_queue
  organization_unrepresented_queue.first(top_items_queue_size)
end

#organization_unapproved_representation_countInteger

Returns total number of unapproved representations owned by the organization

Returns:

  • (Integer)

    total number of unapproved representations owned by the organization



35
36
37
# File 'app/presenters/dashboard.rb', line 35

def organization_unapproved_representation_count
  organization.representations.not_approved.count
end

#organization_unassigned_countInteger

Returns total number of resources owned by the organization which have not been assigned to a user for representation

Returns:

  • (Integer)

    total number of resources owned by the organization which have not been assigned to a user for representation



71
72
73
# File 'app/presenters/dashboard.rb', line 71

def organization_unassigned_count
  organization_unassigned_queue.count
end

#organization_unassigned_unrepresented_countInteger

Returns total number of resources that are unrepresented and have not been assigned to a user for representation

Returns:

  • (Integer)

    total number of resources that are unrepresented and have not been assigned to a user for representation



45
46
47
# File 'app/presenters/dashboard.rb', line 45

def organization_unassigned_unrepresented_count
  organization.resources.unassigned_unrepresented.count
end

#organization_unrepresented_countInteger

Returns total number of unrepresented resources owned by the organization

Returns:

  • (Integer)

    total number of unrepresented resources owned by the organization



55
56
57
# File 'app/presenters/dashboard.rb', line 55

def organization_unrepresented_count
  organization_unrepresented_queue.count
end

#organization_usersActiveRecord::Associations::CollectionProxy

Returns all of the users in the organization

Returns:

  • (ActiveRecord::Associations::CollectionProxy)

    all of the users in the organization



136
137
138
# File 'app/presenters/dashboard.rb', line 136

def organization_users
  organization.users.sorted
end