Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
4.5 kB 82 lines
at autocoaching
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283- description ||= nil- cols ||= [:runner, :time, :name, :video, :rival, :uploaded]/ This allows us to blindly check the keys for items instead of wraping in `try`s- col_options = cols.to_h { |col| [col, []] }.merge(local_assigns.fetch(:col_options, {}))- runs = order_runs(runs).page(params[:page]).includes(:user, :game)- non_pb_runs = user.non_pbs(runs.map(&:category_id)).group_by(&:category_id) if col_options[:time].include?(:archived)- if runs.none? - if description.present? .card-header.text-white = description center.p-4 i Nothing to show!- else - if description.present? .card-header.text-white = description .table-responsive table.card-body.table.table-striped.table-hover.mb-0 thead tr - if cols.include?(:runner) th.header.align-right.nowrap = th_sorter('Runner', 'user_id') - if cols.include?(:time) th.header.align-right.nowrap = th_sorter('Time', 'time') - if cols.include?(:video) th.nowrap = th_sorter('Video', 'video_url') - if cols.include?(:name) th width='100%' Game + Category - if cols.include?(:rival) th.align-right.nowrap Rival - if cols.include?(:uploaded) th.align-right.nowrap = th_sorter('Created', 'created_at') - if cols.include?(:owner_controls) th.header.align-right.nowrap tbody - runs.each do |run| - timing = params[:timing] || run.default_timing tr id="run_#{run.id36}" - if cols.include?(:runner) td.align-right.nowrap = user_badge(run.user) - if cols.include?(:time) td.align-right.nowrap / Make sure to not group runs with no category - if col_options[:time].include?(:archived) && run.category_id.present? / Gather only runs with the same category and sort by default timing ascending - old_runs = non_pb_runs[run.category_id].try(:sort_by, &:created_at).try(:reverse) - if old_runs.present? span.dropdown-toggle.mr-2.cursor-pointer id="#{run.id36}-history-dropdown" data-toggle='dropdown' = icon('fas', 'history') span.dropdown-menu.bg-dark aria-labelledby="#{run.id36}-history-dropdown" h6.dropdown-header Past Times - old_runs.each do |old_run| a.dropdown-item.text-secondary href=run_path(old_run) = old_run.duration.format = run.duration.format - if cols.include?(:video) td.text-center.nowrap - if run.video&.url.present? = icon('fas', 'video') - if cols.include?(:name) td width='100%' = link_to run, run_path(run), class: 'run-link' - if cols.include?(:rival) td.align-right.nowrap small - rivalry = run.user.rivalries.includes(:to_user).detect { |r| r.category_id == run.category_id } - if rivalry.present? && rivalry.to_user.pb_for(timing, run.category).present? - rival_run = rivalry.to_user.pb_for(timing, run.category) = link_to run_path(run, compare: rival_run), class: 'run-link stealth-link' do = pretty_difference(run.duration(run.default_timing), rival_run.duration(run.default_timing)) ' against = user_badge(rivalry.to_user) - if cols.include?(:uploaded) td.align-right.nowrap = render partial: 'shared/relative_time', locals: {time: run.created_at, ago: true} - if cols.include?(:owner_controls) td.nowrap: .dropleft.text-center .kill-run-button id="dropdown_#{run.id36}" data={toggle: :dropdown} = icon('fas', 'ellipsis-v') .dropdown-menu.bg-dark role=:menu aria={labelledby: "dropdown_#{run.id36}"} button.dropdown-item.text-danger.run-disown-button data={run: {id: run.id36}} = icon('fas', 'eraser', 'Disown') button.dropdown-item.text-danger.run-delete-button data={run: {id: run.id36}} = icon('fas', 'trash', 'Delete') .mx-auto = paginate(runs, theme: 'twitter-bootstrap-4', pagination_class: 'mt-3')