Class: Effective::Datatables::Logs
- Inherits:
-
Effective::Datatable
- Object
- Effective::Datatable
- Effective::Datatables::Logs
- Includes:
- EffectiveLoggingHelper
- Defined in:
- app/models/effective/datatables/logs.rb
Instance Method Summary collapse
-
#collection ⇒ Object
A nil attributes means give me all the top level log entries If we set a log_id then it’s for sub logs.
Methods included from EffectiveLoggingHelper
#bootstrap_class_for_status, #effective_logging_object_link_to, #format_log_details_resource_value, #format_log_details_value, #parents_of_log, #render_log
Instance Method Details
#collection ⇒ Object
A nil attributes means give me all the top level log entries If we set a log_id then it’s for sub logs
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/effective/datatables/logs.rb', line 54 def collection collection = Effective::Log.unscoped.where(parent_id: attributes[:log_id]).includes(:user, :associated) if attributes[:log_changes] collection = collection.where(status: EffectiveLogging.log_changes_status) end if (attributes[:user] || attributes[:user_id]).present? user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i } collection = collection.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User') end if attributes[:associated_id] && attributes[:associated_type] collection = collection.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type]) end if attributes[:associated] collection = collection.where(associated: attributes[:associated]) end collection end |