<commit_before>%h1
  = @race.name

%h4
  Vrijeme utrke:
  %b
    = l @race.date, format: :short

%h4
  Prijave otvorene do:
  %b
    = l @race.registration_threshold, format: :short

.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? && current_user.admin
    = link_to race_path(@race, format: "csv") do
      .mdl-button.mdl-js-button.mdl-button--raised.mdl-button--colored.mdl-js-ripple-effect
        Export CSV

    = link_to edit_race_path(@race) do
      .mdl-button.mdl-js-button.mdl-button--raised.mdl-button--colored.mdl-js-ripple-effect
        Izmijeni

  - if @race.date > @race.registration_threshold
    - 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
        = f.select :category_id, @race.categories.collect{|c| [c.name, c.id]}
        .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: @race.description_url, target: '_blank' }
  %h4
    RASPIS UTRKE

- 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.start_number} - #{r.full_name}", r.id]}), include_blank: true
    = f.hidden_field :race_id, value: @race.id
    = f.hidden_field :status, value: 1
    = f.select :category_id, @race.categories.collect{|c| [c.name, c.id]}
    = f.submit 'Prijavi', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'

  %br
  %br

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

%table#raceResults.wide_table.mdl-data-table.mdl-js-data-table.mdl-shadow--2dp
  %thead
    %tr
      %th Mjesto
      %th Startni broj
      %th Ime i Prezime
      %th Klub
      %th Vrijeme
      %th Status
      - if user_signed_in? && current_user.admin
        %th
        %th
  %tbody
    - @race.categories.each_with_index do |category, index|
      %tr{ class: "cat-#{index}" }
        %td{ colspan: user_signed_in? && current_user.admin ? 8 : 7 }
          = category.name.upcase

      - (@race.race_results.select{|rr| rr.lap_times.length > 0}.sort{|x, y| x.position <=> y.position} + @race.race_results.select{|rr| rr.lap_times.length == 0}.sort{|x, y| y.status <=> x.status}).select{|rr| rr.category == category}.each_with_index do |race_result|
        %tr
          %td
            - if race_result.status == 3
              = race_result.position
          %td= race_result.start_number
          %td= link_to race_result.racer.full_name, race_result.racer
          %td= race_result.racer.club.try(:name)
          %td= race_result.finish_time
          - if @race.ended_at.present? && race_result.status == 1
            .mdl-tooltip.mdl-tooltip--large{for: "raceResult-#{race_result.id}"}
              Na iducem startu placa dodatnih 10 kn.
            %td.shame{id: "raceResult-#{race_result.id}"}
              = race_result.pretty_status
          - else
            %td= race_result.pretty_status
          - if user_signed_in? && current_user.admin && race_result.status && race_result.status < 2
            %td
              = form_for race_result do |f|<commit_msg>Try to fix broken comparison<commit_after>%h1
  = @race.name

%h4
  Vrijeme utrke:
  %b
    = l @race.date, format: :short

%h4
  Prijave otvorene do:
  %b
    = l @race.registration_threshold, format: :short

.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? && current_user.admin
    = link_to race_path(@race, format: "csv") do
      .mdl-button.mdl-js-button.mdl-button--raised.mdl-button--colored.mdl-js-ripple-effect
        Export CSV

    = link_to edit_race_path(@race) do
      .mdl-button.mdl-js-button.mdl-button--raised.mdl-button--colored.mdl-js-ripple-effect
        Izmijeni

  - if @race.date > @race.registration_threshold
    - 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
        = f.select :category_id, @race.categories.collect{|c| [c.name, c.id]}
        .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: @race.description_url, target: '_blank' }
  %h4
    RASPIS UTRKE

- 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.start_number} - #{r.full_name}", r.id]}), include_blank: true
    = f.hidden_field :race_id, value: @race.id
    = f.hidden_field :status, value: 1
    = f.select :category_id, @race.categories.collect{|c| [c.name, c.id]}
    = f.submit 'Prijavi', class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect'

  %br
  %br

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

%table#raceResults.wide_table.mdl-data-table.mdl-js-data-table.mdl-shadow--2dp
  %thead
    %tr
      %th Mjesto
      %th Startni broj
      %th Ime i Prezime
      %th Klub
      %th Vrijeme
      %th Status
      - if user_signed_in? && current_user.admin
        %th
        %th
  %tbody
    - @race.categories.each_with_index do |category, index|
      %tr{ class: "cat-#{index}" }
        %td{ colspan: user_signed_in? && current_user.admin ? 8 : 7 }
          = category.name.upcase

      - (@race.race_results.select{|rr| rr.position.present?}.sort{|x, y| x.position <=> y.position} + @race.race_results.select{|rr| rr.position.nil?}.sort{|x, y| y.status <=> x.status}).select{|rr| rr.category == category}.each_with_index do |race_result|
        %tr
          %td
            - if race_result.status == 3
              = race_result.position
          %td= race_result.start_number
          %td= link_to race_result.racer.full_name, race_result.racer
          %td= race_result.racer.club.try(:name)
          %td= race_result.finish_time
          - if @race.ended_at.present? && race_result.status == 1
            .mdl-tooltip.mdl-tooltip--large{for: "raceResult-#{race_result.id}"}
              Na iducem startu placa dodatnih 10 kn.
            %td.shame{id: "raceResult-#{race_result.id}"}
              = race_result.pretty_status
          - else
            %td= race_result.pretty_status
          - if user_signed_in? && current_user.admin && race_result.status && race_result.status < 2
            %td
              = form_for race_result do |f|
{'fraction_non_alphanumeric': 0.14338235294117646, 'fraction_numerical': 0.004056795131845842, 'mean_word_length': 2.6710097719869705, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1530063', 'n_tokens_mistral': 3063, 'n_tokens_neox': 2913, 'n_words': 523}