mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
20 lines
559 B
Ruby
20 lines
559 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Provides methods for Machines
|
|
class MachineService
|
|
def self.list(filters)
|
|
sort_by = Setting.get('machines_sort_by') || 'default'
|
|
machines = if sort_by == 'default'
|
|
Machine.includes(:machine_image, :plans)
|
|
else
|
|
Machine.includes(:machine_image, :plans).order(sort_by)
|
|
end
|
|
if filters[:disabled].present?
|
|
state = filters[:disabled] == 'false' ? [nil, false] : true
|
|
machines = machines.where(disabled: state)
|
|
end
|
|
|
|
machines
|
|
end
|
|
end
|