<commit_before>%h1
  = @race.name

.race-actions
  = link_to races_path do
    .mdl-button.mdl-button--raised.mdl-button--accent.mdl-js-button.mdl-js-ripple-effect
      Natrag
  - if user_signed_in? && !@racer_has_race_result
    = form_for RaceResult.new do |f|
      = f.hidden_field :racer_id, value: current_user.racer.try(:id)
      = f.hidden_field :race_id, value: @race.id
      = f.hidden_field :status, value: 1
      .actions
        = f.submit 'Prijavi se', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect'
  - elsif user_signed_in? && @racer_has_race_result
    = form_for @race_result, method: 'DELETE' do |f|
      .actions
        = f.submit 'Odjavi se', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'
  - else
    = link_to 'Login za prijavu', login_racers_path(redirect: "/races/#{@race.id}"), class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'
%a{ href: 'http://www.xczld.info/novosti/i-kolo-3-mtb-maraton-stankovci-2016-raspis/', target: '_blank' }
  %h4
    RASPIS UTRKE

%h4
  Prijavljeni vozaci
  = "(#{@race.race_results.count})"

- if user_signed_in? && current_user.admin
  = form_for RaceResult.new do |f|
    = f.select :racer_id, options_for_select(Racer.where.not(id: @race.race_results.pluck(:racer_id)).collect{|r| [r.full_name, r.id]}), include_blank: true
    = f.hidden_field :race_id, value: @race.id
    = f.hidden_field :status, value: 1
    = f.submit 'Prijavi', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'

    %br
    %br

%table.wide_table.mdl-data-table.mdl-js-data-table.mdl-shadow--2dp
  %thead
    %tr
      %th Startni broj
      %th Ime
      %th Prezime
      %th Klub
      %th Vrijeme
      %th Status
      %th Bodovi
      - if user_signed_in? && current_user.admin
        %th
  %tbody
    - Racer.categories.each do |category|
      %tr{ class: 'cat-' + category[0].gsub('+', '') }
        %td{ colspan: 7 }
          = category[0].upcase

      - @race.race_results.order(points: :desc).each do |race_result|
        - if race_result.racer.category == category[0]
          %tr
            %td<commit_msg>Better sort of race results<commit_after>%h1
  = @race.name

.race-actions
  = link_to races_path do
    .mdl-button.mdl-button--raised.mdl-button--accent.mdl-js-button.mdl-js-ripple-effect
      Natrag
  - if user_signed_in? && !@racer_has_race_result
    = form_for RaceResult.new do |f|
      = f.hidden_field :racer_id, value: current_user.racer.try(:id)
      = f.hidden_field :race_id, value: @race.id
      = f.hidden_field :status, value: 1
      .actions
        = f.submit 'Prijavi se', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect'
  - elsif user_signed_in? && @racer_has_race_result
    = form_for @race_result, method: 'DELETE' do |f|
      .actions
        = f.submit 'Odjavi se', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'
  - else
    = link_to 'Login za prijavu', login_racers_path(redirect: "/races/#{@race.id}"), class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'
%a{ href: 'http://www.xczld.info/novosti/i-kolo-3-mtb-maraton-stankovci-2016-raspis/', target: '_blank' }
  %h4
    RASPIS UTRKE

%h4
  Prijavljeni vozaci
  = "(#{@race.race_results.count})"

- if user_signed_in? && current_user.admin
  = form_for RaceResult.new do |f|
    = f.select :racer_id, options_for_select(Racer.where.not(id: @race.race_results.pluck(:racer_id)).collect{|r| [r.full_name, r.id]}), include_blank: true
    = f.hidden_field :race_id, value: @race.id
    = f.hidden_field :status, value: 1
    = f.submit 'Prijavi', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'

    %br
    %br

%table.wide_table.mdl-data-table.mdl-js-data-table.mdl-shadow--2dp
  %thead
    %tr
      %th Startni broj
      %th Ime
      %th Prezime
      %th Klub
      %th Vrijeme
      %th Status
      %th Bodovi
      - if user_signed_in? && current_user.admin
        %th
  %tbody
    - Racer.categories.each do |category|
      %tr{ class: 'cat-' + category[0].gsub('+', '') }
        %td{ colspan: 7 }
          = category[0].upcase

      - @race.race_results.sort{|x, y| x.finish_time <=> y.finish_time}.each do |race_result|
        - if race_result.racer.category == category[0]
          %tr
            %td
{'fraction_non_alphanumeric': 0.15055187637969095, 'fraction_numerical': 0.006622516556291391, 'mean_word_length': 2.8594548551959114, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7366063', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1772, 'n_words': 319}