2024-07-10 13:29:18 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Lists
|
|
|
|
class StorageLocationsService < BaseService
|
|
|
|
def initialize(team, params)
|
|
|
|
@team = team
|
|
|
|
@parent_id = params[:parent_id]
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def fetch_records
|
2024-07-18 19:05:59 +08:00
|
|
|
@records =
|
|
|
|
StorageLocation.joins('LEFT JOIN storage_locations AS sub_locations ' \
|
|
|
|
'ON storage_locations.id = sub_locations.parent_id')
|
|
|
|
.select('storage_locations.*, COUNT(sub_locations.id) AS sub_location_count')
|
|
|
|
.where(team: @team, parent_id: @parent_id)
|
|
|
|
.group(:id)
|
2024-07-10 13:29:18 +08:00
|
|
|
end
|
|
|
|
|
2024-07-11 13:54:44 +08:00
|
|
|
def filter_records; end
|
2024-07-10 13:29:18 +08:00
|
|
|
end
|
|
|
|
end
|