module Sync
  class Fetch  < Mutations::Command
    required do
      model :device, class: Device
    end

    def execute
      message = {
          device: device,
          users: device.users,
          sequences: device.sequences,
          regimens: device.regimens,
          regimen_items: device.regimen_items,
          plants: device.plants
      }.as_json
      message[:checksum] = Digest::MD5.hexdigest(Marshal::dump(message))
      message
    end
  end
end

module Sync
  class Fetch  < Mutations::Command
    required do
      model :device, class: Device
    end

    def execute
      regimens = device.regimens;
      message = {
          device: device,
          users: device.users,
          sequences: device.sequences,
          regimens: regimens,
          regimen_items: RegimenItem.where(regimen_id: regimens.pluck(:id)),
          plants: device.plants
      }.as_json
      message[:checksum] = Digest::MD5.hexdigest(Marshal::dump(message))
      message
    end
  end
end
Fix regimen_item test failure in Sync::Fetch
Fix regimen_item test failure in Sync::Fetch
