sufia-models/app/models/file_usage.rb in sufia-5.0.0 vs sufia-models/app/models/file_usage.rb in sufia-6.0.0.beta1
- old
+ new
@@ -8,11 +8,11 @@
user_id = user ? user.id : nil
self.id = id
self.path = Sufia::Engine.routes.url_helpers.generic_file_path(Sufia::Noid.noidify(id))
earliest = Sufia.config.analytic_start_date
- self.created = DateTime.parse(file.create_date)
+ self.created = ::GenericFile.find(id).create_date
self.created = earliest > created ? earliest : created unless earliest.blank?
self.downloads = FileDownloadStat.to_flots FileDownloadStat.statistics(id, created, user_id)
self.pageviews = FileViewStat.to_flots FileViewStat.statistics(id, created, user_id)
end
@@ -21,11 +21,11 @@
end
def total_pageviews
self.pageviews.reduce(0) { |total, result| total + result[1].to_i }
end
-
- # Package data for visualization using JQuery Flot
+
+ # Package data for visualization using JQuery Flot
def to_flot
[
{ label: "Pageviews", data: pageviews },
{ label: "Downloads", data: downloads }
]