e9_crm 0.1.24 → 0.1.25
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.
data/app/models/campaign.rb
CHANGED
@@ -38,7 +38,7 @@ class Campaign < ActiveRecord::Base
|
|
38
38
|
scope :of_group, lambda {|val| joins(:campaign_group).where(:campaign_group_id => val.to_param) }
|
39
39
|
scope :typed, lambda { where(arel_table[:type].not_eq('NoCampaign')) }
|
40
40
|
scope :ordered, lambda { order(arel_table[:name].asc) }
|
41
|
-
|
41
|
+
|
42
42
|
scope :reports, lambda {|*args|
|
43
43
|
options = args.extract_options!
|
44
44
|
|
@@ -50,6 +50,7 @@ class Campaign < ActiveRecord::Base
|
|
50
50
|
COUNT(deals.id) lead_count,
|
51
51
|
|
52
52
|
SUM(IF(deals.status='won',1,0)) won_deal_count,
|
53
|
+
SUM(IF(deals.status IN('won','lost'),1,0)) closed_deal_count,
|
53
54
|
SUM(IF(deals.status='won',deals.value,0)) total_value,
|
54
55
|
AVG(IF(deals.status='won',deals.value,NULL)) average_value,
|
55
56
|
|
@@ -60,10 +61,13 @@ class Campaign < ActiveRecord::Base
|
|
60
61
|
rv.count repeat_visits,
|
61
62
|
nv.count new_visits,
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
SUM(DATEDIFF(
|
65
|
+
deals.closed_at,
|
66
|
+
deals.created_at)) total_elapsed,
|
67
|
+
|
68
|
+
AVG(DATEDIFF(
|
69
|
+
deals.closed_at,
|
70
|
+
deals.created_at)) average_elapsed
|
67
71
|
SQL
|
68
72
|
|
69
73
|
select(selects)
|
@@ -60,7 +60,10 @@
|
|
60
60
|
= m record.average_cost
|
61
61
|
%td.record-average-elapsed.num
|
62
62
|
- dat[:average_elapsed] << record.average_elapsed
|
63
|
-
= record.average_elapsed && "%
|
63
|
+
= record.closed_deal_count > 0 ? record.average_elapsed && ("%i days" % record.average_elapsed) || 0 : 'n/a'
|
64
|
+
|
65
|
+
- dat[:closed_deal_count] << record.closed_deal_count
|
66
|
+
- dat[:total_elapsed] << record.total_elapsed
|
64
67
|
|
65
68
|
%tfooter
|
66
69
|
%tr{:class => 'record-totals'}
|
@@ -75,14 +78,18 @@
|
|
75
78
|
%td.record-deal-count.num
|
76
79
|
= dat[:deal_count].sum.to_i
|
77
80
|
%td.record-won-deal-count.num
|
78
|
-
= dat[:won_deal_count].sum.to_i
|
81
|
+
= won_deal_count = dat[:won_deal_count].sum.to_i
|
79
82
|
%td.record-total-value.num
|
80
|
-
=
|
83
|
+
- total_value = dat[:total_value].compact.sum
|
84
|
+
= m(total_value)
|
81
85
|
%td.record-average-value.num
|
82
|
-
= m
|
86
|
+
= m(total_value.to_f / won_deal_count)
|
83
87
|
%td.record-total-cost.num
|
84
|
-
=
|
88
|
+
- total_cost = dat[:total_cost].compact.sum
|
89
|
+
= m(total_cost)
|
85
90
|
%td.record-average-cost.num
|
86
|
-
= m
|
91
|
+
= m(total_cost.to_f / won_deal_count)
|
87
92
|
%td.record-average-elapsed.num
|
88
|
-
=
|
93
|
+
- total_elapsed = dat[:total_elapsed].compact.sum.to_f
|
94
|
+
- closed_deal_count = dat[:closed_deal_count].sum.to_i
|
95
|
+
= "%i days" % (total_elapsed / closed_deal_count)
|
@@ -33,7 +33,7 @@ module E9Crm::Rack
|
|
33
33
|
contacts = []
|
34
34
|
end
|
35
35
|
|
36
|
-
[200, {"Content-Type" => "application/json", "Cache-Control" => "
|
36
|
+
[200, {"Content-Type" => "application/json", "Cache-Control" => "no-cache"}, [contacts.to_json]]
|
37
37
|
else
|
38
38
|
[404, {"Content-Type" => "text/html", "X-Cascade" => "pass"}, ["Not Found"]]
|
39
39
|
end
|
data/lib/e9_crm/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: e9_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.25
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Travis Cox
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-26 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|