Class: Hyrax::Statistic
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Hyrax::Statistic
show all
- Extended by:
- ActionDispatch::Routing::PolymorphicRoutes
- Defined in:
- app/models/hyrax/statistic.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.build_for(object, attrs) ⇒ Object
16
17
18
|
# File 'app/models/hyrax/statistic.rb', line 16
def build_for(object, attrs)
new attrs.merge(filter(object))
end
|
.convert_date(date_time) ⇒ Object
20
21
22
|
# File 'app/models/hyrax/statistic.rb', line 20
def convert_date(date_time)
date_time.to_datetime.to_i * 1000
end
|
.query_works(query) ⇒ Object
28
29
30
31
32
|
# File 'app/models/hyrax/statistic.rb', line 28
def query_works(query)
models = Hyrax::ModelRegistry.work_rdf_representations.map { |m| "\"#{m}\"" }
response = Hyrax::SolrService.get(fq: "has_model_ssim:(#{models.join(' OR ')})", 'facet.field': query, 'facet.missing': true, rows: 0)
Hash[*response['facet_counts']['facet_fields'][query]]
end
|
.resource_types ⇒ Object
40
41
42
43
44
|
# File 'app/models/hyrax/statistic.rb', line 40
def resource_types
types = query_works("resource_type_sim")
types['Unknown'] = types.delete(nil)
types
end
|
.statistics(object, start_date, user_id = nil) ⇒ Object
24
25
26
|
# File 'app/models/hyrax/statistic.rb', line 24
def statistics(object, start_date, user_id = nil)
combined_stats object, start_date, cache_column, event_type, user_id
end
|
.statistics_for(object) ⇒ Object
12
13
14
|
# File 'app/models/hyrax/statistic.rb', line 12
def statistics_for(object)
where(filter(object))
end
|
.work_types ⇒ Object
34
35
36
37
38
|
# File 'app/models/hyrax/statistic.rb', line 34
def work_types
types = query_works("human_readable_type_sim")
types['Unknown'] = types.delete(nil)
types
end
|
Instance Method Details
#to_flot ⇒ Object
69
70
71
|
# File 'app/models/hyrax/statistic.rb', line 69
def to_flot
[self.class.convert_date(date), send(cache_column)]
end
|