Module: Hyrax::DashboardHelperBehavior
- Included in:
- HyraxHelperBehavior
- Defined in:
- app/helpers/hyrax/dashboard_helper_behavior.rb
Instance Method Summary collapse
- #link_to_works(user = current_user) ⇒ Object
-
#number_of_collections(user = current_user) ⇒ Integer
Number of Collections the user created.
-
#number_of_files(user = current_user) ⇒ Integer
Number of FileSets the user deposited.
-
#number_of_works(user = current_user) ⇒ Integer
Number of works that the user deposited.
- #on_the_dashboard? ⇒ Boolean
Instance Method Details
#link_to_works(user = current_user) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 20 def link_to_works(user = current_user) state = Blacklight::SearchState.new(params, CatalogController.blacklight_config) facet_type = if Hyrax.config.use_valkyrie? state.add_facet_params('generic_type_si', 'Work') else state.add_facet_params('generic_type_sim', 'Work') end facet_depositor = state.add_facet_params('depositor_ssim', user.to_s) state = Hash.new {} state["f"] = facet_type["f"].merge(facet_depositor["f"]) link_to(t("hyrax.dashboard.stats.works"), main_app.search_catalog_path(state)) end |
#number_of_collections(user = current_user) ⇒ Integer
Returns number of Collections the user created.
47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 47 def number_of_collections(user = current_user) Hyrax::SolrQueryService .new .with_field_pairs(field_pairs: field_pairs(user)) .with_generic_type(generic_type: 'Collection') .count rescue RSolr::Error::ConnectionRefused 'n/a' end |
#number_of_files(user = current_user) ⇒ Integer
Returns number of FileSets the user deposited.
35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 35 def number_of_files(user = current_user) Hyrax::SolrQueryService .new .with_field_pairs(field_pairs: field_pairs(user)) .with_generic_type(generic_type: 'FileSet') .count rescue RSolr::Error::ConnectionRefused 'n/a' end |
#number_of_works(user = current_user) ⇒ Integer
Returns number of works that the user deposited.
10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/hyrax/dashboard_helper_behavior.rb', line 10 def number_of_works(user = current_user) Hyrax::SolrQueryService .new .with_field_pairs(field_pairs: field_pairs(user)) .with_generic_type(generic_type: 'Work') .count rescue RSolr::Error::ConnectionRefused 'n/a' end |
#on_the_dashboard? ⇒ 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 |