Skip to content

Commit 6f589e3

Browse files
author
afthab vp
authored
chore(CE): feedback model changes (#862)
1 parent a45d0a7 commit 6f589e3

File tree

12 files changed

+67
-55
lines changed

12 files changed

+67
-55
lines changed

server/app/models/feedback.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ class Feedback < ApplicationRecord
55

66
validates :data_app_id, presence: true
77
validates :visual_component_id, presence: true
8-
validates :model_id, presence: true
98
validates :feedback_type, presence: true
109

1110
counter_culture %i[visual_component data_app]
1211

1312
belongs_to :data_app
1413
belongs_to :visual_component
15-
belongs_to :model
1614
belongs_to :workspace
1715

1816
enum feedback_type: { thumbs: 0, scale_input: 1, text_input: 2, dropdown: 3, multiple_choice: 4 }

server/app/models/message_feedback.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ class MessageFeedback < ApplicationRecord
55

66
validates :data_app_id, presence: true
77
validates :visual_component_id, presence: true
8-
validates :model_id, presence: true
98
validates :feedback_type, presence: true
109
validates :chatbot_interaction, presence: true
1110

1211
counter_culture %i[visual_component data_app]
1312

1413
belongs_to :data_app
1514
belongs_to :visual_component
16-
belongs_to :model
1715
belongs_to :workspace
1816

1917
enum feedback_type: { thumbs: 0, scale_input: 1, text_input: 2, dropdown: 3, multiple_choice: 4 }
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# frozen_string_literal: true
22

33
class FeedbackSerializer < ActiveModel::Serializer
4-
attributes :id, :workspace_id, :data_app_id, :visual_component_id, :model_id, :reaction,
4+
attributes :id, :workspace_id, :data_app_id, :visual_component_id, :model_id, :workflow_id, :reaction,
55
:feedback_content, :created_at, :updated_at, :feedback_type, :session_id,
66
:additional_remarks, :tags
7+
8+
def model_id
9+
object.visual_component.model&.id
10+
end
11+
12+
def workflow_id
13+
object.visual_component.workflow&.id
14+
end
715
end
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# frozen_string_literal: true
22

33
class MessageFeedbackSerializer < ActiveModel::Serializer
4-
attributes :id, :workspace_id, :data_app_id, :visual_component_id, :model_id, :reaction,
4+
attributes :id, :workspace_id, :data_app_id, :visual_component_id, :model_id, :workflow_id, :reaction,
55
:feedback_content, :created_at, :updated_at, :feedback_type, :chatbot_interaction,
66
:additional_remarks, :tags
7+
8+
def model_id
9+
object.visual_component.model&.id
10+
end
11+
12+
def workflow_id
13+
object.visual_component.workflow&.id
14+
end
715
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class RemoveModelIdFromFeedbacksAndMessageFeedbacks < ActiveRecord::Migration[7.1]
2+
def change
3+
safety_assured do
4+
remove_reference :feedbacks, :model, index: true
5+
remove_reference :message_feedbacks, :model, index: true
6+
end
7+
end
8+
end

server/db/schema.rb

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/spec/factories/feedback.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
factory :feedback do
55
data_app { create(:data_app) }
66
visual_component { create(:visual_component) }
7-
model { create(:model) }
87
association :workspace
98
session_id { SecureRandom.hex(10) }
109
feedback_type { "thumbs" }

server/spec/factories/message_feedbacks.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
association :data_app
66
association :visual_component
77
association :workspace
8-
association :model
98
feedback_type { "thumbs" }
109
reaction { "positive" }
1110
chatbot_interaction { { user_query: "Hello", chatbot_reply: "Hi! How can I assist you!" } }

server/spec/interactors/reports/activity_report_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343
)
4444
sync_run_triggered = workspace_activity[:data][:sync_run_triggered]
4545

46-
expect(sync_run_triggered.count).to eq(slice_size)
47-
expect(sync_run_triggered[slice_size - 1]["time_slice"]).not_to be_nil
48-
expect(sync_run_triggered[slice_size - 1]["total_count"]).to eq(2)
49-
expect(sync_run_triggered[slice_size - 1]["success_count"]).to eq(1)
50-
expect(sync_run_triggered[slice_size - 1]["failed_count"]).to eq(1)
46+
expect(sync_run_triggered.count).to be_within(1).of(slice_size)
47+
expect(sync_run_triggered.last["time_slice"]).not_to be_nil
48+
expect(sync_run_triggered.last["total_count"]).to eq(2)
49+
expect(sync_run_triggered.last["success_count"]).to eq(1)
50+
expect(sync_run_triggered.last["failed_count"]).to eq(1)
5151

5252
total_sync_run_rows = workspace_activity[:data][:total_sync_run_rows]
53-
expect(total_sync_run_rows.count).to eq(slice_size)
54-
expect(total_sync_run_rows[slice_size - 1]["time_slice"]).not_to be_nil
55-
expect(total_sync_run_rows[slice_size - 1]["total_count"]).to eq(4)
56-
expect(total_sync_run_rows[slice_size - 1]["success_count"]).to eq(3)
57-
expect(total_sync_run_rows[slice_size - 1]["failed_count"]).to eq(1)
53+
expect(total_sync_run_rows.count).to be_within(1).of(slice_size)
54+
expect(total_sync_run_rows.last["time_slice"]).not_to be_nil
55+
expect(total_sync_run_rows.last["total_count"]).to eq(4)
56+
expect(total_sync_run_rows.last["success_count"]).to eq(3)
57+
expect(total_sync_run_rows.last["failed_count"]).to eq(1)
5858
end
5959
end
6060

server/spec/models/feedback_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
describe "associations" do
77
it { should belong_to(:data_app) }
88
it { should belong_to(:visual_component) }
9-
it { should belong_to(:model) }
109
it { should belong_to(:workspace) }
1110
end
1211

1312
describe "validations" do
1413
it { should validate_presence_of(:data_app_id) }
1514
it { should validate_presence_of(:visual_component_id) }
16-
it { should validate_presence_of(:model_id) }
1715
it { should validate_presence_of(:feedback_type) }
1816
end
1917

0 commit comments

Comments
 (0)