-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add splitting to races Adds a Split button to races. This button will split if there is at least one segment left in the run, or create a segment then split if not. It will also create a run if one isn't yet attached to the race entry. These two features together can be used to build splits adhoc during a blind or semi-blind races. The API allows you to choose whether to enable this smart behavior by passing `more=1`. When not included, the API will only split in the classical sense, completing the run if you're on the last segment. Includes several other race improvements: - Adds timelines to races for each runner splitting - Timelines (both in & out of races) now have smarter segment widths for in-progress runs (they were previously all equivalent widths) - Adds a "Syncing" spinner to the race page that shows whenever you've performed an action but it hasn't reflected on the page yet due to the worker and/or ActionCable taking an extra bit - The race page is now more aggressive about hiding itself (and showing a spinner) while loading / while navigating away from the page, rather than showing outdated information cached by Turbolinks - The Create Race button no longer shows an error symbol after being clicked & transitioning to the new race page, even though there was no error - Can no longer start editing a race after it has started * CR comments * Rubocop * Pricing overhaul * Clean up an unused ad file, fix some copy * Fix highlight button showing for non-owners * Fix inconsistent button styling on game page * CR comments * Fix split button * Hide Pricing link if already subscribed * Fix advanced charts * Fix a logged-out 500 * Fix subscriptions section on Settings page * Fix another logged-out 500
- Loading branch information
Showing
61 changed files
with
1,101 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
ul.nav.nav-tabs > li.active > a | ||
.nav .active | ||
color: var(--secondary) | ||
cursor: pointer | ||
border-bottom: 1px solid var(--secondary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
.tipsy code | ||
letter-spacing: -.05em | ||
|
||
.info | ||
border-bottom: 1px dashed | ||
cursor: default | ||
display: inline | ||
font-size: 0.7em | ||
|
||
.info:after | ||
content: '?' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
class Api::V4::Races::Entries::SplitsController < Api::V4::Races::EntriesController | ||
before_action :set_time, only: %i[create] | ||
before_action :set_user | ||
before_action :validate_user | ||
before_action :set_race | ||
before_action :set_entry | ||
before_action :set_run | ||
before_action :check_permission | ||
|
||
def create | ||
@run.split( | ||
more: params[:more] == '1', | ||
realtime_end_ms: split_params[:realtime_end_ms], | ||
gametime_end_ms: split_params[:gametime_end_ms], | ||
) | ||
|
||
# If this was the final split | ||
if @run.completed?(Run::REAL) | ||
run_history = @run.histories.order(attempt_number: :asc).last | ||
run_history.update(split_params.merge(ended_at: run_history.started_at + (split_params[:realtime_end_ms] / 1000))) | ||
|
||
# If this was a race run | ||
@run.entry&.update(finished_at: run_history.ended_at) | ||
end | ||
|
||
Api::V4::RaceBroadcastJob.perform_later(@race, 'race_entries_updated', 'A user has split') | ||
|
||
render json: Api::V4::RunBlueprint.render(@run) | ||
end | ||
|
||
private | ||
|
||
def set_time | ||
@now = Time.now.utc | ||
end | ||
|
||
def split_params | ||
params.require(:split).permit( | ||
:realtime_end_ms, | ||
:gametime_end_ms, | ||
:realtime_gold, | ||
:gametime_gold, | ||
:realtime_skipped, | ||
:gametime_skipped, | ||
) | ||
end | ||
|
||
def set_entry | ||
super(param: :entry_id) | ||
end | ||
|
||
def set_run | ||
@run = @entry.run | ||
|
||
@run ||= @entry.create_run( | ||
user: current_user, | ||
category: @race.category, | ||
game: @race.game, | ||
program: 'exchange', | ||
attempts: 0, | ||
s3_filename: SecureRandom.uuid, | ||
realtime_duration_ms: nil, | ||
gametime_duration_ms: nil, | ||
parsed_at: @now, | ||
default_timing: Run::REAL, | ||
) | ||
|
||
return if @run.histories.where(started_at: @entry.race.started_at).any? | ||
|
||
@run.histories.create( | ||
started_at: @entry.race.started_at, | ||
attempt_number: @run.histories.order(attempt_number: :asc).last, | ||
pause_duration_ms: 0, | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Api::V4::Runs::SplitsController < Api::V4::ApplicationController | ||
before_action :set_run | ||
before_action only: [:create] do | ||
doorkeeper_authorize! :upload_run | ||
end | ||
|
||
def create | ||
if @run.split( | ||
more: params[:more] == '1', | ||
realtime_end_ms: split_params[:realtime_end_ms], | ||
gametime_end_ms: split_params[:gametime_end_ms], | ||
) | ||
render json: Api::V4::RunBlueprint.render( | ||
@run, | ||
root: :run, | ||
historic: params[:historic] == '1', | ||
segment_groups: params[:segment_groups] == '1', | ||
) | ||
else | ||
render status: :bad_request, json: { | ||
status: 400, | ||
message: @run.errors.full_messages.to_sentence, | ||
} | ||
end | ||
end | ||
|
||
private | ||
|
||
def split_params | ||
params.require(:split).permit(:realtime_end_ms, :gametime_end_ms) | ||
end | ||
end |
Oops, something went wrong.