ifd_tools 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
module IfdTools
|
|
2
|
-
|
|
2
|
+
module Tracking
|
|
3
|
+
class Event < ActiveRecord::Base
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
self.table_name = "ifd_tools_tracking_events"
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
belongs_to :customer
|
|
8
|
+
belongs_to :trackable, polymorphic: true
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
attr_accessible :ip_address, :platform, :timestamp, :type, :customer_id
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
validates :customer, presence: true
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
default_scope order(:timestamp)
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
def assign_trackable_item_by_id(id)
|
|
17
|
+
# self.trackable = AssociatedClass.find(id)
|
|
18
|
+
raise "Must implement 'assign_trackable_item_by_id' in each IfdTools::Tracking::Event subclass to set association"
|
|
19
|
+
end
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
after_initialize do
|
|
22
|
+
self.timestamp ||= Time.now if new_record?
|
|
23
|
+
end
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
# Class Methods
|
|
26
|
+
class << self
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
def event_types
|
|
29
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), "/*.rb"))].delete_if { |f| f.end_with? "/event.rb" }.each { |f| require f }
|
|
30
|
+
Dir["#{Rails.root}/app/models/ifd_tools/tracking/*.rb"].each { |f| require f }
|
|
31
|
+
subclasses
|
|
32
|
+
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
def platform_for_request(request)
|
|
35
|
+
if request.headers["HTTP_USER_AGENT"] =~ /Macintosh|iPad|iPhone/
|
|
36
|
+
"mac"
|
|
37
|
+
else
|
|
38
|
+
"pc"
|
|
39
|
+
end
|
|
38
40
|
end
|
|
39
|
-
end
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
def top_content
|
|
43
|
+
content = self.where("type != ?", "IfdTools::Tracking::ApplicationEvent").group(:trackable_id).order("count(trackable_id) desc").limit(25).collect do |e|
|
|
44
|
+
e.trackable_type.constantize.find(e.trackable_id) rescue nil
|
|
45
|
+
end
|
|
46
|
+
content.compact.sort { |a,b| b.trackable_activity <=> a.trackable_activity }
|
|
44
47
|
end
|
|
45
|
-
content.compact.sort { |a,b| b.trackable_activity <=> a.trackable_activity }
|
|
46
|
-
end
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
end
|
|
49
50
|
|
|
51
|
+
end
|
|
50
52
|
end
|
|
51
|
-
end
|
|
53
|
+
end
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
module IfdTools
|
|
2
|
-
module
|
|
2
|
+
module Tracking
|
|
3
|
+
module Trackable
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
def self.included(base)
|
|
6
|
+
base.class_eval do
|
|
7
|
+
has_many :tracking_events, :class_name => 'IfdTools::Tracking::Event', foreign_key: :trackable_id, dependent: :destroy
|
|
8
|
+
end
|
|
7
9
|
end
|
|
8
|
-
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
def trackable_title
|
|
12
|
+
name rescue title
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
def trackable_type
|
|
16
|
+
self.class.name.titleize
|
|
17
|
+
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
# Override if you might want to link to something else
|
|
20
|
+
def trackable_resource
|
|
21
|
+
self
|
|
22
|
+
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
def trackable_activity
|
|
25
|
+
tracking_events.count
|
|
26
|
+
end
|
|
26
27
|
|
|
28
|
+
end
|
|
27
29
|
end
|
|
28
30
|
end
|
data/lib/ifd_tools/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ifd_tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -298,7 +298,6 @@ files:
|
|
|
298
298
|
- app/models/ifd_tools/software_update.rb
|
|
299
299
|
- app/models/ifd_tools/tracking/application_event.rb
|
|
300
300
|
- app/models/ifd_tools/tracking/event.rb
|
|
301
|
-
- app/models/ifd_tools/tracking.rb
|
|
302
301
|
- app/uploaders/software_uploader.rb
|
|
303
302
|
- app/views/admin/contact_requests/_form.html.haml
|
|
304
303
|
- app/views/admin/customers/_trend.html.haml
|