diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb new file mode 100644 index 0000000..f877f55 --- /dev/null +++ b/app/controllers/feedback_controller.rb @@ -0,0 +1,24 @@ +class FeedbackController < ApplicationController + def feature + Feedback.create( + message: feedback_params[:resolvedQuery], + feedback_type: Feedback::FEEDBACK_TYPES[:FEATURE] + ) + + render status: :ok + end + + def bug + Feedback.create( + message: feedback_params[:resolvedQuery], + feedback_type: Feedback::FEEDBACK_TYPES[:BUG] + ) + render status: :ok + end + + private + + def feedback_params + params.require(:result).permit(:resolvedQuery) + end +end diff --git a/app/models/feedback.rb b/app/models/feedback.rb new file mode 100644 index 0000000..7ad5ee4 --- /dev/null +++ b/app/models/feedback.rb @@ -0,0 +1,6 @@ +class Feedback < ActiveRecord::Base + FEEDBACK_TYPES = { + BUG: :BUG, + FEATURE: :FEATURE, + } +end diff --git a/config/routes.rb b/config/routes.rb index e6240a9..7e23d1a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,11 @@ post :patch, to: 'application#patch' post :reset, to: 'application#reset' + namespace :feedback do + post :bug + post :feature + end + namespace :champions do post :title post :ally_tips diff --git a/db/migrate/20180213073704_create_feedback.rb b/db/migrate/20180213073704_create_feedback.rb new file mode 100644 index 0000000..7c9f39e --- /dev/null +++ b/db/migrate/20180213073704_create_feedback.rb @@ -0,0 +1,9 @@ +class CreateFeedback < ActiveRecord::Migration[5.0] + def change + create_table :feedbacks do |t| + t.timestamps + t.string :message + t.string :feedback_type + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5d248dd..a1a8c9a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171028221812) do +ActiveRecord::Schema.define(version: 20180213073704) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -25,6 +25,13 @@ t.index ["summoner_performance_id"], name: "index_bans_on_summoner_performance_id", unique: true, using: :btree end + create_table "feedbacks", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "message" + t.string "feedback_type" + end + create_table "matches", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false