From 2b32a88a8e9f1d0bb5055843ac987d9cb9981803 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 2 May 2021 20:21:04 -0400 Subject: Add Activities --- app/models/activity.rb | 3 +++ data/activities.yml | 30 ++++++++++++++++++++++++++ db/migrate/20210503001859_create_activities.rb | 12 +++++++++++ db/schema.rb | 11 +++++++++- db/seeds.rb | 5 +++++ test/fixtures/activities.yml | 13 +++++++++++ test/models/activity_test.rb | 7 ++++++ 7 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 app/models/activity.rb create mode 100644 data/activities.yml create mode 100644 db/migrate/20210503001859_create_activities.rb create mode 100644 test/fixtures/activities.yml create mode 100644 test/models/activity_test.rb diff --git a/app/models/activity.rb b/app/models/activity.rb new file mode 100644 index 0000000..2f93564 --- /dev/null +++ b/app/models/activity.rb @@ -0,0 +1,3 @@ +class Activity < ApplicationRecord + validates :gid, :name, :description, presence: true +end diff --git a/data/activities.yml b/data/activities.yml new file mode 100644 index 0000000..15bd3e2 --- /dev/null +++ b/data/activities.yml @@ -0,0 +1,30 @@ +quarry_floret_mines: + name: "Quarry Floret Mines" + description: "Planequarry at the Floret Mines." + whatnot: + duration: + base: 70 + minimum: 35 + scaling: + planequarry: 2 + results: + - item: + chance: 1 + table: + stone: 0 + - item: + chance: 1 + table: + crude_iron_ore: 0 + iron_ore: 0.98 + pure_iron_ore: 0.996 + table_scaling: + skills: + planequarry: 1.25 + - item: + chance: 0.02 + table: + red_beryl: 0 + tourmaline: 0.45 + yellow_beryl: 0.90 + paraiba_tourmaline: 0.95 diff --git a/db/migrate/20210503001859_create_activities.rb b/db/migrate/20210503001859_create_activities.rb new file mode 100644 index 0000000..883d82a --- /dev/null +++ b/db/migrate/20210503001859_create_activities.rb @@ -0,0 +1,12 @@ +class CreateActivities < ActiveRecord::Migration[6.1] + def change + create_table :activities do |t| + t.string :gid + t.string :name + t.text :description + t.jsonb :whatnot + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 67fd0f5..85aa952 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,20 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_05_02_212517) do +ActiveRecord::Schema.define(version: 2021_05_03_001859) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "activities", force: :cascade do |t| + t.string "gid" + t.string "name" + t.text "description" + t.jsonb "whatnot" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "items", force: :cascade do |t| t.string "gid" t.string "name" diff --git a/db/seeds.rb b/db/seeds.rb index 2008d89..00a0566 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -24,3 +24,8 @@ load_data_file("data/items.yml").map do |gid, hash| item.whatnot = hash[:whatnot] item.save end + +load_data_file("data/activities.yml").map do |gid, hash| + activity = Activity.find_or_create_by(gid: gid) + activity.update(hash) +end diff --git a/test/fixtures/activities.yml b/test/fixtures/activities.yml new file mode 100644 index 0000000..6a7ba8a --- /dev/null +++ b/test/fixtures/activities.yml @@ -0,0 +1,13 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + gid: MyString + name: MyString + description: MyText + whatnot: + +two: + gid: MyString + name: MyString + description: MyText + whatnot: diff --git a/test/models/activity_test.rb b/test/models/activity_test.rb new file mode 100644 index 0000000..c07a8b9 --- /dev/null +++ b/test/models/activity_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class ActivityTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end -- cgit v1.2.3