Finished phase006
CI / scan_ruby (push) Failing after 7s
CI / scan_js (push) Failing after 7s
CI / lint (push) Failing after 8s

This commit is contained in:
2026-09-16 16:37:03 -06:00
parent 0826d267f2
commit 87d2141ed0
22 changed files with 754 additions and 10 deletions
+18 -1
View File
@@ -72,10 +72,27 @@ class VehiclesController < ApplicationController
end
def prepare_show
@maintenance_schedules = @vehicle.maintenance_schedules.order(:maintenance_type)
@maintenance_schedules = @vehicle.maintenance_schedules.active.order(:maintenance_type)
@maintenance_schedule_statuses = maintenance_schedule_statuses(@maintenance_schedules)
@fuel_entries = @vehicle.fuel_entries.includes(:updated_by_user).order(date: :desc, created_at: :desc)
@maintenance_entries = @vehicle.maintenance_entries.includes(:updated_by_user).order(date: :desc, created_at: :desc)
@fuel_entry ||= @vehicle.fuel_entries.build(date: Date.current)
@maintenance_entry ||= @vehicle.maintenance_entries.build(date: Date.current)
end
def maintenance_schedule_statuses(schedules)
schedules.index_with do |schedule|
latest_entry = latest_maintenance_entry_for(schedule)
status = MaintenanceScheduleStatus.new(schedule, latest_entry, current_odometer: @vehicle.current_odometer)
MaintenanceNotification.record_status_change(schedule, status)
status
end
end
def latest_maintenance_entry_for(schedule)
@vehicle.maintenance_entries
.where("lower(name) = ?", schedule.maintenance_type.downcase)
.order(date: :desc, created_at: :desc)
.first
end
end