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) ⇒ Integer

Returns number of Collections the user created.

Parameters:

  • user (User) (defaults to: current_user)

Returns:

  • (Integer)

    number of Collections the user created


30
31
32
33
34
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 30

def number_of_collections(user = current_user)
  count(Hyrax::SolrQueryBuilderService.construct_query_for_model(::Collection, field_pairs(user)))
rescue RSolr::Error::ConnectionRefused
  'n/a'
end

#number_of_files(user = current_user) ⇒ Integer

Returns number of FileSets the user deposited.

Parameters:

  • user (User) (defaults to: current_user)

Returns:

  • (Integer)

    number of FileSets the user deposited


22
23
24
25
26
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 22

def number_of_files(user = current_user)
  count(Hyrax::SolrQueryBuilderService.construct_query_for_model(::FileSet, field_pairs(user)))
rescue RSolr::Error::ConnectionRefused
  'n/a'
end

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

Returns number of works matching the where that the user deposited.

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

Returns:

  • (Integer)

    number of works matching the where that the user deposited

See Also:


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

def number_of_works(user = current_user, where: { generic_type_sim: "Work" })
  field_pairs = field_pairs(user)
  field_pairs.merge!(where)
  count(Hyrax::SolrQueryBuilderService.construct_query(field_pairs))
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