diff --git a/app/controllers/api/v1/curura/games_controller.rb b/app/controllers/api/v1/curura/games_controller.rb index 1c5c2eb..edbf4d0 100644 --- a/app/controllers/api/v1/curura/games_controller.rb +++ b/app/controllers/api/v1/curura/games_controller.rb @@ -11,7 +11,7 @@ def create private def game_params - params.require(:game).permit(:country, :score, :timezone) + params.require(:game).permit(:country, :score, :timezone, :start_time) end end end diff --git a/app/models/curura/game.rb b/app/models/curura/game.rb index eae16f9..5124e22 100644 --- a/app/models/curura/game.rb +++ b/app/models/curura/game.rb @@ -1,7 +1,9 @@ -class Curura::Game < ApplicationRecord - validates :score, :country, :start_time, presence: true +module Curura + class Game < ApplicationRecord + validates :score, :country, :start_time, presence: true - scope :today, -> { where("start_time >= ?", Time.zone.now.beginning_of_day) } - scope :won_above_score, ->(score) { where("score > ?", score) } - scope :country, ->(country) { where(country: country) } + scope :today, -> { where("start_time >= ?", Time.zone.now.beginning_of_day) } + scope :won_above_score, ->(score) { where("score > ?", score) } + scope :country, ->(country) { where(country: country) } + end end diff --git a/db/migrate/20240412170557_change_score_float_to_int_for_curura_games.rb b/db/migrate/20240412170557_change_score_float_to_int_for_curura_games.rb new file mode 100644 index 0000000..9138230 --- /dev/null +++ b/db/migrate/20240412170557_change_score_float_to_int_for_curura_games.rb @@ -0,0 +1,5 @@ +class ChangeScoreFloatToIntForCururaGames < ActiveRecord::Migration[7.1] + def change + change_column :curura_games, :score, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 3d6462e..ac0712a 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[7.1].define(version: 2024_04_11_175622) do +ActiveRecord::Schema[7.1].define(version: 2024_04_12_170557) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -21,7 +21,7 @@ end create_table "curura_games", force: :cascade do |t| - t.float "score", default: 0.0 + t.integer "score", default: 0 t.string "country" t.datetime "start_time" t.datetime "created_at", null: false