diff --git a/.env.example b/.env.example index 55b998f19..26b1487ae 100644 --- a/.env.example +++ b/.env.example @@ -23,6 +23,9 @@ FORCE_SSL=false ENABLE_ACCOUNT_SIGNUP=false # Redis config +# specify the configs via single URL or individual variables +# ref: https://www.iana.org/assignments/uri-schemes/prov/redis +# You can also use the following format for the URL: redis://:password@host:port/db_number REDIS_URL=redis://redis:6379 # If you are using docker-compose, set this variable's value to be any string, # which will be the password for the redis service running inside the docker-compose diff --git a/app/controllers/api/v1/accounts/conversations/draft_messages_controller.rb b/app/controllers/api/v1/accounts/conversations/draft_messages_controller.rb new file mode 100644 index 000000000..86b7ce5bb --- /dev/null +++ b/app/controllers/api/v1/accounts/conversations/draft_messages_controller.rb @@ -0,0 +1,28 @@ +class Api::V1::Accounts::Conversations::DraftMessagesController < Api::V1::Accounts::Conversations::BaseController + def show + render json: { has_draft: false } and return unless Redis::Alfred.exists?(draft_redis_key) + + draft_message = Redis::Alfred.get(draft_redis_key) + render json: { has_draft: true, message: draft_message } + end + + def update + Redis::Alfred.set(draft_redis_key, draft_message_params) + head :ok + end + + def destroy + Redis::Alfred.delete(draft_redis_key) + head :ok + end + + private + + def draft_redis_key + format(Redis::Alfred::CONVERSATION_DRAFT_MESSAGE, id: @conversation.id) + end + + def draft_message_params + params.dig(:draft_message, :message) || '' + end +end diff --git a/app/helpers/api/v2/accounts/reports_helper.rb b/app/helpers/api/v2/accounts/reports_helper.rb index 74c7af43e..4d5a6f115 100644 --- a/app/helpers/api/v2/accounts/reports_helper.rb +++ b/app/helpers/api/v2/accounts/reports_helper.rb @@ -1,7 +1,7 @@ module Api::V2::Accounts::ReportsHelper def generate_agents_report Current.account.users.map do |agent| - agent_report = generate_report({ type: :agent, id: agent.id }) + agent_report = report_builder({ type: :agent, id: agent.id }).summary [agent.name] + generate_readable_report_metrics(agent_report) end end @@ -15,7 +15,7 @@ module Api::V2::Accounts::ReportsHelper def generate_teams_report Current.account.teams.map do |team| - team_report = generate_report({ type: :team, id: team.id }) + team_report = report_builder({ type: :team, id: team.id }).summary [team.name] + generate_readable_report_metrics(team_report) end end @@ -27,7 +27,7 @@ module Api::V2::Accounts::ReportsHelper end end - def generate_report(report_params) + def report_builder(report_params) V2::ReportBuilder.new( Current.account, report_params.merge( @@ -37,7 +37,11 @@ module Api::V2::Accounts::ReportsHelper business_hours: ActiveModel::Type::Boolean.new.cast(params[:business_hours]) } ) - ).short_summary + ) + end + + def generate_report(report_params) + report_builder(report_params).short_summary end private @@ -46,7 +50,9 @@ module Api::V2::Accounts::ReportsHelper [ report_metric[:conversations_count], Reports::TimeFormatPresenter.new(report_metric[:avg_first_response_time]).format, - Reports::TimeFormatPresenter.new(report_metric[:avg_resolution_time]).format + Reports::TimeFormatPresenter.new(report_metric[:avg_resolution_time]).format, + Reports::TimeFormatPresenter.new(report_metric[:reply_time]).format, + report_metric[:resolutions_count] ] end end diff --git a/app/javascript/dashboard/components/ChannelSelector.vue b/app/javascript/dashboard/components/ChannelSelector.vue index 33877de94..dd9513fb6 100644 --- a/app/javascript/dashboard/components/ChannelSelector.vue +++ b/app/javascript/dashboard/components/ChannelSelector.vue @@ -1,9 +1,9 @@