Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(CE): data app report model changes #445

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/app/models/data_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class DataApp < ApplicationRecord
belongs_to :workspace
has_many :visual_components, dependent: :destroy
has_many :models, through: :visual_components
has_many :feedbacks, through: :visual_components
has_many :data_app_sessions, dependent: :nullify

after_initialize :set_default_status, if: :new_record?
Expand Down
1 change: 1 addition & 0 deletions server/app/models/feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Feedback < ApplicationRecord
belongs_to :data_app
belongs_to :visual_component
belongs_to :model
belongs_to :workspace

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

Expand Down
13 changes: 13 additions & 0 deletions server/spec/factories/feedback.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

FactoryBot.define do
factory :feedback do
association :data_app
association :visual_component
association :workspace
association :model
session_id { SecureRandom.hex(10) }
feedback_type { "thumbs" }
reaction { "positive" }
end
end
1 change: 1 addition & 0 deletions server/spec/models/data_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
it { should have_many(:visual_components).dependent(:destroy) }
it { should have_many(:models).through(:visual_components) }
it { should have_many(:data_app_sessions).dependent(:nullify) }
it { should have_many(:feedbacks).through(:visual_components) }
end

describe "#set_default_status" do
Expand Down
1 change: 1 addition & 0 deletions server/spec/models/feedback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
it { should belong_to(:data_app) }
it { should belong_to(:visual_component) }
it { should belong_to(:model) }
it { should belong_to(:workspace) }
end

describe "validations" do
Expand Down