Тестовое

Тестовое


Imagine a small part of some project:

There is an Experience model, each experience has many feedback records and each feedback has many responses. They can be added and deleted.

Look at the file test_assignment.rb, it contains some DB schema details and active record models that are used. The DB contains thousands of experiences and hundreds of thousands of feedback records. One feedback record has many responses, some of them contain score info(how a user evaluate experience).


when you run SQL

SELECT DISTINCT question FROM responses

it returns


  • Let us know what you liked visited this experience
  • Let us know what can be improved
  • Rate the experience


when you run SQL

SELECT DISTINCT answers FROM responses WHERE question = “Rate the experience”

it returns


  • 5 great
  • awesome (5)
  • 4 OK
  • 4
  • not bad 3
  • 2 bad
  • 1 awful


Please provide a solution for each question below:



  • List all the issues(the bigger the best) related to DB structure and code described in the task and possible solution for each issue.
  • Implement #rating on the Experience model to return rating of the experience
  • for example:
  • experience.rating # => 4.33
  • at first, implement the calculator on the fly and it should take an acceptable amount of the time and use server resources as less as possible(don’t change existing DB schema)
  • then, provide a more efficient solution when the rating is stored in the experience model and is changed only on when the server receives feedback creation/destroy request (it requires changes fo the existing DB schema). This solution should work in the concurrent environment(lots of concurrent requests which add/delete feedback responses)
  • describe the pros and cons of each solution implementation above
  • (Optional) Implement the app(similar to described in the task):

  • it should contain a page with experiences list with rating info
  • it should contain a page where user can create a new experience
  • on the provider list page, the user can click button Leave Feedback and leave they feedback(they can’t see other feedback)
  • the app doesn’t need any authentication you can limit feedback by IP address, 1 feedback is allowed for 1 IP
  • the app should contain tests(model/controller unit tests)


* the answers on the second question can be provided as code changes in the test_assignment.rb file.


** "Feedback" is a mass (or non-count, or uncountable) noun. As such, it has no plural form. You can have "some feedback" or "a lot of feedback", but you can't have *"two feedbacks". Unlike some other common mass nouns (like "water"), "feedback" is a pure mass noun- it has no countable meanings or interpretations. 

https://www.google.com/search?q=feedback+plural+form



# == Schema Information
#
# Table name: experiences
#
# id :integer, not null, primary key
# name :string

# Table name: feedback
#
# id :integer, not null, primary key
# experience_id :integer

# Table name: responses
#
# id :integer, not null, primary key
# feedback_id :integer
# question :string
# answer :string

# Indexes
#
# index_responses_on_feedback_id (feedback_id)

# Foreign Keys
#
# fk_rails_... (responses.feedback_id => feedback.id)

class Experience < ActiveRecord
has_many :feedback
end


class Feedback < ActiveRecord
belongs_to :experience
has_many :responses
end

class Response < ActiveRecord
belongs_to :feedback
end



Report Page