Skip to content

Commit

Permalink
Improve time series results display
Browse files Browse the repository at this point in the history
  • Loading branch information
farski committed Dec 18, 2024
1 parent 01b196e commit 332825e
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 94 deletions.
4 changes: 3 additions & 1 deletion app/views/data_explorer/time_series/_results.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

<%= render "data_explorer/time_series/results/table/metric_headers" %>

<%= render "data_explorer/time_series/results/table/comparison_headers" %>
<% if @composition.comparisons.size > 0 %>
<%= render "data_explorer/time_series/results/table/comparison_headers" %>
<% end %>
</thead>

<tbody>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,103 @@
<%= render partial: "data_explorer/time_series/results/table/group_row", collection: @composition.results.group_1_unique_members, as: :group_1_member %>
<% @composition.results.group_1_unique_members&.each do |group_1_member| %>
<% label_displayed = false %>

<% @composition.results.group_2_unique_members&.each do |group_2_member| %>
<%
values = []
@composition.results.granularity_unique_members.each do |granularity_member|
@composition.metrics.each do |metric|
@composition.comparisons.each do |comparison|
comparison.lookback.times do |i|
lookback = -(comparison.lookback - i)
value = @composition.results.get_value_comparison(comparison, lookback, metric, granularity_member, group_1_member, group_2_member)

values << value
end
end

values << @composition.results.get_value(metric, granularity_member, group_1_member, group_2_member)
end
end
%>

<% unless values.compact.size == 0 %>
<tr>
<th
<%= html_attributes("data-raw-member": group_1_member) %>
scope="row">

<% label = @composition.results.group_member_label(@composition.groups[0], group_1_member) %>

<% unless label_displayed %>
<%= Labeler.label(label, @composition.groups[0]) %>
<% label_displayed = true %>
<% end %>
</th>
<th <%= html_attributes("data-raw-member": group_2_member) %>
scope="row">

<%= @composition.results.group_member_label(@composition.groups[1], group_2_member) %>
</th>

<% @composition.results.granularity_unique_members.each do |granularity_member| %>
<% @composition.metrics.each do |metric| %>
<% @composition.comparisons.each do |comparison| %>
<% comparison.lookback.times do |i| %>
<%# if +comparison.lookback+ is 3, +lookback+ should be -3, -2, %>
<%# and -1 for the loops. So when i=0, lookback=-3, and i=1 l=-2 %>
<% lookback = -(comparison.lookback - i) %>
<% value = @composition.results.get_value_comparison(comparison, lookback, metric, granularity_member, group_1_member, group_2_member) %>

<td <%= html_attributes("data-highlight-group": metric.metric) %>
<%= html_attributes("data-raw-value": value) %>>
<%= number_with_delimiter(value) %>
</td>
<% end %>
<% end %>

<% value = @composition.results.get_value(metric, granularity_member, group_1_member, group_2_member) %>

<td <%= html_attributes("data-highlight-group": metric.metric) %>
<%= html_attributes("data-raw-value": value) %>>
<%= number_with_delimiter(value) %>
</td>
<% end %>
<% end %>
</tr>
<% end %>
<% end %>

<tr>
<th
<%= html_attributes("data-raw-member": group_1_member) %>
scope="row">

<% label = @composition.results.group_member_label(@composition.groups[0], group_1_member) %>
<%= Labeler.label(label, @composition.groups[0]) %>
</th>
<th>UNKNOWN</th>

<% @composition.results.granularity_unique_members.each do |granularity_member| %>
<% @composition.metrics.each do |metric| %>
<% @composition.comparisons.each do |comparison| %>
<% comparison.lookback.times do |i| %>
<%# if +comparison.lookback+ is 3, +lookback+ should be -3, -2, %>
<%# and -1 for the loops. So when i=0, lookback=-3, and i=1 l=-2 %>
<% lookback = -(comparison.lookback - i) %>
<% value = @composition.results.get_value_comparison(comparison, lookback, metric, granularity_member, group_1_member, nil) %>

<td <%= html_attributes("data-raw-value": value) %>>
<%= number_with_delimiter(value) %>
</td>
<% end %>
<% end %>

<% value = @composition.results.get_value(metric, granularity_member, group_1_member, nil) %>

<td <%= html_attributes("data-raw-value": value) %>>
<%= number_with_delimiter(value) %>
</td>
<% end %>
<% end %>
</tr>
<% end %>

0 comments on commit 332825e

Please sign in to comment.