Files
openfoodnetwork/lib/reporting/report_object_template.rb
Sebastian Castro 287e8f5845 Reports Refactor 3
Easily group and create header and summary row
Auto format cells when appropriate type (boolean, dates) and render_format (neither csv nor json)
2022-05-12 16:54:13 +02:00

31 lines
878 B
Ruby

# frozen_string_literal: true
# This is the old way of managing report, by loading Models from the DB and building
# The result from those models
module Reporting
class ReportObjectTemplate < ReportTemplate
# rubocop:disable Rails/Delegate
# Not delegating for now cause not all subclasses are ready to use reportGrouper
# so they can implement this method themseves
def table_rows
grouper.table_rows
end
# rubocop:enable Rails/Delegate
# The search result, an ActiveRecord Array
def query_result
raise NotImplementedError
end
# Convert the query_result into expected row result (which will be displayed)
# Example
# {
# name: proc { |model| model.display_name },
# best_friend: proc { |model| model.friends.first.first_name }
# }
def columns
raise NotImplementedError
end
end
end