feat: preload label list

This commit is contained in:
Shivam Mishra
2023-05-04 12:56:06 +05:30
parent b081fe08b8
commit 9cff6c04ee
2 changed files with 13 additions and 2 deletions
+11
View File
@@ -13,4 +13,15 @@ module Labelable
new_labels << labels
update!(label_list: new_labels)
end
def preloaded_label_list
unless @taggings_cache
@taggings_cache = []
taggings.each do |tagging|
@taggings_cache << tagging.tag.name
end
end
@taggings_cache || []
end
end
@@ -33,7 +33,7 @@ json.can_reply conversation.can_reply?
json.contact_last_seen_at conversation.contact_last_seen_at.to_i
json.custom_attributes conversation.custom_attributes
json.inbox_id conversation.inbox_id
json.labels conversation.label_list
json.labels conversation.preloaded_label_list
json.muted conversation.muted?
json.snoozed_until conversation.snoozed_until
json.status conversation.status
@@ -42,4 +42,4 @@ json.timestamp conversation.last_activity_at.to_i
json.first_reply_created_at conversation.first_reply_created_at.to_i
json.unread_count conversation.unread_incoming_messages.count
json.last_non_activity_message conversation.messages.non_activity_messages.first.try(:push_event_data)
json.priority conversation.priority
json.priority conversation.priority