Class: Office::EmailConversation
- Inherits:
-
Object
- Object
- Office::EmailConversation
- Includes:
- Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
- Defined in:
- lib/office/email_conversation.rb
Constant Summary collapse
- STATE_UNREAD =
'state_unread'- STATE_READ =
'state_read'- STATES =
[ STATE_UNREAD, STATE_READ ]
Class Method Summary collapse
Instance Method Summary collapse
-
#add_tag(which) ⇒ Object
Tested manually ok, does not pass the spec.
- #in_emailtag?(which) ⇒ Boolean
-
#leads ⇒ Object
def lead_ids email_conversation_leads.map( &:lead_id ) end field :lead_ids, type: :array, default: [].
- #remove_tag(which) ⇒ Object
-
#rmtag(which) ⇒ Object
@deprecated, do not use.
- #tags ⇒ Object
-
#wp_term_ids ⇒ Object
@TODO: remove vp 2023-09-23.
Class Method Details
.in_emailtag(which) ⇒ Object
67 68 69 70 71 |
# File 'lib/office/email_conversation.rb', line 67 def self.in_emailtag which tag = WpTag.iso_get( which ) = Office::EmailConversationTag.where({ wp_term_id: tag.id }) where({ :id.in => .map(&:email_conversation_id) }) end |
.not_in_emailtag(which) ⇒ Object
73 74 75 76 77 |
# File 'lib/office/email_conversation.rb', line 73 def self.not_in_emailtag which tag = WpTag.iso_get( which ) = Office::EmailConversationTag.where({ wp_term_id: tag.id }) where({ :id.nin => .map(&:email_conversation_id) }) end |
Instance Method Details
#add_tag(which) ⇒ Object
Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? vp 2023-03-07
42 43 44 45 46 47 48 49 |
# File 'lib/office/email_conversation.rb', line 42 def add_tag which tag = WpTag.iso_get which # puts!( tag.slug, "Adding tag" ) if DEBUG Office::EmailConversationTag.find_or_create_by!({ email_conversation_id: id, wp_term_id: tag.id, }) end |
#in_emailtag?(which) ⇒ Boolean
62 63 64 65 |
# File 'lib/office/email_conversation.rb', line 62 def in_emailtag? which tag = WpTag.iso_get( which ) .where({ wp_term_id: tag.id }).present? end |
#leads ⇒ Object
def lead_ids
email_conversation_leads.map( &:lead_id )
end field :lead_ids, type: :array, default: []
26 27 28 |
# File 'lib/office/email_conversation.rb', line 26 def leads Lead.find( lead_ties.map( &:lead_id ) ) end |
#remove_tag(which) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/office/email_conversation.rb', line 51 def remove_tag which tag = WpTag.iso_get which # puts!( tag.slug, "Removing tag" ) if DEBUG Office::EmailConversationTag.where({ email_conversation_id: id, wp_term_id: tag.id, }).first&.delete end |
#rmtag(which) ⇒ Object
@deprecated, do not use. vp 2023-10-29
60 |
# File 'lib/office/email_conversation.rb', line 60 def rmtag which; remove_tag which; end |
#tags ⇒ Object
37 38 39 |
# File 'lib/office/email_conversation.rb', line 37 def WpTag.find( .map( &:wp_term_id ) ) end |
#wp_term_ids ⇒ Object
@TODO: remove vp 2023-09-23
33 34 35 |
# File 'lib/office/email_conversation.rb', line 33 def wp_term_ids ## @TODO: remove _vp_ 2023-09-23 .map( &:wp_term_id ) end |