Module: Hyrax::DashboardHelperBehavior

Included in:
HyraxHelperBehavior
Defined in:
app/helpers/hyrax/dashboard_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#number_of_collections(user = current_user) ⇒ Object



25
26
27
28
29
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 25

def number_of_collections(user = current_user)
  ::Collection.where(DepositSearchBuilder.depositor_field => user.user_key).count
rescue RSolr::Error::ConnectionRefused
  'n/a'
end

#number_of_files(user = current_user) ⇒ Object



19
20
21
22
23
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 19

def number_of_files(user = current_user)
  ::FileSet.where(DepositSearchBuilder.depositor_field => user.user_key).count
rescue RSolr::Error::ConnectionRefused
  'n/a'
end

#number_of_works(user = current_user, where: { generic_type_sim: "Work" }) ⇒ Object

Parameters:

  • user (User) (defaults to: current_user)
  • where (Hash) (defaults to: { generic_type_sim: "Work" })

    applied as the where clause when querying the Hyrax::WorkRelation

See Also:



12
13
14
15
16
17
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 12

def number_of_works(user = current_user, where: { generic_type_sim: "Work" })
  where_clause = where.merge(DepositSearchBuilder.depositor_field => user.user_key)
  Hyrax::WorkRelation.new.where(where_clause).count
rescue RSolr::Error::ConnectionRefused
  'n/a'
end

#on_the_dashboard?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 4

def on_the_dashboard?
  params[:controller].match(%r{^hyrax/dashboard|hyrax/my})
end