ish_manager 0.1.8.340 → 0.1.8.342

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b4184b0ea29ec3dfaba9dcdc6ed2dee035b6232a18902bbaaadfdfa4b19a99b
4
- data.tar.gz: c686465e885ba4bb5c96a53d8c85306691db5a3eb52fcdb66a4a5fffa2e5f3fa
3
+ metadata.gz: 31dc721f8085acc082c40407f49b1d43d5e2fdea662ec65baab7518d05e59bc6
4
+ data.tar.gz: 92623cdaabf812aa4949bb91f8316fd9173cc6553df79cb04f5027c4d46da49b
5
5
  SHA512:
6
- metadata.gz: 30b9137f89b5d97a384638c126f0b20f83f0cf75031a9bc8f55712f8d72f76031ad711614843664de0d64eaf07e6d066a40cc15e2a6cb67be6be792a863f1553
7
- data.tar.gz: fd5f044e36f07fb45c5e232ff678518ec487461de77c6f6e6723c1b5a1d8b3570e49ccad3bbf4e4f08457cbb41df479362ac15f72aeeab9dd2af8e9a808a4126
6
+ metadata.gz: 747bafb898ed79e8d7a8fd09a381221745733082b69214a1512d100d4ce5997daef0d4f9261d0311991d93d02483c4f8917648be5241915217d1b09188d7e438
7
+ data.tar.gz: 31e72f77b079430987187711798a1b0744739cd3d73958757c2c393277aae95ae85f569fff846b0213d2b5c94f13db0bf37e248537edd022c17fd32bbe67bdbd
@@ -71,9 +71,15 @@ class ::IshManager::EmailContextsController < ::IshManager::ApplicationControlle
71
71
  def index
72
72
  authorize! :index, ::Ish::EmailContext
73
73
  @email_ctxs = ::Ish::EmailContext.all
74
+
74
75
  if params[:notsent]
75
76
  @email_ctxs = @email_ctxs.where( sent_at: nil )
76
77
  end
78
+
79
+ if params[:type]
80
+ @email_ctxs = @email_ctxs.where( type: params[:type] )
81
+ end
82
+
77
83
  @email_ctxs = @email_ctxs.page( params[Ish::EmailContext::PAGE_PARAM_NAME] )
78
84
  end
79
85
 
@@ -38,9 +38,62 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
38
38
  authorize! :edit, @lead
39
39
  end
40
40
 
41
+ ## 0 1 2 3 4 5 6 7 8
42
+ ## fields: id, date, name, email, company url, source tag, phone, linkedin, comment
43
+ def import
44
+ authorize! :import, ::Lead
45
+ file = params[:csv_file]
46
+ flags = []
47
+ errors = []
48
+ CSV.read(file.path, headers: true).each do |row|
49
+ company_url = row[4].presence
50
+ company_url ||= "https://#{row[3].split('@')[1]}"
51
+ company = ::Leadset.find_or_create_by({ company_url: company_url })
52
+ lead = ::Lead.new({
53
+ name: row[2] || 'there',
54
+ full_name: row[2] || 'there',
55
+ email: row[3],
56
+ m3_leadset_id: company.id,
57
+ phone: row[6],
58
+ })
59
+ flag = lead.save
60
+ flags << flag
61
+ if !flag
62
+ errors << lead.errors.full_messages.join(", ")
63
+ end
64
+ end
65
+ flash[:notice] = "Result: #{flags.inspect} ."
66
+ flash[:alert] = errors
67
+ redirect_to action: 'new'
68
+ end
69
+
41
70
  def index
42
71
  authorize! :index, ::Lead
43
- @leads = ::Lead.all.includes( :leadset )
72
+ @leads = ::Lead.all.includes( :leadset, :email_campaign_leads )
73
+ lead_emails = @leads.map( &:email ).compact.reject(&:empty?)
74
+
75
+ map = %Q{
76
+ function() {
77
+ emit(this.to_email, {count: 1})
78
+ }
79
+ }
80
+ reduce = %Q{
81
+ function(key, values) {
82
+ var result = {count: 0};
83
+ values.forEach(function(value) {
84
+ result.count += value.count;
85
+ });
86
+ return result;
87
+ }
88
+ }
89
+ @email_contexts = {}
90
+ tmp_contexts = Ish::EmailContext.all.where( :to_email.in => lead_emails
91
+ ).map_reduce( map, reduce
92
+ ).out( inline: 1 ## From: https://www.mongodb.com/docs/mongoid/current/reference/map-reduce/
93
+ ).to_a
94
+ tmp_contexts.map { |x| @email_contexts[x[:_id]] = x[:value][:count].to_i }
95
+ # puts! @email_contexts, '@email_contexts'
96
+
44
97
  end
45
98
 
46
99
  def new
@@ -67,8 +120,9 @@ class ::IshManager::LeadsController < IshManager::ApplicationController
67
120
  private
68
121
 
69
122
  def set_lists
123
+ super
70
124
  @leadsets_list = [ [nil,nil] ] + ::Leadset.all.map { |k| [ k.name, k.id ] }
71
- @email_campaigns_list = [ [nil,nil] ] + Ish::EmailContext.all_campaigns.map { |k| [ k.slug, k.id ] }
125
+ @email_campaigns_list = [ [nil,nil] ] + Ish::EmailContext.unsent_campaigns.map { |k| [ k.slug, k.id ] }
72
126
  end
73
127
 
74
128
  end
@@ -61,11 +61,14 @@
61
61
  = link_to 'Meetings', meetings_path
62
62
  = link_to '[+]', new_meeting_path
63
63
  %ul
64
- %li= link_to 'Leads', leads_path
64
+ %li
65
+ = link_to 'Leads', leads_path
66
+ = link_to '[+]', new_lead_path
65
67
  %li= link_to 'Leadsets', leadsets_path
66
68
  %li= link_to 'Email Templates', email_templates_path
67
69
  %li
68
- = link_to 'Contexts/Campaigns', email_contexts_path
70
+ = link_to 'Contexts', email_contexts_path
71
+ = link_to 'Campaigns', email_campaigns_path
69
72
  = link_to '[+]', new_email_context_path
70
73
  = link_to '[to-send]', notsent_email_contexts_path
71
74
  %hr
@@ -7,6 +7,9 @@
7
7
  = link_to '+', new_email_context_path
8
8
  = link_to 'to-send', notsent_email_contexts_path
9
9
 
10
+ %ul.meta
11
+ %li= params[:type]
12
+
10
13
  .W0
11
14
  = render 'paginate', resource: @email_ctxs, param_name: :email_contexts_page, views_prefix: :ish_manager
12
15
 
@@ -0,0 +1,19 @@
1
+
2
+ = form_tag leads_import_path, multipart: true do
3
+ .doc
4
+ %ul
5
+ %li v1 fields: id, date, name, email, company url, source tag, phone, linkedin, comment
6
+ .field
7
+ %label File
8
+ = file_field_tag :csv_file
9
+
10
+ -# .field
11
+ -# %label Leadset
12
+ -# = select_tag :leadset_id, options_for_select(@leadsets_list), class: 'select2'
13
+
14
+ .field
15
+ %label Campaign
16
+ = select_tag :email_campaign_id, options_for_select(@email_campaigns_list), class: 'select2'
17
+
18
+ .actions
19
+ = submit_tag 'Submit'
@@ -1,3 +1,19 @@
1
1
 
2
2
  %h1 Edit lead
3
3
  = render 'form', :lead => @lead
4
+
5
+ %hr
6
+ %h1 Email Campaigns:
7
+ %ul
8
+ - @lead.email_campaign_leads.each do |x|
9
+ %li
10
+ <b>Sent on ::</b> #{x.sent_at.to_s[0..10]}
11
+ <b>Slug ::</b> #{x.email_campaign.slug}
12
+
13
+ %hr
14
+ %h1 Single Emails:
15
+ %ul
16
+ - @lead.email_contexts.each do |x|
17
+ %li
18
+ <b>Sent at ::</b> #{x.sent_at.to_s[0..10]}
19
+ <b>Subject ::</b> #{x.subject}
@@ -18,16 +18,20 @@
18
18
  %th Company
19
19
  %th Email
20
20
  %th Tag
21
+ %th created_at
22
+ %th n campaign sends
23
+ %th n single sends
21
24
 
22
25
  %tbody
23
26
  - @leads.each do |lead|
24
27
  %tr
25
28
  %td= check_box_tag 'lead_ids[]', lead.id
26
29
  %td= link_to lead.name, lead_path( lead )
27
- %td= lead.leadset&.name
30
+ %td= lead.leadset&.id
28
31
  %td= lead.email
29
- -# %td= link_to raw('<i class="fa fa-envelope"></i>'), "mailto:#{lead.email}" if lead.email.present?
30
-
31
-
32
32
  %td= lead.tag
33
+ %td= lead.created_at.to_s[0..10]
34
+ %td= lead.email_campaign_leads.count
35
+ %td= @email_contexts[lead.email] || '-'
36
+
33
37
 
@@ -1,5 +1,8 @@
1
1
 
2
2
  .row
3
- .col.s6.col-sm-offset-3
4
- %h5 New Lead
3
+ .col-sm-12.col-md-6
4
+ %h1 New Lead
5
5
  = render 'form', :lead => @new_lead
6
+ .col-sm-12.col-md-6
7
+ %h1 Import Leads
8
+ = render 'form_import'
@@ -2,41 +2,19 @@
2
2
  - url = leadset.persisted? ? leadset_path( leadset.id ) : leadsets_path
3
3
 
4
4
  = form_for leadset, :as => :leadset, :url => url do |f|
5
- .input-field
6
- = f.label :email
7
- = f.text_field :email
8
5
 
9
- .input-field
10
- = f.label :job_url
11
- = f.text_field :job_url
12
6
  .input-field
13
7
  = f.label :company_url
14
8
  = f.text_field :company_url
15
9
  .input-field
16
- = f.label :yelp_url
17
- = f.text_field :yelp_url
18
-
19
- .input-field
20
- = f.label :company
21
- = f.text_field :company
10
+ = f.label :name
11
+ = f.text_field :name
22
12
  .input-field
23
13
  = f.label :tag
24
14
  = f.text_field :tag
25
15
  .input-field
26
16
  = f.label :location
27
17
  = f.text_field :location
28
- .input-field
29
- = f.label :description
30
- = f.text_area :description
31
- .input-field
32
- = f.label :address
33
- = f.text_area :address
34
- .field
35
- = f.check_box :is_done
36
- = f.label :is_done
37
- .field
38
- = f.check_box :is_trash
39
- = f.label :is_trash
40
18
  .actions{ :style => "margin-top: 1em;" }
41
19
  = f.submit
42
20
 
@@ -10,7 +10,7 @@
10
10
  %thead
11
11
  %tr
12
12
  %th &nbsp;
13
-
13
+ %th created at
14
14
  %th Name
15
15
  %th Tag
16
16
  %th.company-url Company Url
@@ -19,8 +19,8 @@
19
19
  - @leadsets.each do |leadset|
20
20
  %tr
21
21
  %td= check_box_tag leadset.id
22
-
22
+ %td= leadset.created_at.strftime("%Y-%m-%d %H:%M")
23
23
  %td= link_to leadset.name, leadset_path( leadset )
24
24
  %td= leadset.tag
25
- %td= link_to 'B', leadset.company_url if leadset.company_url.present?
25
+ %td= link_to leadset.company_url, leadset.company_url
26
26
  %td= leadset.location
data/config/routes.rb CHANGED
@@ -45,12 +45,13 @@ IshManager::Engine.routes.draw do
45
45
  # office, below
46
46
  #
47
47
 
48
- resources :email_campaigns, as: :email_campaigns
48
+ # resources :email_campaigns, as: :email_campaigns
49
49
 
50
50
  get 'email_contexts/iframe_src/:id', to: 'email_contexts#iframe_src', as: :email_context_iframe
51
51
  get 'email_contexts/new_with/:template_slug', to: 'email_contexts#new'
52
52
  post 'email_contexts/send/:id', to: 'email_contexts#do_send', as: :email_context_send
53
- get 'email_contexts', to: 'email_contexts#index', as: :email_contexts, defaults: { notsent: false }
53
+ get 'email_contexts', to: 'email_contexts#index', as: :email_contexts, defaults: { notsent: false, type: Ish::EmailContext::TYPE_SINGLE }
54
+ get 'email_contexts/campaigns', to: 'email_contexts#index', as: :email_campaigns, defaults: { notsent: false, type: Ish::EmailContext::TYPE_CAMPAIGN }
54
55
  get 'email_contexts/notsent', to: 'email_contexts#index', as: :notsent_email_contexts, defaults: { notsent: true }
55
56
  resources :email_contexts
56
57
 
@@ -64,6 +65,7 @@ IshManager::Engine.routes.draw do
64
65
 
65
66
  get 'leads', :to => 'leads#index'
66
67
  post 'leads/bulkop', to: 'leads#bulkop'
68
+ post 'leads/import', to: 'leads#import', as: :leads_import
67
69
  resources :leads
68
70
 
69
71
  resources :leadsets
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.340
4
+ version: 0.1.8.342
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-25 00:00:00.000000000 Z
11
+ date: 2022-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -374,6 +374,7 @@ files:
374
374
  - app/views/ish_manager/kaminari/_paginator.html.erb
375
375
  - app/views/ish_manager/kaminari/_prev_page.html.erb
376
376
  - app/views/ish_manager/leads/_form.haml
377
+ - app/views/ish_manager/leads/_form_import.haml
377
378
  - app/views/ish_manager/leads/edit.haml
378
379
  - app/views/ish_manager/leads/index.haml
379
380
  - app/views/ish_manager/leads/new.haml