-
Notifications
You must be signed in to change notification settings - Fork 19
Configuring Dimension Information
A dimension is either a column on the fact model or a relation to another table. They are used to group information together for aggregates. For example, a report on orders dimensioned by sales agent would join the orders fact model to agents and yields data grouped by agent.
You must declare what a fact model is dimensional by. A valid dimension is a column on the fact model's ActiveRecord model or a belongs_to
/has_one through
relationship. has_many
relationships do not work (well) at all.
class TicketFactModel < ActiveReporting::FactModel
dimension :creator # belongs_to relationship
dimension :assignee # belongs_to relationship
dimension :category # Column on the tickets table
end
When another fact model uses a relationship as a dimension, that ActiveRecord model's fact model class can hold configuration information for how to act when used as a dimension.
By default, it is assumed a dimension's label is a column called name
. This can be changed on the fact model.
class UserFactModel < ActiveReporting::FactModel
default_dimension_label :username
end