app/controllers/project_stats_controller.rb
# Return JSON-formatted chart data with the given fields
# rubocop: disable Metrics/MethodLength
Return JSON-formatted chart data with the given fields
rubocop: disable Metrics/MethodLength
Return JSON - formatted chart data with the given fields rubocop : disable Metrics / MethodLength
def create_line_chart(fields)
    database_fields =
      [:created_at] +
      fields.map(&:to_sym)
    stat_data = ProjectStat.select(*database_fields)
    dataset = []
    fields.each do |field|
      active_dataset =
        stat_data.reduce({}) do |h, e|
          h.merge(e.created_at => e[field])
        end
      dataset << {
        name: I18n.t("project_stats.index.#{field}"),
        data: active_dataset
      }
    end
    dataset
  end
def create_line_chart ( fields ) database_fields = [ :created_at ] + fields . map ( & :to_sym ) stat_data = ProjectStat . select ( * database_fields ) dataset = [ ] fields . each do | field | active_dataset = stat_data . reduce ( { } ) do | h , e | h . merge ( e . created_at => e [ field ] ) end dataset << { name : I18n . t ( "project_stats.index.#{field}" ) , data : active_dataset } end dataset end
Return JSON-formatted chart data with the given fields
rubocop: disable Metrics/MethodLength
Return JSON - formatted chart data with the given fields rubocop : disable Metrics / MethodLength
# Retrieve just the data we need # Add "field" to dataset
fields
<not_specific>