feat: Overview heatmap improvements (#12359)
This PR adds inbox filtering to the conversation traffic heatmap, allowing users to analyze patterns for specific inboxes. Additionally, it also adds a new resolution count heatmap that shows when support teams are most active in resolving conversations, using a green color to distinguish it from the blue conversation heatmap. The PR also reorganizes heatmap components into a cleaner structure with a shared `BaseHeatmapContainer` that handles common functionality like date range selection, inbox filtering, and data fetching. This makes it easy to add new heatmap metrics in the future - just create a wrapper component specifying the metric type and color scheme. <img width="1926" height="1670" alt="CleanShot 2025-10-13 at 14 01 35@2x" src="https://github.com/user-attachments/assets/67822a34-6170-4d19-9e11-7ad4ded5c388" /> <img width="1964" height="1634" alt="CleanShot 2025-10-13 at 14 03 00@2x" src="https://github.com/user-attachments/assets/e4613c08-64b8-4fa6-91d8-7510946dd75d" /> Unrelated change, the data seeder conversation resolution would not work correctly, we've fixed it. --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -16,8 +16,11 @@ class Seeders::Reports::ConversationCreator
|
||||
@priorities = [nil, 'urgent', 'high', 'medium', 'low']
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def create_conversation(created_at:)
|
||||
conversation = nil
|
||||
should_resolve = false
|
||||
resolution_time = nil
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
travel_to(created_at) do
|
||||
@@ -26,14 +29,35 @@ class Seeders::Reports::ConversationCreator
|
||||
|
||||
add_labels_to_conversation(conversation)
|
||||
create_messages_for_conversation(conversation)
|
||||
resolve_conversation_if_needed(conversation)
|
||||
|
||||
# Determine if should resolve but don't update yet
|
||||
should_resolve = rand > 0.3
|
||||
if should_resolve
|
||||
resolution_delay = rand((30.minutes)..(24.hours))
|
||||
resolution_time = created_at + resolution_delay
|
||||
end
|
||||
end
|
||||
|
||||
travel_back
|
||||
end
|
||||
|
||||
# Now resolve outside of time travel if needed
|
||||
if should_resolve && resolution_time
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
conversation.update_column(:status, :resolved)
|
||||
conversation.update_column(:updated_at, resolution_time)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
|
||||
# Trigger the event with proper timestamp
|
||||
travel_to(resolution_time) do
|
||||
trigger_conversation_resolved_event(conversation)
|
||||
end
|
||||
travel_back
|
||||
end
|
||||
|
||||
conversation
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
private
|
||||
|
||||
@@ -85,16 +109,6 @@ class Seeders::Reports::ConversationCreator
|
||||
message_creator.create_messages
|
||||
end
|
||||
|
||||
def resolve_conversation_if_needed(conversation)
|
||||
return unless rand < 0.7
|
||||
|
||||
resolution_delay = rand((30.minutes)..(24.hours))
|
||||
travel(resolution_delay)
|
||||
conversation.update!(status: :resolved)
|
||||
|
||||
trigger_conversation_resolved_event(conversation)
|
||||
end
|
||||
|
||||
def trigger_conversation_resolved_event(conversation)
|
||||
event_data = { conversation: conversation }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user