* refactor: use grid instead of flex * refactor: let the parent layout decide the spacing * feat: add a separate date-range component * refactor: use new date-range component * fix: destructure all options * refactor: separate group by component * refactor: better handle group by data * fix: defaul group by * refactor: variable naming * refactor: use DATE_RANGE_OPTIONS directly * chore: update platform in gemfile.lock * refactor: trigger fetch on filter change * refactor: remove redundant method * refactor: simplify methods and emitting * refactor: simplify filter logic * refactor: simplify fetching * refactor: imports * refactor: prop name * refactor: CSAT response to use new APIs * refactor: use common filter event * refactor: use computed value for validGroupBy * refactor: better function names * refactor: rename prop * refactor: remove redundant props * refactor: separate agents filter component * feat: add labels filter * feat: add inboxes filter * fix: event * refactor: send label and inbox along with request payload * feat: add inbox filter * feat: add inbox to download * refactor: use request payload from computed property * refactor: params * feat: add team to csat filters * feat: add team to csat filters * feat: add filter for rating * feat: reverse options * feat: add labels for ratings and translations * feat: update translation * fix: margin and spacing * fix: trailing whitespace * feat: add tests for filters * chore: move files * feat: add try catch with alerts * feat: update import * fix: imports * Updates broken imports --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
43 lines
1.8 KiB
Ruby
43 lines
1.8 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: csat_survey_responses
|
|
#
|
|
# id :bigint not null, primary key
|
|
# feedback_message :text
|
|
# rating :integer not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# account_id :bigint not null
|
|
# assigned_agent_id :bigint
|
|
# contact_id :bigint not null
|
|
# conversation_id :bigint not null
|
|
# message_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_csat_survey_responses_on_account_id (account_id)
|
|
# index_csat_survey_responses_on_assigned_agent_id (assigned_agent_id)
|
|
# index_csat_survey_responses_on_contact_id (contact_id)
|
|
# index_csat_survey_responses_on_conversation_id (conversation_id)
|
|
# index_csat_survey_responses_on_message_id (message_id) UNIQUE
|
|
#
|
|
class CsatSurveyResponse < ApplicationRecord
|
|
belongs_to :account
|
|
belongs_to :conversation
|
|
belongs_to :contact
|
|
belongs_to :message
|
|
belongs_to :assigned_agent, class_name: 'User', optional: true
|
|
|
|
validates :rating, presence: true, inclusion: { in: [1, 2, 3, 4, 5] }
|
|
validates :account_id, presence: true
|
|
validates :contact_id, presence: true
|
|
validates :conversation_id, presence: true
|
|
|
|
scope :filter_by_created_at, ->(range) { where(created_at: range) if range.present? }
|
|
scope :filter_by_assigned_agent_id, ->(user_ids) { where(assigned_agent_id: user_ids) if user_ids.present? }
|
|
scope :filter_by_inbox_id, ->(inbox_id) { joins(:conversation).where(conversations: { inbox_id: inbox_id }) if inbox_id.present? }
|
|
scope :filter_by_team_id, ->(team_id) { joins(:conversation).where(conversations: { team_id: team_id }) if team_id.present? }
|
|
# filter by rating value
|
|
scope :filter_by_rating, ->(rating) { where(rating: rating) if rating.present? }
|
|
end
|