Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- route_ids = ::Planner::PlanSolution.find_by(id: plan_solution_id).try(:planner_routes).try(:pluck, :id)
- stop_ids = get_stops_ids(route_id)
- byebug
- route_stops = Planner::RouteStop.where(stop_id: stop_ids, planner_route_id: route_ids)
- unassigned_stop_ids = stop_ids.map(&:to_i) - route_stops.pluck(:stop_id)
- #unplanned_stop_ids.each do |u_stop|
- # ::Planner::RouteStop.new(
- # stop_id: u_stop
- # )
- #end
- def index
- collection = collection_sort(collection_filter.preload(:entity_tags, tags: :tag_type)
- .active)
- trucks = Trucks::TruckContextQuery.new(trucks: collection,
- start_place: collection_filters[:start_place],
- geolocated: collection_filters[:geolocated]).call
- truck_contexts = TruckContext.where(truck_id: trucks.pluck(:id))
- serializer_options = { meta: { truck_ids: trucks.pluck(:id) } }
- paginated = PaginationService.new(params, trucks)
- jsonapi_response(paginated, 200, serializer_options.merge(params: { truck_contexts: truck_contexts}))
- end
- def index
- #stops = ::Planner::Plan.find(params[:planner_plan_id]).stop_groups.map(&:stops)
- stops = ::Planner::PlanStop.selected_stops_ids(plan_id: params['planner_plan_id'])
- stop_ids_not_selected = []
- stop_ids_selected = []
- stops.each do |stop|
- elements = stop.last ? stop_ids_selected : stop_ids_not_selected
- elements << stop.first
- end
- stop_ids = ::Planner::Plan.find(params[:planner_plan_id]).stop_groups.pluck(:id)
- data = Stop.eager_load([:stop_group, :contact, :delivery_times, :items, :plan_stops, :entity_tags, tags: %i[tag_type]])
- .select(fields_for_join)
- .joins(:plan_stops)
- .where(stop_group_id: stop_ids)
- .where.not(latitude: nil)
- .where.not(longitude: nil)
- .where('delivery_times.min_delivery_time >= ?', Time.zone.now.beginning_of_day)
- not_selected = ::Planner::Plan.find(params[:planner_plan_id]).stop_groups.map(&:stops).map(&:ids).flatten
- n_s = not_selected - ::Planner::Plan.find(params[:planner_plan_id]).stops.ids
- serializer_options = { meta: { stop_ids_not_selected: n_s, stop_ids_selected: stop_ids_not_selected } }
- #serializer_options = { meta: { stop_ids_not_selected: stop_ids_not_selected, stop_ids_selected: stop_ids_selected } }
- #byebug
- jsonapi_response(PaginationService.new(params, data), 200, serializer_options)
- end
Advertisement
Add Comment
Please, Sign In to add comment