Class: List
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- List
- Includes:
- Boards::Listable, Importable
- Defined in:
- app/models/list.rb
Constant Summary
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes included from Importable
#importing, #user_contributions
Instance Method Summary collapse
Methods included from Boards::Listable
#collapsed?, #destroyable?, #movable?, #title, #update_preferences_for
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Instance Method Details
#as_json(options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/list.rb', line 43 def as_json( = {}) super().tap do |json| json[:collapsed] = false if .key?(:collapsed) json[:collapsed] = collapsed?([:current_user]) end if .key?(:label) json[:label] = label.as_json( project: board.project, only: [:id, :title, :description, :color], methods: [:text_color] ) end end end |
#preferences_for(user) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/list.rb', line 30 def preferences_for(user) return preferences.build unless user BatchLoader.for(list_id: id, user_id: user.id).batch(default_value: preferences.build(user: user)) do |items, loader| list_ids = items.map { |i| i[:list_id] } user_ids = items.map { |i| i[:user_id] } ListUserPreference.where(list_id: list_ids.uniq, user_id: user_ids.uniq).find_each do |preference| loader.call({ list_id: preference.list_id, user_id: preference.user_id }, preference) end end end |