https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog
from Nicolas Despr�s <nicolas.despres(a)gmail.com>
Add inputs value in the graph form.
* web/ranch/test/functional/graph_form_controller_test.rb: Test it.
* web/ranch/test/fixtures/inputs.yml,
* web/ranch/test/fixtures/outputs.yml: Generate data for a bench
with several run.
* web/ranch/app/controllers/graph_form_controller.rb: Select inputs
from the inputs table.
* web/ranch/app/views/graph_form/index.rhtml: Display inputs.
app/controllers/graph_form_controller.rb | 18 ++++++++++++-
app/views/graph_form/index.rhtml | 36 +++++++++++++++++++++++++-
test/fixtures/inputs.yml | 18 +++++++------
test/fixtures/outputs.yml | 17 +++++++-----
test/functional/graph_form_controller_test.rb | 9 ++++++
5 files changed, 83 insertions(+), 15 deletions(-)
Index: web/ranch/test/functional/graph_form_controller_test.rb
--- web/ranch/test/functional/graph_form_controller_test.rb (revision 22)
+++ web/ranch/test/functional/graph_form_controller_test.rb (working copy)
@@ -20,6 +20,8 @@
assert_not_nil assigns(:project)
assert_not_nil assigns(:bench_name)
+ assert_not_nil assigns(:output_arg_num)
+ assert_not_nil assigns(:inputs)
assert !assigns(:draw_on)
assert_kind_of Hash, assigns(:revision)
assert assigns(:revision)[:start] < assigns(:revision)[:stop]
@@ -37,6 +39,8 @@
assert_not_nil assigns(:project)
assert_not_nil assigns(:bench_name)
+ assert_not_nil assigns(:output_arg_num)
+ assert_not_nil assigns(:inputs)
assert_kind_of Hash, assigns(:revision)
assert_equal 2, assigns(:revision)[:start]
assert_equal 8, assigns(:revision)[:stop]
@@ -54,6 +58,8 @@
assert_not_nil assigns(:project)
assert_not_nil assigns(:bench_name)
+ assert_not_nil assigns(:output_arg_num)
+ assert_not_nil assigns(:inputs)
assert_kind_of Hash, assigns(:revision)
assert_equal 1, assigns(:revision)[:start]
assert_equal assigns(:project).head_revision, assigns(:revision)[:stop]
@@ -72,6 +78,8 @@
assert_equal 1, assigns(:project).id
assert_equal 'determinize', assigns(:bench_name)
assert flash.has_key? :error
+ assert_not_nil assigns(:output_arg_num)
+ assert_not_nil assigns(:inputs)
end
def test_draw_output_arg_num
@@ -88,6 +96,7 @@
assert_equal 'determinize', assigns(:bench_name)
assert_equal 0, assigns(:output_arg_num)
assert_equal 3, assigns(:output_arg_nb)
+ assert_not_nil assigns(:inputs)
end
end
Index: web/ranch/test/fixtures/inputs.yml
--- web/ranch/test/fixtures/inputs.yml (revision 22)
+++ web/ranch/test/fixtures/inputs.yml (working copy)
@@ -1,5 +1,10 @@
<% id = 0 %>
+<% (1..10).each do |rev| %>
+
+<% val = 2
+ while val <= 256 do %>
+
<% arg_num = 0
{
'nb_states' => '',
@@ -7,17 +12,16 @@
'foo' => 'unit_foo'
}.each do |name, unit| %>
-<% val = 2
- arg_num += 1
- (1..10).each do |rev| %>
-
-<%= "determinize_r#{rev}_#{name}:" %>
+<%= "determinize_r#{rev}_#{name}_#{val}:" %>
id: <%= id += 1 %>
name: <%= name %>
- value: <%= val *= 2 %>
unit: <%= unit.inspect %>
+ value: <%= val %>
bench_id: <%= rev %>
- arg_num: <%= arg_num %>
+ arg_num: <%= arg_num += 1 %>
+
+<% end
+ val *= 2 %>
<% end %>
<% end %>
Index: web/ranch/test/fixtures/outputs.yml
--- web/ranch/test/fixtures/outputs.yml (revision 22)
+++ web/ranch/test/fixtures/outputs.yml (working copy)
@@ -1,5 +1,11 @@
<% id = 0 %>
+<% val = 5
+ (1..10).each do |rev| %>
+
+<% input = 2
+ while input <= 256 do %>
+
<% arg_num = 0
{
'utime' => 'sec',
@@ -7,17 +13,16 @@
'nb_states' => ''
}.each do |name, unit| %>
-<% val = 5
- arg_num += 1
- (1..10).each do |rev| %>
-
<%= "determinize_r#{rev}_#{name}:" %>
id: <%= id += 1 %>
name: <%= name %>
- value: <%= val += rev + name.size %>
unit: <%= unit.inspect %>
+ value: <%= val += input + rev + name.size %>
bench_id: <%= rev %>
- arg_num: <%= arg_num %>
+ arg_num: <%= arg_num += 1 %>
+
+<% end
+ input *= 2 %>
<% end %>
<% end %>
Index: web/ranch/app/controllers/graph_form_controller.rb
--- web/ranch/app/controllers/graph_form_controller.rb (revision 22)
+++ web/ranch/app/controllers/graph_form_controller.rb (working copy)
@@ -8,6 +8,7 @@
def index
@bench_name = params[:bench_name]
@project = Project.find params[:project_id]
+ select_inputs
@output_arg_num = 0
@draw_on = false
@revision = {}
@@ -19,6 +20,8 @@
def draw
@bench_name = params[:bench_name]
@project = Project.find params[:project_id]
+ @draw_on = true
+ select_inputs
@output_arg_num = params[:output_arg_num].to_i
if @output_arg_num.zero?
@output_arg_nb = Output.find_by_sql "SELECT outputs.arg_num " +
@@ -30,7 +33,7 @@
"ORDER BY outputs.arg_num "
@output_arg_nb = @output_arg_nb.size
end
- @draw_on = true
+
@revision = params[:revision]
head_rev = @project.head_revision
@revision[:stop] = @revision[:stop].to_i
@@ -48,4 +51,17 @@
:bench_name => @bench_name)
end
end
+
+ protected
+
+ def select_inputs
+ @inputs = Input.find_by_sql "SELECT inputs.name, inputs.unit, " +
+ "inputs.value, inputs.arg_num " +
+ "FROM inputs, benches " +
+ "WHERE benches.id = #{(a)project.id} " +
+ "AND benches.name = '#@bench_name' " +
+ "AND benches.id = inputs.bench_id " +
+ "ORDER BY inputs.arg_num"
+ end
+
end
Index: web/ranch/app/views/graph_form/index.rhtml
--- web/ranch/app/views/graph_form/index.rhtml (revision 22)
+++ web/ranch/app/views/graph_form/index.rhtml (working copy)
@@ -4,24 +4,58 @@
<%= start_form_tag :action => "draw",
:project_id => @project.id,
:bench_name => @bench_name %>
-<%= content_tag "p", "Choose a range of revision:" %>
</div>
<p>
<center>
<p>
+<p>
<table>
<tr>
+ <td></td>
<td>Start</td>
<td>Stop</td>
</tr>
<tr>
+ <td>Revision:</td>
<td><%= text_field "revision", "start", "size"
=> 8,
"value" => @revision[:start] %></td>
<td><%= text_field "revision", "stop", "size"
=> 8,
"value" => @revision[:stop] %></td>
+ </tr>
+</table>
+</p><p>
+<table>
+ <tr>
+ <td>Output:</td>
<td><%= outputs_tag "output_arg_num", @bench_name, @output_arg_num
%></td>
</tr>
</table>
+</p><p>
+<table>
+ <tr>
+ <td>Inputs</td>
+ <td>Value</td>
+ </tr>
+ <% arg_num = 1
+ i = 0
+ while i < @inputs.size do %>
+ <tr>
+ <%= content_tag "td", "#{@inputs[i].name}(#{@inputs[i].unit})"
%>
+ <td>
+ <select id="#{(a)inputs[i].name}" name="#{(a)inputs[i].name}">
+ <% while i < @inputs.size and arg_num == @inputs[i].arg_num do %>
+ <%= content_tag "option", @inputs[i].value.to_s,
+ :value => @inputs[i].value.to_s %>
+
+ <% i += 1
+ end
+ arg_num += 1 %>
+ </select>
+ </td>
+ </tr>
+ <% end %>
+</table>
+</p>
</p>
<p style="color: red;"><%= flash[:error] %></p>
<p><%= submit_tag "Draw" %></p>