Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle
.bundle/

# Ignore all logfiles and tempfiles.
/web/log/*
Expand Down
3 changes: 1 addition & 2 deletions web/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
#gem 'therubyracer', platforms: :ruby
#gem 'mini_racer'
gem 'mini_racer'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'font-awesome-sass', '~> 4.4.0'
gem 'devise'
Expand Down
4 changes: 4 additions & 0 deletions web/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.6)
libv8-node (16.19.0.1)
loofah (2.9.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -124,6 +125,8 @@ GEM
mini_magick (4.11.0)
mini_mime (1.1.0)
mini_portile2 (2.5.0)
mini_racer (0.6.4)
libv8-node (~> 16.19.0.0)
minitest (5.14.4)
nokogiri (1.11.3)
mini_portile2 (~> 2.5.0)
Expand Down Expand Up @@ -275,6 +278,7 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
mini_magick
mini_racer
paranoia (~> 2.0)
rails (= 4.2.11.3)
react-rails (~> 1.5.0)
Expand Down
1 change: 1 addition & 0 deletions web/app/controllers/history_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class HistoryController < ApplicationController
before_action :filter_needs_admin_role, only: [:delete]

def index
RaceSession.get_open_session
@race_sessions = RaceSession.where(active: false).order("id DESC")
end

Expand Down
15 changes: 13 additions & 2 deletions web/app/controllers/system_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ def index
def start_race_session
if !RaceSession::get_open_session
@race_session = RaceSession.new(strong_params_race_session)
@race_session.active = true
if !@race_session.start_date.nil?
@race_session.start_date = @race_session.start_date.midnight
end

if !@race_session.end_date.nil?
@race_session.end_date = @race_session.end_date.end_of_day
end

if @race_session.start_date.nil? || @race_session.start_date < DateTime.current
@race_session.active = true
end

@race_session.save
if ConfigValue.enable_sound
SoundFileWorker.perform_async("sfx_start_race")
Expand Down Expand Up @@ -54,7 +65,7 @@ def get_style_settings
end

def strong_params_race_session
params.require(:race_session).permit(:title, :idle_time_in_seconds, :season_id)
params.require(:race_session).permit(:title, :idle_time_in_seconds, :season_id, :start_date, :end_date)
end

def strong_params_style_settings
Expand Down
14 changes: 13 additions & 1 deletion web/app/models/race_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ class RaceSession < ActiveRecord::Base
after_create :filter_reset_ir_daemon

def self.get_open_session
return RaceSession.where(active: true).first
active = RaceSession.where(active: true).first
if active.nil?
active = RaceSession.where("active IS NULL AND start_date <= ? AND end_date >= ?", DateTime.current, DateTime.current).first
if !active.nil?
active.active = true
active.save
end
elsif !active.end_date.nil? && active.end_date < DateTime.current
active.active = false
active.save
end

return active
end

def self.get_session_from_previous
Expand Down
8 changes: 8 additions & 0 deletions web/app/views/shared/_panel_race_session_control.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
%label{:for => "exampleInputName2"}
= t('race_session.idle_time_in_seconds')
= f.text_field(:idle_time_in_seconds, placeholder: "60", class: 'form-control', required: true)
.form-group
%label{:for => "exampleInputName2"}
= t('race_session.start_date')
= f.date_field(:start_date, class: 'form-control', required: false)
.form-group
%label{:for => "exampleInputName2"}
= t('race_session.end_date')
= f.date_field(:end_date, class: 'form-control', required: false)
%button.btn.btn-success{:type => "submit"}
= t('actions.start_standard_race_session')
.row
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddScheduledDatesToRaceSession < ActiveRecord::Migration
def change
add_column :race_sessions, :start_date, :date
add_column :race_sessions, :end_date, :date
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ChangeScheduledDatesToDateTimesInRaceSession < ActiveRecord::Migration
def up
change_column :race_sessions, :start_date, :datetime
change_column :race_sessions, :end_date, :datetime
end

def down
change_column :race_sessions, :start_date, :date
change_column :race_sessions, :end_date, :date
end
end
12 changes: 12 additions & 0 deletions web/db/migrate/20260419202255_add_indexes_to_pilot_race_laps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AddIndexesToPilotRaceLaps < ActiveRecord::Migration
def change
add_index :pilot_race_laps, :race_session_id,
name: 'idx_prl_race_session'

add_index :pilot_race_laps, [:race_session_id, :pilot_id],
name: 'idx_prl_session_pilot'

add_index :pilot_race_laps, [:race_session_id, :latest, :invalidated],
name: 'idx_prl_session_active'
end
end
7 changes: 6 additions & 1 deletion web/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20250317000853) do
ActiveRecord::Schema.define(version: 20260419202255) do

create_table "config_values", force: :cascade do |t|
t.string "name"
Expand Down Expand Up @@ -41,6 +41,9 @@
add_index "pilot_race_laps", ["lap_num"], name: "index_pilot_race_laps_on_lap_num"
add_index "pilot_race_laps", ["lap_time"], name: "index_pilot_race_laps_on_lap_time"
add_index "pilot_race_laps", ["pilot_id"], name: "index_pilot_race_laps_on_pilot_id"
add_index "pilot_race_laps", ["race_session_id", "latest", "invalidated"], name: "idx_prl_session_active"
add_index "pilot_race_laps", ["race_session_id", "pilot_id"], name: "idx_prl_session_pilot"
add_index "pilot_race_laps", ["race_session_id"], name: "idx_prl_race_session"

create_table "pilots", force: :cascade do |t|
t.string "name"
Expand Down Expand Up @@ -73,6 +76,8 @@
t.boolean "hot_seat_enabled", default: false
t.integer "idle_time_in_seconds", default: 0
t.integer "season_id"
t.datetime "start_date"
t.datetime "end_date"
end

add_index "race_sessions", ["deleted_at"], name: "index_race_sessions_on_deleted_at"
Expand Down
Loading