diff --git a/.gitignore b/.gitignore index e553419..63c4bf6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Temporary files generated by your text editor or operating system # belong in git's global ignore instead: # `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` +.idea # Ignore bundler config. /.bundle diff --git a/.idea/gambosite.iml b/.idea/gambosite.iml index 9b6b960..c47f4f1 100644 --- a/.idea/gambosite.iml +++ b/.idea/gambosite.iml @@ -79,7 +79,6 @@ - @@ -154,78 +153,76 @@ diff --git a/Gemfile b/Gemfile index b2a3552..8b205ef 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,6 @@ source "https://rubygems.org" gem "rails", "~> 8.0.0" # The modern asset pipeline for Rails [https://github.com/rails/propshaft] gem "propshaft" -# Use mysql as the database for Active Record -gem "mysql2", "~> 0.5" # Use the Puma web server [https://github.com/puma/puma] gem "puma", ">= 5.0" # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] diff --git a/Gemfile.lock b/Gemfile.lock index 3199bcb..8620bb4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,7 +155,6 @@ GEM mini_mime (1.1.5) minitest (5.25.4) msgpack (1.7.5) - mysql2 (0.5.6) net-imap (0.5.5) date net-protocol @@ -374,7 +373,6 @@ DEPENDENCIES importmap-rails jbuilder kamal - mysql2 (~> 0.5) propshaft puma (>= 5.0) rails (~> 8.0.0) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 5da34c4..8bc4b91 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -54,4 +54,16 @@ class AdminController < ApplicationController session.delete(:user_id) redirect_to root_path, notice: "Logged out!" end + + def set_lootban(name) + if Lootban.count == 0 + Lootban.create(name: name) + else + Lootban.first.name = name + end + end + + def delete_lootban + Lootban.delete_all + end end diff --git a/app/controllers/leaderboard_controller.rb b/app/controllers/leaderboard_controller.rb index 2bdcd59..4b23a64 100644 --- a/app/controllers/leaderboard_controller.rb +++ b/app/controllers/leaderboard_controller.rb @@ -1,5 +1,6 @@ class LeaderboardController < ApplicationController def index @players = Player.where(main_player_id: nil).order(purse: :desc) + @lootban = Lootban.first&.name || "Nobody... yet" end end diff --git a/app/models/lootban.rb b/app/models/lootban.rb new file mode 100644 index 0000000..dfb42d8 --- /dev/null +++ b/app/models/lootban.rb @@ -0,0 +1,2 @@ +class Lootban < ApplicationRecord +end diff --git a/app/views/leaderboard/index.html.erb b/app/views/leaderboard/index.html.erb index 5242ca3..e51ffd5 100644 --- a/app/views/leaderboard/index.html.erb +++ b/app/views/leaderboard/index.html.erb @@ -38,5 +38,5 @@ <% end %>

Current Loot Ban:

-

Belien

+

<%= @lootban %>

diff --git a/db/migrate/20250227233421_create_lootbans.rb b/db/migrate/20250227233421_create_lootbans.rb new file mode 100644 index 0000000..7dae0c7 --- /dev/null +++ b/db/migrate/20250227233421_create_lootbans.rb @@ -0,0 +1,9 @@ +class CreateLootbans < ActiveRecord::Migration[8.0] + def change + create_table :lootbans do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 784a570..57eb92e 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[8.0].define(version: 2025_01_26_011348) do +ActiveRecord::Schema[8.0].define(version: 2025_02_27_233421) do create_table "api_keys", force: :cascade do |t| t.string "key" t.string "client" @@ -32,6 +32,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_26_011348) do t.datetime "updated_at", null: false end + create_table "lootbans", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "players", force: :cascade do |t| t.string "name" t.integer "wins" diff --git a/test/fixtures/lootbans.yml b/test/fixtures/lootbans.yml new file mode 100644 index 0000000..7d41224 --- /dev/null +++ b/test/fixtures/lootbans.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/models/lootban_test.rb b/test/models/lootban_test.rb new file mode 100644 index 0000000..ebefe97 --- /dev/null +++ b/test/models/lootban_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class LootbanTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end