Module: ActiveFedora::Calculations
- Included in:
- Relation
- Defined in:
- lib/active_fedora/relation/calculations.rb
Instance Method Summary collapse
- #calculate(_calculation, conditions, _opts = {}) ⇒ Object
-
#count(*args) ⇒ Object
Get a count of the number of objects from solr Takes :conditions as an argument.
Instance Method Details
#calculate(_calculation, conditions, _opts = {}) ⇒ Object
14 15 16 |
# File 'lib/active_fedora/relation/calculations.rb', line 14 def calculate(_calculation, conditions, _opts = {}) SolrService.query(create_query(conditions), raw: true, rows: 0).fetch('response'.freeze)['numFound'.freeze] end |
#count(*args) ⇒ Object
Get a count of the number of objects from solr Takes :conditions as an argument
5 6 7 8 9 10 11 12 |
# File 'lib/active_fedora/relation/calculations.rb', line 5 def count(*args) return (args.first).count if args.any? opts = {} opts[:rows] = limit_value if limit_value opts[:sort] = order_values if order_values calculate :count, where_values, opts end |