Class: HrLite::OrgController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- HrLite::OrgController
- Defined in:
- app/controllers/hr_lite/org_controller.rb
Overview
The everyone-visible org chart: who reports to whom, plus the viewer's own reporting line labelled L1/L2/... Only names, designations and departments — never salary, identity numbers or any other private data.
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/hr_lite/org_controller.rb', line 6 def show profiles = EmployeeProfile.includes(:user) .where("date_of_exit IS NULL OR date_of_exit >= ?", Date.current) .to_a @by_user = profiles.index_by(&:user_id) build_tree(profiles) @own_profile = @by_user[hr_current_user.id] exited = EmployeeProfile.where(date_of_exit: ...Date.current).pluck(:user_id).to_set @own_chain = (@own_profile&.reporting_chain || []).reject { |boss| exited.include?(boss.id) } end |