Guest User

Untitled

a guest
Feb 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. module Hyrax
  2. module Analytics
  3. # @abstract Base class for Analytics services that support statistics needs in Hyrax.
  4. # Implementing subclasses must define `#connection` `#remote_statistics` and `#to_graph`
  5. class Base
  6. # Establish connection with the analytics service
  7. def self.connection
  8. raise NotImplementedError, "#{self.class}#connection is unimplemented."
  9. end
  10.  
  11. # Used by Hyrax::Statistic to perform live queries against the remote service
  12. # @param start_date [DateTime]
  13. # @param object [ActiveFedora::Base??] probably a better type for this
  14. # @param query_type
  15. #
  16. # return [Enumerable] of objects to cache locally in DB
  17. # TODO: decide best place for query types: pageview, download, returning visitors, new visitors,..
  18. def self.remote_statistics(start_date, object, query_type)
  19. raise NotImplementedError, "#{self.class}#remote_statistics is unimplemented."
  20. end
  21.  
  22. # OR, define explicit query methods for each query?
  23. # Examples
  24. def self.pageviews(start_date, object)
  25. raise NotImplementedError, "#{self.class}#pageviews is unimplemented."
  26. end
  27.  
  28. def self.downloads(start_date, object)
  29. raise NotImplementedError, "#{self.class}#downloads is unimplemented."
  30. end
  31.  
  32. def self.visitors(start_date)
  33. raise NotImplementedError, "#{self.class}#visitors is unimplemented."
  34. end
  35.  
  36. def self.returning_visitors(start_date)
  37. raise NotImplementedError, "#{self.class}#returning_visitors is unimplemented."
  38. end
  39. end
  40. end
  41. end
Add Comment
Please, Sign In to add comment