<commit_before><%
datafile = "data/php/environnements.txt"

mysqldbs = []
phpenvs = []

if File.exists?(datafile)
  mysqldbs = File.readlines(datafile).grep(/ mysql/).map do |line|
    a = line.chomp.split(/\s+/)
    {server:a[0], name:a[3].split("/").last, size:a[2].to_i*1024}
  end
  phpenvs = File.readlines("data/php/environnements.txt").grep(/ php/).map do |line|
    a = line.chomp.split(/\s+/)
    p = a[3].split("/")
    {server:a[0], name:p[-1], php_version:p[-2], size:a[2].to_i*1024}
  end
end

php5 = %x(grep -rl php-test data/rp/rp-intra-01/sites-enabled/* 2>/dev/null).split.map{|f| f.split("/").last.gsub(".appli.i2","")}
phpenvs.reject! do |env|
  (php5.include?(env[:name]) && env[:server] != "vm-php") || (!php5.include?(env[:name]) && env[:server] == "vm-php")
end
%>

<% title "Software as a Service - PHP/Mysql" %>

<div id="saas" class="span12 items_list">

<%= render "submenu" %>

<table id="php" class="pretty list chrome-bug-on-scroll">
  <tr class="fix-on-scroll">
    <th><%= t(:environment) %></th>
    <th><%= t(:server) %></th>
    <th><%= t(:version) %></th>
    <th><%= t(:files) %></th>
    <th><%= t(:databases) %></th>
  </tr>
  <tbody class="long-list">
<% phpenvs.group_by{|i|i[:server]}.each do |server,environments| %>
  <tr>
    <td rowspan="<%= environments.length+1 %>" class="multirow">
      <%= link_to_server_if_exists(server).html_safe %><br />
      <span class="tiny">(<%= environments.length %>)</span>
    </td>
    <td colspan="4" class="hidden"></td>
  </tr>
  <% environments.sort_by{|e| e[:name]}.each do |env| %>
  <tr>
    <td><%= link_to env[:name], "http://#{env[:name]}.appli.i2/" %></td>
    <td class="center"><%= env[:php_version] %></td>
    <td class="center"><%= pretty_size(env[:size]).sub("bytes","b") %></td>
    <td>
      <ul class="details">
      <%= mysqldbs.select{|m| m[:name].starts_with?(env[:name])}.group_by do |db|
            db[:server]
          end.map do |server,dbs|
            "<li>#{link_to_server_if_exists server}: #{dbs.map{|db| "#{db[:name]} (#{pretty_size(db[:size]).sub("bytes","b")})"}.join(", ")}</li>"
          end.join("<br/>").html_safe %>
      </ul>
    </td>
  </tr>
  <% end %>
<% end %>
  </tbody>
</table>

</div><commit_msg>Improved styles for saas/php view<commit_after><%
datafile = "data/php/environnements.txt"

mysqldbs = []
phpenvs = []

if File.exists?(datafile)
  mysqldbs = File.readlines(datafile).grep(/ mysql/).map do |line|
    a = line.chomp.split(/\s+/)
    {server:a[0], name:a[3].split("/").last, size:a[2].to_i*1024}
  end
  phpenvs = File.readlines("data/php/environnements.txt").grep(/ php/).map do |line|
    a = line.chomp.split(/\s+/)
    p = a[3].split("/")
    {server:a[0], name:p[-1], php_version:p[-2], size:a[2].to_i*1024}
  end
end

php5 = %x(grep -rl php-test data/rp/rp-intra-01/sites-enabled/* 2>/dev/null).split.map{|f| f.split("/").last.gsub(".appli.i2","")}
phpenvs.reject! do |env|
  (php5.include?(env[:name]) && env[:server] != "vm-php") || (!php5.include?(env[:name]) && env[:server] == "vm-php")
end
%>

<% title "Software as a Service - PHP/Mysql" %>

<div id="saas" class="span12 items_list">

<%= render "submenu" %>

<table id="php" class="pretty list chrome-bug-on-scroll">
  <tr class="fix-on-scroll">
    <th><%= t(:environment) %></th>
    <th><%= t(:server) %></th>
    <th><%= t(:version) %></th>
    <th><%= t(:files) %></th>
    <th><%= t(:databases) %></th>
  </tr>
  <tbody class="long-list">
<% phpenvs.group_by{|i|i[:server]}.each do |server,environments| %>
  <tr>
    <td rowspan="<%= environments.length+1 %>" class="multirow">
      <%= link_to_server_if_exists(server).html_safe %><br />
      <span class="tiny">(<%= environments.length %>)</span>
    </td>
    <td colspan="4" class="hidden"></td>
  </tr>
  <% environments.sort_by{|e| e[:name]}.each do |env| %>
  <tr>
    <td><%= link_to env[:name], "http://#{env[:name]}.appli.i2/" %></td>
    <td class="center"><%= env[:php_version] %></td>
    <td class="center"><%= pretty_size(env[:size]).sub("bytes","b") %></td>
    <td>
      <%= mysqldbs.select{|m| m[:name].starts_with?(env[:name])}.group_by do |db|
            db[:server]
          end.map do |server,dbs|
            "<p>#{link_to_server_if_exists server}: #{dbs.map{|db| "#{db[:name]} (#{pretty_size(db[:size]).sub("bytes","b")})"}.join(", ")}</p>"
          end.join.html_safe %>
      </ul>
    </td>
  </tr>
  <% end %>
<% end %>
  </tbody>
</table>

</div>
{'fraction_non_alphanumeric': 0.2711141060197664, 'fraction_numerical': 0.012578616352201259, 'mean_word_length': 3.6530825496342736, 'pattern_counts': {'":': 0, '<': 123, '<?xml version=': 0, '>': 125, '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': '5079826', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1812, 'n_words': 301}