Class: HrLite::OverviewQuery
- Inherits:
-
Object
- Object
- HrLite::OverviewQuery
- Defined in:
- app/services/hr_lite/overview_query.rb
Overview
Feeds both the admin overview board and the daily leadership digest — one source, so they always agree. Sections return Relations (callers paginate or cap as they see fit).
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #flagged_today ⇒ Object
-
#initialize(date: Date.current) ⇒ OverviewQuery
constructor
A new instance of OverviewQuery.
- #kpis ⇒ Object
- #missing_checkout_yesterday ⇒ Object
- #on_leave_today ⇒ Object
- #pending_requests ⇒ Object
Constructor Details
#initialize(date: Date.current) ⇒ OverviewQuery
Returns a new instance of OverviewQuery.
6 7 8 |
# File 'app/services/hr_lite/overview_query.rb', line 6 def initialize(date: Date.current) @date = date end |
Instance Method Details
#empty? ⇒ Boolean
35 36 37 |
# File 'app/services/hr_lite/overview_query.rb', line 35 def empty? kpis.values.all?(&:zero?) end |
#flagged_today ⇒ Object
18 19 20 |
# File 'app/services/hr_lite/overview_query.rb', line 18 def flagged_today AttendanceRecord.for_date(@date).flagged.includes(:user) end |
#kpis ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/services/hr_lite/overview_query.rb', line 26 def kpis { pending: pending_requests.count, on_leave: on_leave_today.count, flagged: flagged_today.count, missing_checkout: missing_checkout_yesterday.count } end |
#missing_checkout_yesterday ⇒ Object
22 23 24 |
# File 'app/services/hr_lite/overview_query.rb', line 22 def missing_checkout_yesterday AttendanceRecord.for_date(@date - 1).missing_checkout.includes(:user) end |
#on_leave_today ⇒ Object
14 15 16 |
# File 'app/services/hr_lite/overview_query.rb', line 14 def on_leave_today LeaveRequest.active_on(@date).includes(:leave_type, :user).order(:start_date) end |
#pending_requests ⇒ Object
10 11 12 |
# File 'app/services/hr_lite/overview_query.rb', line 10 def pending_requests LeaveRequest.pending.includes(:leave_type, :user).order(:created_at) end |