ahoy_email 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/ahoy_email/database_subscriber.rb +15 -4
- data/lib/ahoy_email/version.rb +1 -1
- data/lib/generators/ahoy/clicks/mongoid_generator.rb +15 -0
- data/lib/generators/ahoy/clicks/templates/mongoid.rb.tt +8 -0
- data/lib/generators/ahoy/clicks_generator.rb +27 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12cfd52040334d8582ee01785c46c290d9a8e125d79ea5a5cddabed3d26ed144
|
4
|
+
data.tar.gz: db924f04d522c4bb9fd488fb34533349b231148170de637fff11ca34c6c18b36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba35f76f9d5bb2d52972ab648179e710c16eeda09bc51b4f91aff083bad354ec5dd6b8c98985b913efbf40c9e3215a3111e2a45978c647cf2fa8d9bd96519925
|
7
|
+
data.tar.gz: 1247bc81b9cc52a43ec480640c4c94989cfcf7ac4c0868c5c5cdeb0d85da013f93e9bc61993f78d94a8191819e6b7c76d6593f84d70203ed329793debbf7df2a
|
data/CHANGELOG.md
CHANGED
@@ -10,9 +10,16 @@ module AhoyEmail
|
|
10
10
|
|
11
11
|
def stats(campaign)
|
12
12
|
sends = Ahoy::Message.where(campaign: campaign).count
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
if defined?(ActiveRecord) && Ahoy::Click < ActiveRecord::Base
|
15
|
+
result = Ahoy::Click.where(campaign: campaign).select("COUNT(*) AS clicks, COUNT(DISTINCT token) AS unique_clicks").to_a[0]
|
16
|
+
clicks = result.clicks
|
17
|
+
unique_clicks = result.unique_clicks
|
18
|
+
else
|
19
|
+
clicks = Ahoy::Click.where(campaign: campaign).count
|
20
|
+
# TODO use aggregation framework
|
21
|
+
unique_clicks = Ahoy::Click.where(campaign: campaign).distinct(:token).count
|
22
|
+
end
|
16
23
|
|
17
24
|
if sends > 0 || clicks > 0
|
18
25
|
{
|
@@ -25,7 +32,11 @@ module AhoyEmail
|
|
25
32
|
end
|
26
33
|
|
27
34
|
def campaigns
|
28
|
-
Ahoy::Message
|
35
|
+
if defined?(ActiveRecord) && Ahoy::Message < ActiveRecord::Base
|
36
|
+
Ahoy::Message.where.not(campaign: nil).distinct.pluck(:campaign)
|
37
|
+
else
|
38
|
+
Ahoy::Message.where(campaign: {"$ne" => nil}).distinct(:campaign)
|
39
|
+
end
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
data/lib/ahoy_email/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Ahoy
|
4
|
+
module Generators
|
5
|
+
module Clicks
|
6
|
+
class MongoidGenerator < Rails::Generators::Base
|
7
|
+
source_root File.join(__dir__, "templates")
|
8
|
+
|
9
|
+
def copy_templates
|
10
|
+
template "mongoid.rb", "app/models/ahoy/click.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,7 +4,33 @@ module Ahoy
|
|
4
4
|
module Generators
|
5
5
|
class ClicksGenerator < Rails::Generators::Base
|
6
6
|
def copy_templates
|
7
|
-
|
7
|
+
activerecord = defined?(ActiveRecord)
|
8
|
+
mongoid = defined?(Mongoid)
|
9
|
+
|
10
|
+
selection =
|
11
|
+
if activerecord && mongoid
|
12
|
+
puts <<-MSG
|
13
|
+
|
14
|
+
Which data store would you like to use?
|
15
|
+
1. Active Record (default)
|
16
|
+
2. Mongoid
|
17
|
+
MSG
|
18
|
+
|
19
|
+
ask(">")
|
20
|
+
elsif activerecord
|
21
|
+
"1"
|
22
|
+
else
|
23
|
+
"2"
|
24
|
+
end
|
25
|
+
|
26
|
+
case selection
|
27
|
+
when "", "1"
|
28
|
+
invoke "ahoy:clicks:activerecord"
|
29
|
+
when "2"
|
30
|
+
invoke "ahoy:clicks:mongoid"
|
31
|
+
else
|
32
|
+
abort "Error: must enter a number [1-2]"
|
33
|
+
end
|
8
34
|
end
|
9
35
|
end
|
10
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -92,7 +92,9 @@ files:
|
|
92
92
|
- lib/ahoy_email/utils.rb
|
93
93
|
- lib/ahoy_email/version.rb
|
94
94
|
- lib/generators/ahoy/clicks/activerecord_generator.rb
|
95
|
+
- lib/generators/ahoy/clicks/mongoid_generator.rb
|
95
96
|
- lib/generators/ahoy/clicks/templates/migration.rb.tt
|
97
|
+
- lib/generators/ahoy/clicks/templates/mongoid.rb.tt
|
96
98
|
- lib/generators/ahoy/clicks_generator.rb
|
97
99
|
- lib/generators/ahoy/messages/activerecord_generator.rb
|
98
100
|
- lib/generators/ahoy/messages/mongoid_generator.rb
|