Created
May 13, 2021 15:10
-
-
Save fmundaca/77be426aa74281f59d7b9c62d76b979b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Administration | |
module PositionsManagement | |
class PositionPrint < Blueprinter::Base | |
view :successed do | |
identifier :id | |
fields :name, :code, :token, :parent_id, :description, :children_count | |
field :total_collaborators do |position| | |
User.where(area_id: position.self_and_descendants.ids).count | |
end | |
field :total_descendants do |position| | |
position.descendants.size | |
end | |
end | |
view :errored do | |
field :errors do |position| | |
position.errors.messages.values.flatten | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment