mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
Easily group and create header and summary row Auto format cells when appropriate type (boolean, dates) and render_format (neither csv nor json)
31 lines
878 B
Ruby
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
|