author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 24 Aug 2013 00:18:50 +0100 | |
changeset 177 | 8e7f0029550d |
parent 164 | 120a4f1e25c0 |
child 304 | 91286a87b569 |
permissions | -rw-r--r-- |
164 | 1 |
class Tag < ActiveRecord::Base |
2 |
||
3 |
has_and_belongs_to_many :benchmark_batches |
|
4 |
||
5 |
def all_configurations |
|
6 |
benchmark_batches.map(&:benchmark_configuration).uniq |
|
7 |
end |
|
8 |
||
9 |
def all_benchmark_infos |
|
10 |
benchmark_batches. |
|
11 |
flat_map(&:benchmark_results). |
|
12 |
map(&:benchmark_info). |
|
13 |
uniq. |
|
14 |
sort { |a, b| a.name <=> b.name } |
|
15 |
end |
|
16 |
||
177
8e7f0029550d
Support for parameters in web app.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
164
diff
changeset
|
17 |
def benchmark_batches_latest_for(benchmark_configuration) |
8e7f0029550d
Support for parameters in web app.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
164
diff
changeset
|
18 |
benchmark_batches. |
8e7f0029550d
Support for parameters in web app.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
164
diff
changeset
|
19 |
where(benchmark_configuration: benchmark_configuration) |
8e7f0029550d
Support for parameters in web app.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
164
diff
changeset
|
20 |
end |
8e7f0029550d
Support for parameters in web app.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
164
diff
changeset
|
21 |
|
8e7f0029550d
Support for parameters in web app.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
164
diff
changeset
|
22 |
|
164 | 23 |
def latest_results_for(benchmark_info, benchmark_configuration) |
24 |
benchmark_batches. |
|
25 |
joins(:benchmark_results). |
|
26 |
where(benchmark_configuration: benchmark_configuration, |
|
27 |
benchmark_results: { benchmark_info: benchmark_info }). |
|
28 |
max { |a, b| a.performed_at <=> b.performed_at }. |
|
29 |
result_for(benchmark_info) |
|
30 |
end |
|
31 |
||
32 |
end |