pont 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pont/comp_attributes.rb +71 -0
- data/lib/pont/version.rb +1 -1
- data/lib/pont.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8cc14f121d178db09510fe185e0e677a6b32a69
|
4
|
+
data.tar.gz: c22b0f25278e599e565c378a12136795fa21755a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81a4c36c3f7d066f0cebadf410da2301c9ac1e48cea17614c2e70b76ae772610e91ea8eb0b5a3d98e759d19cd0364ec00b57e1ced226a53f966baa8d6816be15
|
7
|
+
data.tar.gz: 241561e10cb29fc2c6dfd5d39e9d242a0ffd733b1cfa232b053a501b49782e43b0c6dc11740e9376795f4504c97fd2fe3ff337586dae5b907d16935d568c6ca9
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pont
|
4
|
+
class CompAttributes
|
5
|
+
BASE = [
|
6
|
+
:channel_code,
|
7
|
+
:contract_type_code,
|
8
|
+
:enrollment_type,
|
9
|
+
:in_gas_eligible_market,
|
10
|
+
:market_code,
|
11
|
+
:office_code,
|
12
|
+
:order_type,
|
13
|
+
:plan_comp_filter,
|
14
|
+
:product_type_code,
|
15
|
+
:sourced_by_source_code,
|
16
|
+
:valid_email
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
PIVOT = [
|
20
|
+
:account_confirmed_start_dt,
|
21
|
+
:account_offer_reason,
|
22
|
+
:account_status,
|
23
|
+
:avg_annual_usage,
|
24
|
+
:campaign_code,
|
25
|
+
:comp_ineligible_dt,
|
26
|
+
:comp_type_code,
|
27
|
+
:confirmed_start_dt,
|
28
|
+
:failed_validation,
|
29
|
+
:installation_required,
|
30
|
+
:is_cancelled,
|
31
|
+
:is_duplicate,
|
32
|
+
:is_partial,
|
33
|
+
:is_rejected,
|
34
|
+
:is_rescinded,
|
35
|
+
:is_winback,
|
36
|
+
:payable_status_reason,
|
37
|
+
:revenue_class_code,
|
38
|
+
:sale_dt,
|
39
|
+
:state_code,
|
40
|
+
:total_residuals
|
41
|
+
].concat(BASE).sort.freeze
|
42
|
+
|
43
|
+
# TODO: Move this to after party
|
44
|
+
# Run this in garcon after adding new attributes
|
45
|
+
# heroku run padrino runner "Pont::CompAttributes.create_pivot" --remote production
|
46
|
+
def self.create_pivot
|
47
|
+
quoted_attributes = PIVOT.map { |attribute| "$$#{attribute}$$" }.join(', ')
|
48
|
+
typed_attributes = PIVOT.map { |attribute| "#{attribute} text" }.join(', ')
|
49
|
+
|
50
|
+
if defined?(Rails)
|
51
|
+
ApplicationRecord.transaction do
|
52
|
+
ActiveRecord::Base.connection.execute('DROP VIEW IF EXISTS "comp_attribute_pivot"')
|
53
|
+
query = %(
|
54
|
+
CREATE VIEW \"comp_attribute_pivot\" AS
|
55
|
+
select * from crosstab('select comp_id, comp_attribute_key, comp_attribute_value from comp_attributes
|
56
|
+
order by 1, 2'::text,
|
57
|
+
'select unnest(array[?])'::text) comp_attributes(comp_id integer, ?)
|
58
|
+
order by comp_id
|
59
|
+
)
|
60
|
+
sanitized_query = ActiveRecord::Base.send(:sanitize_sql_array, [query, quoted_attributes, typed_attributes])
|
61
|
+
ActiveRecord::Base.connection.execute(sanitized_query)
|
62
|
+
end
|
63
|
+
else
|
64
|
+
Sequel::Model.db.transaction do
|
65
|
+
Sequel::Model.db.drop_view(:comp_attribute_pivot, if_exists: true)
|
66
|
+
Sequel::Model.db.create_view(:comp_attribute_pivot, "select * from crosstab('select comp_id, comp_attribute_key, comp_attribute_value from comp_attributes order by 1, 2'::text, 'select unnest(array[#{quoted_attributes}])'::text) comp_attributes(comp_id integer, #{typed_attributes}) order by comp_id")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/pont/version.rb
CHANGED
data/lib/pont.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pont
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Marren
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- bin/setup
|
101
101
|
- lib/pont.rb
|
102
102
|
- lib/pont/attribution.rb
|
103
|
+
- lib/pont/comp_attributes.rb
|
103
104
|
- lib/pont/configuration.rb
|
104
105
|
- lib/pont/logger.rb
|
105
106
|
- lib/pont/prospect_event.rb
|