<commit_before><% content_for :heading do -%><%= t("myplaceonline.diets.evaluate") %><% end -%>

<h1><%= t("myplaceonline.diets.evaluate") %></h1>

<%= flashes! %>

<%= form_tag(diet_evaluate_path(@obj), method: :get) do %>

  <%= input_field(name: :days, type: Myp::FIELD_NUMBER, placeholder: t("myplaceonline.diets.evaluate_days"), value: @days) %>
  <%= data_row(heading: t("myplaceonline.diets.evaluate_since"), prefix_heading: true, content: @start, wrap: false) %>
  
  <hr />
  
  <%= data_row(heading: t("myplaceonline.diets.total_calories"), prefix_heading: true, content: @total_calories, wrap: false) %>
  <%= data_row(heading: t("myplaceonline.diets.total_calories_per_day"), prefix_heading: true, content: @total_calories_per_day, wrap: false) %>
  
  <p><b><%= link_to(t("myplaceonline.diets.total_requirements"), dietary_requirements_collection_path(@obj.dietary_requirements_collection)) %></b></p>
  <%= data_table_start %>
  <% @total_requirements.map do |name, requirement| %>
    <%=
      if requirement[:needed] > 0
        consumed_percent = requirement[:consumed] / requirement[:needed]
        data_row(
          heading: name,
          htmlencode_content: false,
          content: CGI::escapeHTML(
            "#{t("myplaceonline.diets.requirements_needed")}#{DietaryRequirement.display_with_measurement(requirement[:needed], requirement[:details].dietary_requirement_type)}"
          ) + "<br />" + CGI::escapeHTML(
            "#{t("myplaceonline.diets.requirements_consumed")}#{DietaryRequirement.display_with_measurement(requirement[:consumed], requirement[:details].dietary_requirement_type)}"
          ) + "<br />" + CGI::escapeHTML(
            "#{t("myplaceonline.diets.requirements_consumed_percent")}#{Myp.decimal_to_s(value: consumed_percent * 100.0)}"
          ),
          content_classes: consumed_percent < 1 ? "bgwarning" : (consumed_percent > 2 ? "bgerror" : "")
        )
      end
    %>
  <% end %>
  <%= data_table_end %>
  
  <hr />
  
  <p><b><%= link_to(t("myplaceonline.diets.consumed_foods"), consumed_foods_path) %></b></p>
  <%= data_table_start %>
  <% @total_consumed_foods.map do |key, food_info| %>
    <%=
      data_row(
        htmlencode_heading: false,
        heading: link_to(CGI::escapeHTML(food_info[:consumed_food].display), consumed_food_path(food_info[:consumed_food])),
        htmlencode_content: false,
        content: CGI::escapeHTML(
          "#{t("myplaceonline.consumed_foods.quantity")}: #{food_info[:quantity]}"
        ) + "<br />" + CGI::escapeHTML(
          "#{t("myplaceonline.diets.total_calories")}: #{food_info[:calories]}"
        )
      )
    %>
  <% end %><commit_msg>Add green highlighting to good diet evaluations<commit_after><% content_for :heading do -%><%= t("myplaceonline.diets.evaluate") %><% end -%>

<h1><%= t("myplaceonline.diets.evaluate") %></h1>

<%= flashes! %>

<%= form_tag(diet_evaluate_path(@obj), method: :get) do %>

  <%= input_field(name: :days, type: Myp::FIELD_NUMBER, placeholder: t("myplaceonline.diets.evaluate_days"), value: @days) %>
  <%= data_row(heading: t("myplaceonline.diets.evaluate_since"), prefix_heading: true, content: @start, wrap: false) %>
  
  <hr />
  
  <%= data_row(heading: t("myplaceonline.diets.total_calories"), prefix_heading: true, content: @total_calories, wrap: false) %>
  <%= data_row(heading: t("myplaceonline.diets.total_calories_per_day"), prefix_heading: true, content: @total_calories_per_day, wrap: false) %>
  
  <p><b><%= link_to(t("myplaceonline.diets.total_requirements"), dietary_requirements_collection_path(@obj.dietary_requirements_collection)) %></b></p>
  <%= data_table_start %>
  <% @total_requirements.map do |name, requirement| %>
    <%=
      if requirement[:needed] > 0
        consumed_percent = requirement[:consumed] / requirement[:needed]
        data_row(
          heading: name,
          htmlencode_content: false,
          content: CGI::escapeHTML(
            "#{t("myplaceonline.diets.requirements_needed")}#{DietaryRequirement.display_with_measurement(requirement[:needed], requirement[:details].dietary_requirement_type)}"
          ) + "<br />" + CGI::escapeHTML(
            "#{t("myplaceonline.diets.requirements_consumed")}#{DietaryRequirement.display_with_measurement(requirement[:consumed], requirement[:details].dietary_requirement_type)}"
          ) + "<br />" + CGI::escapeHTML(
            "#{t("myplaceonline.diets.requirements_consumed_percent")}#{Myp.decimal_to_s(value: consumed_percent * 100.0)}"
          ),
          content_classes: consumed_percent < 0.8 ? "bgwarning" : (consumed_percent > 2.0 ? "bgerror" : "bghighlight")
        )
      end
    %>
  <% end %>
  <%= data_table_end %>
  
  <hr />
  
  <p><b><%= link_to(t("myplaceonline.diets.consumed_foods"), consumed_foods_path) %></b></p>
  <%= data_table_start %>
  <% @total_consumed_foods.map do |key, food_info| %>
    <%=
      data_row(
        htmlencode_heading: false,
        heading: link_to(CGI::escapeHTML(food_info[:consumed_food].display), consumed_food_path(food_info[:consumed_food])),
        htmlencode_content: false,
        content: CGI::escapeHTML(
          "#{t("myplaceonline.consumed_foods.quantity")}: #{food_info[:quantity]}"
        ) + "<br />" + CGI::escapeHTML(
          "#{t("myplaceonline.diets.total_calories")}: #{food_info[:calories]}"
        )
      )
    %>
  <% end %>
{'fraction_non_alphanumeric': 0.1723945755155118, 'fraction_numerical': 0.00371540033438603, 'mean_word_length': 4.191899710703954, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4870995', 'n_tokens_mistral': 1947, 'n_tokens_neox': 1825, 'n_words': 241}