diff --git a/Gemfile b/Gemfile index 867f5f803..d97d929a0 100644 --- a/Gemfile +++ b/Gemfile @@ -58,6 +58,7 @@ gem "debug" gem "ffaker" gem "composite_primary_keys" gem "resolv" +gem "rover-df" group :development do gem 'rubocop', require: false diff --git a/Gemfile.lock b/Gemfile.lock index cfdd274b9..8cb65a690 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -315,6 +315,7 @@ GEM nokogiri (1.13.9) mini_portile2 (~> 2.8.0) racc (~> 1.4) + numo-narray (0.9.2.1) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) @@ -407,6 +408,8 @@ GEM reverse_markdown (2.1.1) nokogiri rexml (3.2.5) + rover-df (0.3.4) + numo-narray (>= 0.9.1.9) rubocop (1.36.0) json (~> 2.3) parallel (~> 1.10) @@ -582,6 +585,7 @@ DEPENDENCIES redis resolv responders + rover-df rubocop rubocop-rails ruby-vips diff --git a/app/components/time_series_component.rb b/app/components/time_series_component.rb index 651ad6129..064117a1e 100644 --- a/app/components/time_series_component.rb +++ b/app/components/time_series_component.rb @@ -3,11 +3,11 @@ class TimeSeriesComponent < ApplicationComponent delegate :current_page_path, :search_params, to: :helpers - attr_reader :results, :columns, :mode + attr_reader :dataframe, :group, :mode - def initialize(results, columns, mode: :table) - @results = results - @columns = columns + def initialize(dataframe, group: nil, mode: :table) + @dataframe = dataframe + @group = group @mode = mode.to_sym end end diff --git a/app/components/time_series_component/time_series_component.html.erb b/app/components/time_series_component/time_series_component.html.erb index e0c10f399..447d5c0aa 100644 --- a/app/components/time_series_component/time_series_component.html.erb +++ b/app/components/time_series_component/time_series_component.html.erb @@ -9,20 +9,18 @@ <% if mode == :table %>
| Date | - - <% columns.each do |column| %> - <%= tag.th(column.to_s.capitalize, class: ("col-expand" if column == columns.last)) %> + <% dataframe.types.keys.each do |column| %> + <%= tag.th(column.to_s.titleize, class: ("col-expand" if column == dataframe.types.keys.last)) %> <% end %> - <% results.each do |row| %> + <% dataframe.each_row do |row| %>||
|---|---|---|
| <%= row["date"].to_date %> | - - <% columns.each do |column| %> -<%= row[column.to_s] %> | + <% dataframe.types.keys.each do |column| %> ++ <%= row[column] %> + | <% end %>