wco_models 3.1.0.175 → 3.1.0.176

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: a05466d095355ec09936c5f72861b3292b272866d603196be5ace081f657c978
4
- data.tar.gz: 00af6f41df7a96e17cab793b68b2fb5f4cedf6f84582c956ea1924ee3c0a42d6
3
+ metadata.gz: 17d234b960f5061db8dd3236d041580aec9252b78a97dd7a27e6c07e57a9cc53
4
+ data.tar.gz: 3aba8e65bd0e8797b6d34dfb64e5ec6f76a05265c4dc4b24474129758a3d5c80
5
5
  SHA512:
6
- metadata.gz: b5d501169a2186a206ce0ff1cad4875bf6fd0bf1bb3cd90aa1ee93c6f33f55e30f974c63a6a268c19f5237d464385098e18aa6c9adbd3b950d32551960c22403
7
- data.tar.gz: e3095c492065d542c85b29c93e54bce2bd0b7d6d653c6adbed89e9f230a57254c8155f39a7daefcfc2bb594c2a3fab4fb5b65cb1cd705332ba35b2d9c26eb797
6
+ metadata.gz: 2117c701ac79832bee70a447f850f6828a9926ecb0d1dd4adcc4e9453de87b56f105ebc2cd1d0ae30bc73ab1dd99bafbc0e068e9d7da0fe39a5aa75ed2b585bd
7
+ data.tar.gz: d983e4bf6ebcb148233487d52cea7d58b0c532342099a4c20212f93190439ead3ad036a06570ec12e7947de98740145d3971cc38024b1f464f930726aa816ffc
@@ -33,6 +33,48 @@ class WcoEmail::Conversation
33
33
 
34
34
  belongs_to :filter, class_name: 'WcoEmail::EmailFilter', inverse_of: :conversations, optional: true
35
35
 
36
+ def self.load_conversations_messages_tag_by_params_and_profile params, current_profile
37
+ @conversations = WcoEmail::Conversation.all
38
+
39
+ if params[:tagname]
40
+ @tag = Wco::Tag.find_by slug: params[:tagname]
41
+ @conversations = @conversations.where( :tag_ids.in => [ @tag.id ] )
42
+ end
43
+ if params[:tagname_not]
44
+ @tag_not = Wco::Tag.find_by slug: params[:tagname_not]
45
+ @conversations = @conversations.where( :tag_ids.nin => [ @tag_not.id ] )
46
+ end
47
+
48
+ if params[:subject].present?
49
+ @conversations = @conversations.where({ subject: /.*#{params[:subject]}.*/i })
50
+ end
51
+
52
+ if params[:from_email].present?
53
+ @conversations = @conversations.where({ from_emails: /.*#{params[:from_email]}.*/i })
54
+ end
55
+
56
+ if params[:lead_id].present?
57
+ @conversations = @conversations.where( lead_ids: params[:lead_id] )
58
+ end
59
+
60
+ @conversations = @conversations.where(
61
+ ).includes( :leads, :messages, :tags
62
+ ).order_by( latest_at: :desc
63
+ ).page( params[:conv_page] ).per( current_profile.per_page )
64
+
65
+ conversation_ids = @conversations.map &:id
66
+ messages = WcoEmail::Message.where(
67
+ :conversation_id.in => conversation_ids,
68
+ read_at: nil,
69
+ )
70
+ @messages_hash = {}
71
+ messages.map do |msg|
72
+ @messages_hash[msg.id.to_s] = msg
73
+ end
74
+
75
+ return [ @conversations, @messages_hash, @tag ]
76
+ end
77
+
36
78
  def cache_key
37
79
  "#{self.class.name} #{id.to_s} #{updated_at}"
38
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.175
4
+ version: 3.1.0.176
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-24 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ahoy_matey