feat: Add team assignment & filter APIs (#1712)

This commit is contained in:
Sojan Jose
2021-01-31 12:40:02 +05:30
committed by GitHub
parent b0563a666e
commit 0ff81e3b53
4 changed files with 70 additions and 5 deletions

View File

@@ -22,10 +22,12 @@ class ConversationFinder
def perform
set_inboxes
set_team
set_assignee_type
find_all_conversations
filter_by_status unless params[:q]
filter_by_team if @team
filter_by_labels if params[:labels]
filter_by_query if params[:q]
@@ -61,6 +63,10 @@ class ConversationFinder
@assignee_type = params[:assignee_type]
end
def set_team
@team = current_account.teams.find(params[:team_id]) if params[:team_id]
end
def find_all_conversations
@conversations = current_account.conversations.where(inbox_id: @inbox_ids)
end
@@ -87,6 +93,10 @@ class ConversationFinder
@conversations = @conversations.where(status: params[:status] || DEFAULT_STATUS)
end
def filter_by_team
@conversations = @conversations.where(team: @team)
end
def filter_by_labels
@conversations = @conversations.tagged_with(params[:labels], any: true)
end