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
69 70 71 72 73 |
# File 'lib/office/email_conversation.rb', line 69 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
75 76 77 78 79 |
# File 'lib/office/email_conversation.rb', line 75 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
44 45 46 47 48 49 50 51 |
# File 'lib/office/email_conversation.rb', line 44 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
64 65 66 67 |
# File 'lib/office/email_conversation.rb', line 64 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: []
28 29 30 |
# File 'lib/office/email_conversation.rb', line 28 def leads Lead.find( lead_ties.map( &:lead_id ) ) end |
#remove_tag(which) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/office/email_conversation.rb', line 53 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
62 |
# File 'lib/office/email_conversation.rb', line 62 def rmtag which; remove_tag which; end |
#tags ⇒ Object
39 40 41 |
# File 'lib/office/email_conversation.rb', line 39 def WpTag.find( .map( &:wp_term_id ) ) end |
#wp_term_ids ⇒ Object
@TODO: remove vp 2023-09-23
35 36 37 |
# File 'lib/office/email_conversation.rb', line 35 def wp_term_ids ## @TODO: remove _vp_ 2023-09-23 .map( &:wp_term_id ) end |