Class: Hyrax::Statistics::ValkyrieQueryService

Inherits:
QueryService
  • Object
show all
Defined in:
app/services/hyrax/statistics/valkyrie_query_service.rb

Instance Method Summary collapse

Methods inherited from QueryService

#build_date_query, #where_public, #where_registered

Instance Method Details

#find_by_date_created(start_datetime, end_datetime = nil) ⇒ Object

query to find works created during the time range

Parameters:

  • start_datetime (DateTime)

    starting date time for range query

  • end_datetime (DateTime) (defaults to: nil)

    ending date time for range query



8
9
10
11
12
13
14
15
# File 'app/services/hyrax/statistics/valkyrie_query_service.rb', line 8

def find_by_date_created(start_datetime, end_datetime = nil)
  return [] if start_datetime.blank? # no date just return nothing
  return super unless non_wings_valkyire?

  Hyrax.query_service.custom_queries.find_by_date_range(start_datetime: start_datetime,
                                                        end_datetime: end_datetime,
                                                        models: relation.allowable_types).to_a
end

#find_public_in_date_range(start_datetime, end_datetime = nil) ⇒ Object



22
23
24
25
# File 'app/services/hyrax/statistics/valkyrie_query_service.rb', line 22

def find_public_in_date_range(start_datetime, end_datetime = nil)
  return super unless non_wings_valkyire?
  find_by_date_created(start_datetime, end_datetime) & where_public.to_a
end

#find_registered_in_date_range(start_datetime, end_datetime = nil) ⇒ Object



17
18
19
20
# File 'app/services/hyrax/statistics/valkyrie_query_service.rb', line 17

def find_registered_in_date_range(start_datetime, end_datetime = nil)
  return super unless non_wings_valkyire?
  find_by_date_created(start_datetime, end_datetime) & where_registered.to_a
end

#relationObject



27
28
29
30
# File 'app/services/hyrax/statistics/valkyrie_query_service.rb', line 27

def relation
  return super unless non_wings_valkyire?
  Hyrax::ValkyrieWorkRelation.new
end