query
stringlengths 7
9.5k
| document
stringlengths 10
1.07M
| negatives
sequencelengths 19
19
| metadata
dict |
---|---|---|---|
GET /property_between_floor_slaps GET /property_between_floor_slaps.json | def index
@property_between_floor_slaps = PropertyBetweenFloorSlap.all
end | [
"def within_bounds\n min_latitude = Float(params[:sw_latitude])\n max_latitude = Float(params[:ne_latitude])\n min_longitude = Float(params[:sw_longitude])\n max_longitude = Float(params[:ne_longitude])\n limit = 1000 || params[:limit]\n offset = 0 || params[:offset]\n approved = true || params[:approved]\n @trailheads = Trailhead.where(\"latitude > :min_latitude AND latitude < :max_latitude AND longitude > :min_longitude AND longitude < :max_longitude\",\n :min_latitude => min_latitude, :min_longitude => min_longitude, :max_latitude => max_latitude, :max_longitude => max_longitude).limit(limit).offset(offset).approved\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trailheads }\n end\n end",
"def create\n @property_between_floor_slap = PropertyBetweenFloorSlap.new(property_between_floor_slap_params)\n\n respond_to do |format|\n if @property_between_floor_slap.save\n format.html { redirect_to @property_between_floor_slap, notice: 'Property between floor slap was successfully created.' }\n format.json { render :show, status: :created, location: @property_between_floor_slap }\n else\n format.html { render :new }\n format.json { render json: @property_between_floor_slap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def property_rooms\n self.dig_for_array(\"propertyRooms\")\n end",
"def rangeSights\n sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: sightings\n end",
"def floor_rooms\n\t\t@rooms[floor_no]\n\tend",
"def list_floorplans_for_building(args = {}) \n get(\"/floorplans.json/#{args[:buildingId]}/floors\", args)\nend",
"def index\n @floor_plans = @location.floor_plans\n end",
"def index\n if params[:ax] && params[:ay] && params[:bx] && params[:by]\n @properties = Property.find_by_coordinates(\n upper_x: params[:ax],\n upper_y: params[:ay],\n bottom_x: params[:bx],\n bottom_y: params[:by]\n )\n else\n @properties = Property.all #in this case is much necessary to implement pagination system\n end\n\n respond_with :api, :v1, @properties, status: :ok\n end",
"def show\n up = bound_params[:uplat]\n down = bound_params[:downlat]\n left = bound_params[:leftlong]\n right = bound_params[:rightlong]\n markers = Marker.find_all_within_bounds(up, down, left, right)\n render :json => markers\n end",
"def energy_level_intervals\n result = {}\n @location = Location.find(params[:location_id])\n start_date = params[:start_date] ? Date.parse(params[:start_date]) : Date.today\n end_date = params[:end_date] ? Date.parse(params[:end_date]) : Date.today\n\n (start_date..end_date).each do |date|\n result[date] = @location.energy_level_intervals(date)\n end\n\n render :json => result\n end",
"def simple_tiles_bounds(options)\n [options[:bounds][:east],\n options[:bounds][:north],\n options[:bounds][:west],\n options[:bounds][:south]]\n end",
"def get_floor_area\n return @total_floor_area\n end",
"def index\n @property_land_shapes = PropertyLandShape.all\n end",
"def elevators_at_floor(floor)\n\t\televators.select{|elevator| elevator.floor.eql? floor}\n\tend",
"def get_bounds\n [ @min, @max ]\n end",
"def get_geo\n schools = School.within(2, :origin => [params[:lat], params[:lng]])\n\n @close_schools = []\n schools.each do |school|\n if school.lat != nil\n @close_schools << school\n end\n end\n respond_to do |format|\n format.json\n end\n end",
"def show\n @overlap = Overlap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @overlap }\n end\n end",
"def range\n @data_from_selected_sensor = SensorDatum.where(:sensor_id => params[:sensor_id])\n if params[:start] && params[:end]\n @start_time = Time.parse(params[:start])\n @end_time = Time.parse(params[:end])\n @sensor_datum = @data_from_selected_sensor.where(:created_at => @start_time..@end_time)\n\n elsif params[:start]\n @start_time = Time.parse(params[:start])\n @sensor_datum = @data_from_selected_sensor.where(:created_at => @start_time..Time.now)\n else\n @sensor_datum = { error: 'Please provide a valid date range'}\n end\n json_response(@sensor_datum)\n end",
"def get_contained_agencies(lat, lon)\n agencies = []\n\n AgencyBound.all.each do |bound|\n if lat.between?(bound.lat_min, bound.lat_max) and lon.between?(bound.lon_min, bound.lon_max)\n agencies.push(bound.agency)\n end\n end\n\n return agencies\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /property_between_floor_slaps POST /property_between_floor_slaps.json | def create
@property_between_floor_slap = PropertyBetweenFloorSlap.new(property_between_floor_slap_params)
respond_to do |format|
if @property_between_floor_slap.save
format.html { redirect_to @property_between_floor_slap, notice: 'Property between floor slap was successfully created.' }
format.json { render :show, status: :created, location: @property_between_floor_slap }
else
format.html { render :new }
format.json { render json: @property_between_floor_slap.errors, status: :unprocessable_entity }
end
end
end | [
"def index\n @property_between_floor_slaps = PropertyBetweenFloorSlap.all\n end",
"def create\n @shooting_range = ShootingRange.new(params[:shooting_range])\n\n respond_to do |format|\n if @shooting_range.save\n format.html { redirect_to(@shooting_range, :notice => 'Shooting range was successfully created.') }\n format.xml { render :xml => @shooting_range, :status => :created, :location => @shooting_range }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shooting_range.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @building = Building.new(building_params)\n @building.building_levels.build(building_params[:building_levels_attributes]) if params[:floor]\n render json: @building.errors unless @building.save\n end",
"def update\n respond_to do |format|\n if @property_between_floor_slap.update(property_between_floor_slap_params)\n format.html { redirect_to @property_between_floor_slap , notice: 'Property between floor slap was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_between_floor_slap }\n else\n format.html { render :edit }\n format.json { render json: @property_between_floor_slap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @overlap = Overlap.new(params[:overlap])\n\n respond_to do |format|\n if @overlap.save\n format.html { redirect_to @overlap, notice: 'Overlap was successfully created.' }\n format.json { render json: @overlap, status: :created, location: @overlap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @overlap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def within_bounds\n min_latitude = Float(params[:sw_latitude])\n max_latitude = Float(params[:ne_latitude])\n min_longitude = Float(params[:sw_longitude])\n max_longitude = Float(params[:ne_longitude])\n limit = 1000 || params[:limit]\n offset = 0 || params[:offset]\n approved = true || params[:approved]\n @trailheads = Trailhead.where(\"latitude > :min_latitude AND latitude < :max_latitude AND longitude > :min_longitude AND longitude < :max_longitude\",\n :min_latitude => min_latitude, :min_longitude => min_longitude, :max_latitude => max_latitude, :max_longitude => max_longitude).limit(limit).offset(offset).approved\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trailheads }\n end\n end",
"def create\n @overlap_holding = OverlapHolding.new(overlap_holding_params)\n\n respond_to do |format|\n if @overlap_holding.save\n format.html { redirect_to @overlap_holding, notice: 'Overlap holding was successfully created.' }\n format.json { render :show, status: :created, location: @overlap_holding }\n else\n format.html { render :new }\n format.json { render json: @overlap_holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @property_land_shape = PropertyLandShape.new(property_land_shape_params)\n\n respond_to do |format|\n if @property_land_shape.save\n format.html { redirect_to @property_land_shape, notice: 'Property land shape was successfully created.' }\n format.json { render :show, status: :created, location: @property_land_shape }\n else\n format.html { render :new }\n format.json { render json: @property_land_shape.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @property_road = PropertyRoad.new(property_road_params)\n\n respond_to do |format|\n if @property_road.save\n format.html { redirect_to @property_road, notice: 'Property road was successfully created.' }\n format.json { render :show, status: :created, location: @property_road }\n else\n format.html { render :new }\n format.json { render json: @property_road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @property_between_floor_slap.destroy\n respond_to do |format|\n format.html { redirect_to property_between_floor_slaps_url, notice: 'Property between floor slap was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def new_range\n @job = Job.find(params[:id])\n @range = TicketRange.new(:from => params[:from], :to => params[:to])\n \n @all_ranges = TicketRange.all\n @overlapping_id = 0\n \n @all_ranges.each do |i|\n if i.from <= @range.to && @range.to <= i.to\n @overlapping_id = i.job_id\n break;\n end\n if i.from <= @range.from && @range.from <= i.to\n @overlapping_id = i.job_id\n break;\n end\n if i.to <= @range.to && i.from >= @range.from\n @overlapping_id = i.job_id\n break;\n end\n end\n \n if @overlapping_id == 0\n @range.save\n @job.ticket_ranges.push(@range)\n render :text => @job.ticket_ranges.last.id\n else\n render :status => 306, :text => Job.find(@overlapping_id).name\n end\n end",
"def rangeSights\n sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: sightings\n end",
"def build_geographies\n build_start_or_end_area unless start_or_end_area\n build_trip_within_area unless trip_within_area\n end",
"def floor_rooms\n\t\t@rooms[floor_no]\n\tend",
"def create\n @salary_range = SalaryRange.new(params[:salary_range])\n\n respond_to do |format|\n if @salary_range.save\n format.html { redirect_to @salary_range, notice: 'Salary range was successfully created.' }\n format.json { render json: @salary_range, status: :created, location: @salary_range }\n else\n format.html { render action: \"new\" }\n format.json { render json: @salary_range.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @floor_monster = FloorMonster.new(params[:floor_monster])\n\n if (@floor_monster.position<1)\n @floor_monster.position = 1\n end\n @floor = Floor.where(id: @floor_monster.floor_id).first\n if (@floor_monster.position>@floor.size)\n @floor_monster.position = @floor.size\n end\n @floor_monster.save\n\n respond_to do |format|\n if @floor_monster.save\n format.html { redirect_to @floor_monster, notice: 'Floor monster was successfully created.' }\n format.json { render json: @floor_monster, status: :created, location: @floor_monster }\n else\n format.html { render action: \"new\" }\n format.json { render json: @floor_monster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ranges covered: true, street: nil\n grouped_lines.each do |city, streets|\n streets.each do |street, range_str|\n streets[ street ] = create_range( range_str, street, covered)\n end\n end\n end",
"def create\n @data_source_overlaps = DataSourceOverlaps.new(params[:data_source_overlaps])\n\n respond_to do |format|\n if @data_source_overlaps.save\n flash[:notice] = 'DataSourceOverlaps was successfully created.'\n format.html { redirect_to(@data_source_overlaps) }\n format.xml { render :xml => @data_source_overlaps, :status => :created, :location => @data_source_overlaps }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @data_source_overlaps.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_laps(race_id, data_file, lap_meter, km_race, tot_race_time_sec, insert_last_partial)\n fname = File.join(File.dirname(__FILE__), data_file)\n lap_nr = 1\n tot_meter = 0\n tot_time_sec = 0\n @items = []\n File.open(fname, 'r').each_line do |line|\n arr_laps_str = line.split(\" \")\n arr_laps_str.each do |value_s|\n #p value_s\n t1 = Time.parse(value_s)\n #p t1.methods\n lap_sec = t1.hour * 3600 + t1.min * 60 + t1.sec\n tot_time_sec += lap_sec\n tot_meter = lap_meter * lap_nr \n item = RaceDetailItem.new\n item.lap_number = lap_nr\n item.lap_time = value_s\n item.lap_meter = lap_meter\n item.lap_pace_minkm = calc_pace_in_min_sec(lap_meter, lap_sec) \n item.tot_meter_race = tot_meter\n item.tot_race_minkm = calc_pace_in_min_sec(tot_meter, tot_time_sec) \n item.race_id = race_id\n item.tot_race_time = format_seconds(tot_time_sec)\n item.tot_km_race = tot_meter / 1000\n item.completed = true\n #p item\n @items << item\n lap_nr += 1\n #exit if lap_nr == 9\n end\n #p line\n end\n @log.debug \"Collected #{@items.size} laps. Completed laps km #{@items.last.tot_km_race} in #{@items.last.tot_race_time} \"\n\n # last lap is not completed but it is the difference between total km and the last completed sum\n if insert_last_partial\n t1 = Time.parse(@items.last.tot_race_time)\n completed_lap_sec = t1.hour * 3600 + t1.min * 60 + t1.sec\n lap_sec = tot_race_time_sec - completed_lap_sec\n item = RaceDetailItem.new\n item.lap_number = lap_nr\n item.lap_time = format_seconds(lap_sec)\n item.lap_meter = km_race * 1000 - @items.last.tot_km_race * 1000\n item.lap_pace_minkm = calc_pace_in_min_sec(item.lap_meter, lap_sec) \n item.tot_meter_race = km_race * 1000\n item.tot_race_minkm = calc_pace_in_min_sec(km_race * 1000, tot_race_time_sec) \n item.race_id = race_id\n item.tot_race_time = format_seconds(tot_race_time_sec)\n item.tot_km_race = km_race\n item.completed = false\n #p item\n @items << item\n end\n \n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /property_between_floor_slaps/1 PATCH/PUT /property_between_floor_slaps/1.json | def update
respond_to do |format|
if @property_between_floor_slap.update(property_between_floor_slap_params)
format.html { redirect_to @property_between_floor_slap , notice: 'Property between floor slap was successfully updated.' }
format.json { render :show, status: :ok, location: @property_between_floor_slap }
else
format.html { render :edit }
format.json { render json: @property_between_floor_slap.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n respond_to do |format|\n if @property_land_shape.update(property_land_shape_params)\n format.html { redirect_to @property_land_shape, notice: 'Property land shape was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_land_shape }\n else\n format.html { render :edit }\n format.json { render json: @property_land_shape.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @property_road.update(property_road_params)\n format.html { redirect_to @property_road, notice: 'Property road was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_road }\n else\n format.html { render :edit }\n format.json { render json: @property_road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: @building_level.errors unless @building_level.update(building_level_params)\n end",
"def save_floorplan_settings(args = {}) \n put(\"/userproperties.json/floorplan/#{args[:floorplanId]}\", args)\nend",
"def update\n respond_to do |format|\n if @floor_geometry.update(floor_geometry_params)\n format.html { redirect_to @floor_geometry, notice: 'Floor geometry was successfully updated.' }\n format.json { render :show, status: :ok, location: @floor_geometry }\n else\n format.html { render :edit }\n format.json { render json: @floor_geometry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location_property = LocationProperty.find(params[:id])\n\n respond_to do |format|\n if @location_property.update_attributes(params[:location_property])\n format.html { redirect_to @location_property, notice: 'Location property was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location_property.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @overlap = Overlap.find(params[:id])\n\n respond_to do |format|\n if @overlap.update_attributes(params[:overlap])\n format.html { redirect_to @overlap, notice: 'Overlap was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @overlap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @floor_stage.update(floor_stage_params)\n format.html { redirect_to @floor_stage, notice: 'Stage was successfully updated.' }\n format.json { render :show, status: :ok, location: @floor_stage }\n else\n format.html { render :edit }\n format.json { render json: @floor_stage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @building = Building.find(params[:building_id])\n @floor = @building.floors.find(params[:id])\n authorize! :update, @floor, :message => 'Acceso denegado.'\n\n respond_to do |format|\n if @floor.update_attributes(params[:floor])\n format.html { redirect_to([@university, @campus, @building, @floor], :notice => 'El piso fue modificado con éxito') }\n format.json { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @floor.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n respond_to do |format|\n if @floor_plan.update_attributes(floor_plan_params)\n format.html { redirect_to admin_property_floor_plan_url(@property, @floor_plan), notice: 'Floor plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rooms\n @property = Property.find(params[:id])\n if @property.belongs_to_user(session[:user_id])\n @room_areas = @property.room_areas\n for room_area in @property.room_areas\n room_area.update_attributes(params[room_area.id.to_s])\n end\n else\n redirect_to :action => 'list'\n end\n redirect_to(:action => 'fittings', :id => params[:id])\n end",
"def update\n respond_to do |format|\n if @property_street_location.update(property_street_location_params)\n format.html { redirect_to @property_street_location, notice: 'Property street location was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_street_location }\n else\n format.html { render :edit }\n format.json { render json: @property_street_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @overlap_holding.update(overlap_holding_params)\n format.html { redirect_to @overlap_holding, notice: 'Overlap holding was successfully updated.' }\n format.json { render :show, status: :ok, location: @overlap_holding }\n else\n format.html { render :edit }\n format.json { render json: @overlap_holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @property_closet.update(property_closet_params)\n format.html { redirect_to @property_closet, notice: 'Property closet was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_closet }\n else\n format.html { render :edit }\n format.json { render json: @property_closet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shooting_range = ShootingRange.find(params[:id])\n\n respond_to do |format|\n if @shooting_range.update_attributes(params[:shooting_range])\n format.html { redirect_to(@shooting_range, :notice => 'Shooting range was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shooting_range.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @floorplan.update(floorplan_params)\n format.html { redirect_to @floorplan, notice: 'floorplan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @floorplan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @spec_property = SpecProperty.find(params[:id])\n\n respond_to do |format|\n if @spec_property.update_attributes(params[:spec_property])\n format.html { redirect_to spec_properties_url, notice: '自定义规格已更新成功.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spec_property.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @floor_plan.update(floor_plan_params)\n format.html { redirect_to @floor_plan, notice: 'Floor plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @floor_plan }\n else\n format.html { render :edit }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @floor_plan.update(floor_plan_params)\n format.html { redirect_to :back, notice: 'Floor plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /property_between_floor_slaps/1 DELETE /property_between_floor_slaps/1.json | def destroy
@property_between_floor_slap.destroy
respond_to do |format|
format.html { redirect_to property_between_floor_slaps_url, notice: 'Property between floor slap was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @property_road.destroy\n respond_to do |format|\n format.html { redirect_to property_roads_url, notice: 'Property road was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @floor_plan.destroy\n respond_to do |format|\n format.html { redirect_to location_path(@location) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor = Floor.find(params[:id])\n @floor.destroy\n\n respond_to do |format|\n format.html { redirect_to floors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor_plan.destroy\n render json: @floor_plan\n end",
"def destroy\n @property_land_shape.destroy\n respond_to do |format|\n format.html { redirect_to property_land_shapes_url, notice: 'Property land shape was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor.destroy\n respond_to do |format|\n format.html { redirect_to floors_url, notice: I18n.t('floors.destroy') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor_status.destroy\n respond_to do |format|\n format.html { redirect_to floor_statuses_url, notice: 'Status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location_property = LocationProperty.find(params[:id])\n @location_property.destroy\n\n respond_to do |format|\n format.html { redirect_to location_properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor_geometry.destroy\n respond_to do |format|\n format.html { redirect_to floor_geometries_url, notice: 'Floor geometry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property_street_location.destroy\n respond_to do |format|\n format.html { redirect_to property_street_locations_url, notice: 'Property street location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location_granularity.destroy\n respond_to do |format|\n format.html { redirect_to location_granularities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spatial_coverages = SpatialCoverages.find(params[:id])\n @spatial_coverages.destroy\n\n respond_to do |format|\n format.html { redirect_to spatial_coverage_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property_sidewalk.destroy\n respond_to do |format|\n format.html { redirect_to property_sidewalks_url, notice: 'Property sidewalk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location_level.destroy\n respond_to do |format|\n format.html { redirect_to location_levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @floor_ammenity.destroy\n respond_to do |format|\n format.html { redirect_to floor_ammenities_url, notice: 'Ammenity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leased_property = LeasedProperty.find(params[:id])\n @leased_property.destroy\n\n respond_to do |format|\n format.html { redirect_to leased_properties_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @overlap_holding.destroy\n respond_to do |format|\n format.html { redirect_to overlap_holdings_url, notice: 'Overlap holding was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @property = Property.find(params[:id])\n # @property.destroy\n \n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unregisters the webhook with Jive | def unregister_webhook
require "open-uri"
require "net/http"
require "openssl"
return if self.add_on.nil? # Can't do it without a token!
return if self.oauth_token.nil? # Can't do it without a token!
uri = URI.parse("#{self.add_on.jive_url}/api/core/v3/webhooks/#{self.webhook_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{self.oauth_token.access_token}"
response = http.request(request)
# Need 2XX status code
if !response.code.to_i.between?(200, 299)
errors[:base] << "#{request.inspect} => #{response.body}"
return false
end
true
end | [
"def remove_webhook\n request(URL::WEBHOOK, url: '')\n end",
"def delete_webhook\n send_request('deleteWebhook', {})\n end",
"def unsubscribe_request_hook(name)\n EasyPost::Hooks.unsubscribe(:request, name)\n end",
"def delete_webhook(target_url)\n Uploadcare::Webhook.delete(target_url)\n end",
"def web_hook_unsubscribe(web_hook_subscribe_model)\n if web_hook_subscribe_model.blank?\n raise LoginRadius::Error.new, getValidationMessage('web_hook_subscribe_model')\n end\n\n query_parameters = {}\n query_parameters['apikey'] = @api_key\n query_parameters['apisecret'] = @api_secret\n\n resource_path = 'api/v2/webhook'\n delete_request(resource_path, query_parameters, web_hook_subscribe_model)\n end",
"def unregister\n Neo4j.event_handler.remove(self)\n end",
"def unsubscribe_response_hook(name)\n EasyPost::Hooks.unsubscribe(:response, name)\n end",
"def destroy\n @webhook_event_request.destroy\n respond_to do |format|\n format.html { redirect_to webhook_event_requests_url }\n format.json { head :no_content }\n end\n end",
"def remove_all_webhooks\n delete(\"/webhooks\")\n end",
"def destroy\n @webhook_endpoint.destroy\n respond_to do |format|\n format.html { redirect_to webhook_endpoints_url, notice: 'Webhook endpoint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def unsubscribe_all_request_hooks\n EasyPost::Hooks.unsubscribe_all(:request)\n end",
"def destroy\n @bitpay_webhook.destroy\n respond_to do |format|\n format.html { redirect_to bitpay_webhooks_url, notice: 'Bitpay webhook was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_hipchat_webhooks hipchat, room_name, webhook_name\n hipchat.delete_webhooks_by_name room_name, webhook_name\nend",
"def destroy\n @incoming_hook.destroy\n respond_to do |format|\n format.html { redirect_to incoming_hooks_url, notice: 'Incoming hook was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def handle_unregistered(data)\n request_id = data\n\n trigger(:unregistered, request_id)\n end",
"def delete\n require \"pact_broker/webhooks/triggered_webhook\"\n TriggeredWebhook.where(webhook: self).update(webhook_id: nil)\n super\n end",
"def unregister_stripe_webhook_if_necessary\n return unless previous_changes.include?(:stripe_secret_key)\n\n # secret key was changed\n\n # if we HAD a secret key\n if previous_changes[:stripe_secret_key][0].present?\n domain = default_url_options[:host]\n manager = StripeWebhook::Manager.new(previous_changes[:stripe_secret_key][0], domain)\n manager.unregister_callback\n end\n end",
"def unregister(username)\n data = \"unregister #{username} #{@host}\"\n response data\n end",
"def unregister\n user_to_be_removed = @event.users.find(current_user)\n if user_to_be_removed\n @event.users.delete(user_to_be_removed)\n end\n #flash[:notice] = \"Unregistered for #{@event.title}\"\n respond_to do |format|\n format.js\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Registers the webhook with Jive | def register_webhook
require "open-uri"
require "net/http"
require "openssl"
uri = URI.parse("#{self.add_on.jive_url}/api/core/v3/webhooks")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{self.oauth_token.access_token}"
body = {
"callback" => self.callback,
"object" => self.object,
}
body["events"] = self.events if !self.events.to_s.empty?
request.body = body.to_json
response = http.request(request)
# Need 2XX status code
if !response.code.to_i.between?(200, 299)
errors[:base] << "#{request.inspect} => #{response.body}"
return false
end
json_body = JSON.parse(response.body)
self.webhook_id = json_body["id"]
true
end | [
"def create_webhook(webhook_id, request)\n start.uri('/api/webhook')\n .url_segment(webhook_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def create_webhook(webhook_id, request)\n start.uri('/api/webhook')\n .url_segment(webhook_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def add_webhook\n get_api\n resp = {}\n begin\n resp = @api.lists(api_id).webhooks.create(\n body: {\n url: Rails.application.routes.url_helpers.webhooks_api_v0_mailchimp_list_url(\n id, \n only_path: false, \n host: APP_CONFIG[\"mailing-url\"].gsub(\"http://\",\"\")\n ),\n events: decode(webhook_configuration)[\"events\"],\n sources: decode(webhook_configuration)[\"sources\"]\n }\n ).body\n rescue Gibbon::MailChimpError => e\n Rails.logger.info \"Mailchimp webhook failed with error: #{e}\"\n resp = { \"id\" => nil, errors: get_errors(e.body) }\n end\n\n if resp[\"id\"].nil?\n self.errors.add(:base, resp[:errors])\n else\n new_config = decode(webhook_configuration)\n new_config[:id] = resp[\"id\"]\n update_attribute(:webhook_configuration, encode(new_config))\n update_attribute(:receive_notifications, true)\n end\n end",
"def sinatra_hook\n @webhook || Proc.new {}\n end",
"def add_webhook(project_id_or_key, name, hook_url, params = {})\n params[:name] = name\n params[:hook_url] = hook_url\n post(\"projects/#{project_id_or_key}/webhooks\", params)\n end",
"def create\n @webhook = @namespace.webhooks.build(webhook_params)\n authorize @webhook\n\n if @webhook.save\n @webhook.create_activity :create, owner: current_user\n respond_with @namespace, @webhook\n else\n respond_with @webhook.errors, status: :unprocessable_entity\n end\n end",
"def post_webhook\n HTTParty.post(\n \"https://api.trello.com/1/tokens/#{user.token}/webhooks/?key=#{ENV['TRELLO_KEY']}\",\n query: {\n description: \"Sprint webhook user#{user.id}\",\n callbackURL: \"#{ENV['BASE_URL']}webhooks\",\n idModel: trello_ext_id\n },\n headers: { \"Content-Type\" => \"application/json\" }\n )\n end",
"def webhooks\n @webhooks ||= WebhookRegistry.new\n end",
"def setup_shopify_webhook(topic, meth)\n unless ShopifyAPI::Webhook.count(topic: topic) > 0\n address = send :webhook_url, meth\n ShopifyAPI::Webhook.create topic: topic, address: address, format: 'json'\n end\n end",
"def create_webhook\n @client.create_hook(\"#{repo.user.github_username}/#{repo.name}\",\n 'web',\n {url: \"#{ENV['ISSUE_TRACKR_APP_URL']}/webhooks/receive\", content_type: 'json'},\n {events: ['issues'], active: true})\n end",
"def new_webhook()\n Webhook.new(self)\n end",
"def webhook\n puts params\n\n status 200\n end",
"def webhook\r\n WebhookController.instance\r\n end",
"def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n content_type: 'json'\n },\n {\n events: ['release'],\n active: true\n }\n )\n\n self.github_hook_id = hook.id\n end",
"def webhook\n @webhook ||= Plaid::Webhook.new(@client)\n end",
"def set_webhook(url)\n send_request('setWebhook', {\"url\":url})\n end",
"def create(addon_id_or_addon_name, body = {})\n @client.addon_webhook.create(addon_id_or_addon_name, body)\n end",
"def setup_shopify_webhooks\n setup_shopify_webhook 'orders/create', :new_order\n setup_shopify_webhook 'carts/create', :new_cart\n setup_shopify_webhook 'carts/update', :updated_cart\n setup_shopify_webhook 'app/uninstalled', :app_uninstalled\n end",
"def create_webhook(post_url, include_received_email, events)\n include_received_email = include_received_email ? true : false\n url = \"v2/#{account_id}/webhooks\"\n\n make_json_api_request :post, url, private_generate_resource(\n \"webhooks\",\n {\n \"post_url\" => post_url,\n \"include_received_email\" => include_received_email,\n \"events\" => events\n }\n )\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Refresh one feed source and return the updated feed items | def refresh
FeedSource.find(params[:feed_source_id]).refresh
feed_sources = params[:feed_sources]
@feed_source_titles = {}
FeedSource.find(feed_sources).each { |source| @feed_source_titles[source.id] = source.title}
@feed_items = FeedItem.where("feed_source_id IN (?)", feed_sources).order(pub_date: :desc).limit(20).offset(0)
@feed_items = @feed_items.sort_by{ |item| item.pub_date.to_i }.reverse
render :index
end | [
"def refresh_feed(feed)\n FeedRefreshManager.refresh feed, self\n end",
"def update!\n data = fx_feed.get\n data = remove_cached_records(data)\n data.each(&:save)\n end",
"def refresh!\n fetch_data\n end",
"def refresh\n raise \"Source classes must implement their own `refresh` method\"\n end",
"def refresh(all)\n Gem.sources.each do |source_uri|\n cache_entry = cache_data[source_uri]\n if cache_entry.nil? then\n cache_entry = Gem::SourceInfoCacheEntry.new nil, 0\n cache_data[source_uri] = cache_entry\n end\n\n update if cache_entry.refresh source_uri, all\n end\n\n flush\n end",
"def refresh\n\n @err_report = []\n\n puts '@dx.to_xml' + @dx.to_xml(pretty: true) if @debug\n\n @dx.all.each do |feed|\n\n puts 'feed:' + feed.inspect if @debug\n\n if feed.next_refresh.empty? or \\\n Time.now >= Time.parse(feed.next_refresh) then\n\n any_new_items = updates? feed\n\n feed.refresh_rate = if feed.refresh_rate.empty? then\n\n 10\n\n else\n\n if Time.now > Time.parse(feed.next_refresh) + \\\n feed.refresh_rate.to_i and not any_new_items then\n feed.refresh_rate.to_i + 10\n end\n\n end\n\n\n feed.next_refresh = Time.now + feed.refresh_rate.to_i * 60\n\n\n else\n\n feed.refresh_rate = feed.refresh_rate.to_i - 10 if feed.refresh_rate.to_i > 10\n\n end\n end\n\n puts '@dx: ' + @dx.to_xml(pretty: true) if @debug\n save()\n\n end",
"def refresh\n Gem.sources.each do |source_uri|\n cache_entry = cache_data[source_uri]\n if cache_entry.nil? then\n cache_entry = Gem::SourceInfoCacheEntry.new nil, 0\n cache_data[source_uri] = cache_entry\n end\n\n update if cache_entry.refresh source_uri\n end\n\n flush\n end",
"def pull_refresh(refresh = true)\n refresh(@endpoint) do |data|\n @stories = data\n view.reloadData\n @refreshControl.endRefreshing\n end\n end",
"def run\n @logging.debug 'Starting polling'\n @polling = true\n\n while @polling\n pending_feeds = Feed.all.select &:pending_refresh?\n\n pending_feeds.each do |feed|\n @logging.debug \"Requesting `#{feed.url}'\"\n\n update_feed feed\n end\n\n sleep 1\n end\n end",
"def update\n @feed = current_user.feeds.find params[:id]\n current_user.refresh_feed @feed\n\n head :ok\n rescue => e\n handle_error e\n end",
"def get_feed\n if has_a_new_version?\n store_etag_and_last_modified_on\n get_uncached_feed\n end\n end",
"def feed_items\n return @feed_items.dup\n end",
"def refresh\n do_refresh\n end",
"def refresh!\n current_time = Time.current\n self.refresh_started_at = current_time\n self.next_refresh_at = current_time.advance(seconds: refresh_every)\n save\n\n if FeedRefresher.refresh(self)\n self.last_refreshed_at = current_time\n end\n\n self.refresh_started_at = nil\n save\n end",
"def update!\n raise(RuntimeError, \"can't fetch without a uri.\") unless @uri\n\n res = @http.get(@uri, \"Accept\" => \"application/atom+xml\")\n\n if @etag and res['etag'] == @etag\n # we're already all up to date\n return self\n elsif res.code == \"410\"\n raise Atom::FeedGone, \"410 Gone (#{@uri})\"\n elsif res.code != \"200\"\n raise Atom::HTTPException, \"Unexpected HTTP response code: #{res.code}\"\n end\n\n # we'll be forgiving about feed content types.\n res.validate_content_type([\"application/atom+xml\",\n \"application/xml\",\n \"text/xml\"])\n\n @etag = res[\"ETag\"] if res[\"ETag\"]\n\n xml = res.body\n\n coll = REXML::Document.new(xml)\n\n update_el = REXML::XPath.first(coll, \"/atom:feed/atom:updated\", { \"atom\" => Atom::NS } )\n\n # the feed hasn't been updated, don't do anything.\n if update_el and self.updated and self.updated >= Time.parse(update_el.text)\n return self\n end\n\n coll = self.class.parse(coll.root, self.base.to_s)\n merge! coll\n\n if abs_uri = next_link\n @next = self.class.new(abs_uri.to_s, @http)\n end\n\n if abs_uri = previous_link\n @prev = self.class.new(abs_uri.to_s, @http)\n end\n\n self\n end",
"def update!\n # Don't do anything if this option is set\n return if self.configurations[:disable_update_from_remote]\n\n if !FeedTools.feed_cache.nil? &&\n !FeedTools.feed_cache.set_up_correctly?\n FeedTools.feed_cache.initialize_cache()\n end\n if !FeedTools.feed_cache.nil? &&\n !FeedTools.feed_cache.set_up_correctly?\n raise \"Your feed cache system is incorrectly set up. \" +\n \"Please see the documentation for more information.\"\n end\n if self.http_headers.blank? && !(self.cache_object.nil?) &&\n !(self.cache_object.http_headers.nil?)\n @http_headers = YAML.load(self.cache_object.http_headers)\n @http_headers = {} unless @http_headers.kind_of? Hash\n elsif self.http_headers.blank?\n @http_headers = {}\n end\n if self.expired? == false\n @live = false\n else\n load_remote_feed!\n \n # Handle autodiscovery\n if self.http_headers['content-type'] =~ /text\\/html/ ||\n self.http_headers['content-type'] =~ /application\\/xhtml\\+xml/\n\n autodiscovered_url = nil\n ['atom', 'rss', 'rdf'].each do |type|\n autodiscovered_url =\n FeedTools::HtmlHelper.extract_link_by_mime_type(self.feed_data,\n \"application/#{type}+xml\")\n break unless autodiscovered_url.nil?\n end\n \n if autodiscovered_url != nil\n begin\n autodiscovered_url = FeedTools::UriHelper.resolve_relative_uri(\n autodiscovered_url, [self.href])\n rescue Exception\n end\n if self.href == autodiscovered_url\n raise FeedAccessError,\n \"Autodiscovery loop detected: #{autodiscovered_url}\"\n end\n self.feed_data = nil\n \n self.href = autodiscovered_url\n if FeedTools.feed_cache.nil?\n self.cache_object = nil\n else\n self.cache_object =\n FeedTools.feed_cache.find_by_href(autodiscovered_url)\n end\n self.update!\n else\n html_body = FeedTools::XmlHelper.try_xpaths(self.xml_document, [\n \"html/body\"\n ])\n if html_body != nil\n raise FeedAccessError,\n \"#{self.href} does not appear to be a feed.\"\n end\n end\n else\n ugly_redirect = FeedTools::XmlHelper.try_xpaths(self.xml_document, [\n \"redirect/newLocation/text()\"\n ], :select_result_value => true)\n if !ugly_redirect.blank?\n if self.href == ugly_redirect\n raise FeedAccessError,\n \"Ugly redirect loop detected: #{ugly_redirect}\"\n end\n self.feed_data = nil\n self.href = ugly_redirect\n if FeedTools.feed_cache.nil?\n self.cache_object = nil\n else\n self.cache_object =\n FeedTools.feed_cache.find_by_href(ugly_redirect)\n end\n self.update!\n end\n end\n \n # Reset everything that needs to be reset.\n @xml_document = nil\n @encoding_from_feed_data = nil\n @root_node = nil\n @channel_node = nil\n @id = nil\n @title = nil\n @subtitle = nil\n @copyright = nil\n @link = nil\n @time_to_live = nil\n @entries = nil\n \n if self.configurations[:lazy_parsing_enabled] == false\n self.full_parse()\n end\n end\n end",
"def cache_feeds\n puts \"Caching feeds... (can be slow)\"\n feeds = Conf.feeds.map do |uri|\n # silly to need this, but if the feed fails to fetch,\n # don't kill the ruby thread ...\n begin\n feed = FeedTools::Feed.open( uri )\n { :uri => uri, :title => feed.title, \n :items => feed.items.map { |item| { :title => item.title, :author => item.author.name, :published => item.published, :link => item.link } } }\n rescue FeedTools::FeedAccessError\n puts uri\n next\n end\n end\n feeds.each { |feed|\n new = CachedFeed.find_or_initialize_by_uri( feed[:uri] )\n new.parsed_feed = feed\n new.save!\n }\n end",
"def refresh\n mirror_list.refresh\n end",
"def refresh \n @result, @processedMovies, @errors = Movie.refresh_listings\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Store page title options that are used on I18n interpolation. | def page_title_options
@page_title_options ||= {}
end | [
"def page_title(options = {})\n return \"\" if @page.title.blank?\n\n options = {\n prefix: \"\",\n suffix: \"\",\n separator: \"\"\n }.update(options)\n title_parts = [options[:prefix]]\n title_parts << if response.status == 200\n @page.title\n else\n response.status\n end\n title_parts << options[:suffix]\n title_parts.reject(&:blank?).join(options[:separator]).html_safe\n end",
"def page_title title, options = {}\n if defined? set_meta_tags\n set_meta_tags site: t('app.name'), title: title, reverse: true\n end\n content_for(:page_title) { title } if options[:in_page]\n content_for(:head_title) { title }\n end",
"def set_page_title\n set_ivar_on_view \"@page_title\", title\n end",
"def set_meta_title(options = {})\n\t\t@meta[:title_raw] = I18n.translate(\"#{meta_key}.title\", options)\n\n\t\tif have_translation?(@meta[:title_raw])\n\t\t\t@meta[:title] = \"#{@meta[:prefix]}#{@meta[:title_raw]}#{@meta[:suffix]}\"\n\t\telse\n\t\t\t@meta[:title] = I18n.translate(\"#{meta_key}.full_title\", options)\n\t\t\t@meta[:title] = I18n.translate('meta.default.title') if !have_translation?(@meta[:title])\n\n\t\t\t@meta[:title_raw] = @meta[:title]\n\t\tend\n\t\t\n\t\t@meta[:title]\n\tend",
"def set_page_title\n set_ivar_on_view \"@page_title\", title\n end",
"def title\n options.fetch(:title)\n end",
"def page_title=(val)\n @page_title = val\n end",
"def render_page_title options={}\n default_options = {\n :prefix => \"\",\n :seperator => \"|\"\n }\n default_options.update(options)\n unless current_page.title.blank?\n h(\"#{default_options[:prefix]} #{default_options[:seperator]} #{current_page.title}\")\n else\n h(\"\")\n end\n end",
"def page_title(options = {})\n return \"\" if @page.title.blank?\n options = {\n prefix: \"\",\n suffix: \"\",\n separator: \"\"\n }.update(options)\n title_parts = [options[:prefix]]\n if response.status == 200\n title_parts << @page.title\n else\n title_parts << response.status\n end\n title_parts << options[:suffix]\n title_parts.reject(&:blank?).join(options[:separator]).html_safe\n end",
"def page_title\n @page_title ||= begin\n aliases = {\n \"create\" => \"new\",\n \"update\" => \"edit\",\n \"remove\" => \"destroy\"\n }\n\n # the controller is self when calling from controller instance\n controller = self unless respond_to?(:controller)\n\n controller_name = controller.controller_name\n action_name = controller.action_name\n action_name_alias = aliases[action_name] || action_name\n options = (@page_title_options || {}).merge(:raise => true)\n\n # First, let's check if there's a action title without the alias\n title = I18n.translate(\"titles.#{controller_name}.#{action_name}\", options) rescue nil\n\n # Then we lookup for the aliased title\n title ||= I18n.translate(\"titles.#{controller_name}.#{action_name_alias}\", options) rescue nil\n\n # Finally we set it as titleized\n title ||= \"#{controller_name.titleize} #{action_name.titleize}\"\n\n title\n end\n end",
"def set_page_title(title)\n @page_title = title\n end",
"def page_title=(title)\n @content_for_page_title = title\n end",
"def title(title, global=true)\n global ? (before << \"Backend.app.setTitle(#{title.to_json});\") : config[:title] = title\n end",
"def title_help \n\n\t\t#Define general page title\n\t\tbase_title = \"Rex Ruby on Rails Learning | PagesHelper\"\n\t\tif(@title.nil?)\n\t\t\tbase_title\n\t\telse\n\t\t\tbase_title = \"Rex Ruby on Rails Learning | #{@title} | PagesHelper\"\n\t\tend\n\tend",
"def title(page_title)\n\t\t\tmode = \"[DEV] \" unless ::Rails.env.production?\n\t\t\tcontent_for(:title) { mode.to_s + page_title + \" | \" }\n\t\tend",
"def title\n @title ||= begin\n if site_title && page_title != site_title\n page_title + TITLE_SEPARATOR + site_title\n elsif site_description && site_title\n site_title + TITLE_SEPARATOR + site_description\n else\n page_title || site_title\n end\n end\n end",
"def set_page_title\n case @title\n when 'Winter', 'Spring', 'Summer', 'Fall'\n parent_content = Content.new(@parent_path)\n @page_title = @title + ' ' + parent_content.title\n else\n @page_title = @title\n end\n end",
"def title(page_title)\n # Only set the content_for if not already set on the page so that only the first title appears as the tab title\n content_for(:page_title) { page_title } if content_for(:page_title).blank?\n page_title\n end",
"def title(page_title, options={})\n content_for(:title, page_title.to_s)\n return content_tag(:h1, page_title, options)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override in the subclass to provide a place to do initialization of game logic, load files, set up state, etc | def game_setup
end | [
"def initialize\n\t\tinitialize_game\n\tend",
"def initialize_game\n setup_boards\n end",
"def process_init\n end",
"def post_init\n end",
"def initialize(parent_wnd)\r\n super(parent_wnd)\r\n \r\n @core_game = nil\r\n @splash_name = File.join(@resource_path, \"icons/mariazza_title_trasp.png\")\r\n @algorithm_name = \"AlgCpuMariazza\" \r\n #core game name (created on base class)\r\n @core_name_class = 'CoreGameMariazza'\r\n \r\n # game commands\r\n @game_cmd_bt_list = []\r\n\r\n ## NOTE: don't forget to initialize variables also in ntfy_base_gui_start_new_game\r\n end",
"def initialize fps, title\n # The sprite and sound managers.\n @spriteManager = SpriteManager.new\n @soundManager = SoundManager.new 3\n\n # Number of frames per second.\n @framesPerSecond = fps\n\n # Title in the application window.\n @windowTitle = title\n\n # create and set timeline for the game loop\n buildAndSetGameLoop\n end",
"def init_game\n return if state.tick_count != 0\n\n state.current_scene = :start\n\n state.red_color = { r: 222, g: 63, b: 66 }\n state.gray_color = { r: 128, g: 128, b: 128 }\n\n state.events ||= {\n game_over_at: nil,\n game_started_at: nil,\n game_retried_at: nil\n }\n\n state.score_last_game = 0\n state.best_score = 0\n state.viewport = { x: 0, y: 0, w: 1280, h: 720 }\n end",
"def initialize(*saved_info)\n\t\tif saved_info.empty?\n\t\t\tnew_game\n\t\telse\n\t\t\tload_game(saved_info)\n\t\tend\n\tend",
"def preReady()\n\t\t\t#does nothing. extend in subclasses\n\t\tend",
"def initialize\n # Call subclass on_init method if applicable.\n self.on_init if self.respond_to? :on_init\n end",
"def initialize(parent_wnd)\r\n super(parent_wnd)\r\n \r\n @core_game = nil\r\n @splash_name = File.join(@resource_path, \"icons/mariazza_title_trasp.png\")\r\n @algorithm_name = \"AlgCpuMariazza\" \r\n @core_name_class = 'CoreGameMariazza'\r\n @log = Log4r::Logger.new(\"coregame_log::MariazzaGfx\") \r\n \r\n init_command_buttons\r\n end",
"def initialize\n @game_settings = GameSettings.new\n super 920, 480\n self.caption = GAME_TITLE\n @settings_hovered = Options::START_SCREEN[0]\n @title_font, @subtitle_font = Gosu::Font.new(50), Gosu::Font.new(20)\n @background_image = Gosu::Image.new(\"media/background1.jpg\", :tileable => true)\n @blank_card = Gosu::Image.new(\"media/card.png\", :tileable => true)\n @button_option = Gosu::Image.new(\"media/button.png\", :tileable => true)\n @deck = Deck.new\n @playing_cards = Array.new\n @computer_signal = ComputerTimer.new\n @players_created, @mes, @false_mes, @true_mes, @trying_mes = false, false, false, false, false\n @hint = []\n #players\n @pressed, @p1, @p2 = nil, nil, nil\n @game_timer = Timers.new\n end",
"def initialize\n\n @prompt = TTY::Prompt.new\n escape_to_welcome\n LoadAssets.load_logo\n\n end",
"def initialize(window, relative_position)\n @relative_position = relative_position\n @image = Gosu::Image.new(window, \"./media/Player.png\")\n super @image.width, @image.height, Gosu::Color::NONE, relative_position\n @speed = [0.0, 0.0].to_vec2d\n @stop_down = false\n @jump_speed = [0.0, 0.0].to_vec2d\n @health = 1.0\n @score = 0\n end",
"def initialize(zone = nil)\n # Type of viewport the spriteset map uses\n viewport_type = :main\n exec_hooks(Spriteset_Map, :viewport_type, binding)\n init_viewports(viewport_type)\n Yuki::ElapsedTime.start(:spriteset_map)\n exec_hooks(Spriteset_Map, :initialize, binding)\n init_tilemap\n init_panorama_fog\n init_characters\n init_player\n init_weather_picture_timer\n finish_init(zone)\n rescue ForceReturn => e\n log_error(\"Hooks tried to return #{e.data} in Spriteset_Map#initialize\")\n end",
"def setup_game\n\t\t@game_board = Board.new\n\t\t@game_engine = GameEngine.new(@game_board)\n\t\tupdate_ui\n\tend",
"def initialize(options = {})\n options = default_options.merge(options)\n require_keys!(options, [:engine_path, :movetime])\n @movetime = options[:movetime]\n\n set_debug(options)\n reset_board!\n set_startpos!\n\n check_engine(options)\n set_engine_name(options)\n open_engine_connection(options[:engine_path])\n set_engine_options(options[:options]) if !options[:options].nil?\n new_game!\n end",
"def initialize\n # Do some setup stuff\nend",
"def initialize(player, coregame, cup_gui)\r\n super\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called on an instance of the subclass, this will run the game_setup method and then begin the show loop on the delegate | def game_start
game_setup
@console_delegate.show
end | [
"def game_setup\n end",
"def setup_game\n\t\t@game_board = Board.new\n\t\t@game_engine = GameEngine.new(@game_board)\n\t\tupdate_ui\n\tend",
"def setup_new_game\n Game.new.play\n end",
"def run\r\n @log.debug \"Run the tester...\"\r\n @dlg_box = CupSingleGameWin.new(@options)\r\n @dlg_box.create\r\n end",
"def run\n start_game\n game_loop\n end_game\n end",
"def start_game\n\n # Dev server interaction\n # FIXME: Shift this to 'login to server' interaction\n # \n @client_network_com.send_message(['setup', @game_state_model::players[@game_state_model::player_role]::name, @game_state_model::players[@game_state_model::player_role].player_color].join('|'))\n @controllers[:game]::view::grid.set_tiles\n initialize(568, 343, model: @game_state_model)\n @currentCtrl = @controllers[:game]\n\n end",
"def start\n GAME.play\n render_all\n end",
"def run_cycle\n\t\t\t\tsuper()\n\t\t\t\t\n\t\t\t\t#puts 'UIApp->run_cycle'\n\t\t\t\t\n\t\t\t\trender\n\t\t\tend",
"def initialize fps, title\n # The sprite and sound managers.\n @spriteManager = SpriteManager.new\n @soundManager = SoundManager.new 3\n\n # Number of frames per second.\n @framesPerSecond = fps\n\n # Title in the application window.\n @windowTitle = title\n\n # create and set timeline for the game loop\n buildAndSetGameLoop\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def start(*args)\n self.setup\n self.show_all(*args)\n Nyle.main\n end",
"def setup\n self.caption = \"RubyMiner v 0.1\"\n push_game_state(Menu)\n end",
"def start_found_game\n listen_for_challenge\n game_on\n run_game\n end",
"def play\n\t\tgame_loop\n\tend",
"def setup_display\n gameboard.build_display\n build_white_side\n build_black_side\n end",
"def main\n data_load\n title_animation unless debug? && (ARGV.include?('skip_title') || PSDK_CONFIG.skip_title_in_debug)\n if $scene == self\n Yuki::MapLinker.reset\n GamePlay::Load.new(#> Suppression de sauvegarde : X+B+Haut\n Input.press?(:X) &\n Input.press?(:B) &\n Input.press?(:UP)).main\n end\n end",
"def main\n\t\tstart\n\t\twhile self == SceneManager.scene\n\t\t\tGraphics.update\n\t\t\tController.keyboard.update\n\t\t\tupdate\n\t\t\tController.wait_next_frame\n\t\tend\n\t\tterminate\n\tend",
"def setup_and_teardown\n begin\n MenuMethods.setup_screen\n render_greenhouse\n yield\n ensure\n MenuMethods.teardown_screen\n puts \"#{SproutSimulator::Plants::PlantAsciiArt3}\\n\\n\\t\\tGame Over\\n\"\n end\n end_game_condition!\n end",
"def main\n create_graphics\n curr_scene = $scene\n check_up\n while @running && curr_scene == $scene\n Graphics.update\n update\n end\n dispose\n # Unload title related pictures\n RPG::Cache.load_title(true)\n RPG::Cache.load_interface(true)\n ::Scheduler.start(:on_scene_switch, ::Scene_Title) if !@running && $scene.is_a?(Scene_Map)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the chat property value. The chat between the user and Teams app. | def chat
return @chat
end | [
"def chat_info\n return @chat_info\n end",
"def chat_info\n return @chat_info\n end",
"def chat\n @_chat || payload && payload['chat']\n end",
"def chat=(value)\n @chat = value\n end",
"def chat\n @_chat ||=\n if payload\n if payload.is_a?(Hash)\n payload['chat'] || payload['message'] && payload['message']['chat']\n else\n payload.try(:chat) || payload.try(:message).try!(:chat)\n end\n end\n end",
"def chat_id\n return @chat_id\n end",
"def chat_type\n return @chat_type\n end",
"def meeting_chat_id\n return @meeting_chat_id\n end",
"def chat_display_name\n return @chat_display_name\n end",
"def chat_info=(value)\n @chat_info = value\n end",
"def chat_info=(value)\n @chat_info = value\n end",
"def chat_id=(value)\n @chat_id = value\n end",
"def enable_chat\n @meeting['enableOptions']['chat']\n end",
"def meeting_chat_id=(value)\n @meeting_chat_id = value\n end",
"def meeting_chat_enabled\n return @meeting_chat_enabled\n end",
"def chat_type=(value)\n @chat_type = value\n end",
"def conversation_member_user\n return @conversation_member_user\n end",
"def set_chat(chat)\n @msg.chat = chat if @msg\n end",
"def conversation_id\n return @conversation_id\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the chat property value. The chat between the user and Teams app. | def chat=(value)
@chat = value
end | [
"def set_chat(chat)\n @msg.chat = chat if @msg\n end",
"def chat_info=(value)\n @chat_info = value\n end",
"def chat_info=(value)\n @chat_info = value\n end",
"def chat_id=(value)\n @chat_id = value\n end",
"def chat_type=(value)\n @chat_type = value\n end",
"def allow_meeting_chat=(value)\n @allow_meeting_chat = value\n end",
"def meeting_chat_enabled=(value)\n @meeting_chat_enabled = value\n end",
"def meeting_chat_id=(value)\n @meeting_chat_id = value\n end",
"def has_chatter=(value)\n @has_chatter = value\n end",
"def chat\n @_chat || payload && payload['chat']\n end",
"def enable_chat\n @meeting['enableOptions']['chat']\n end",
"def cmd_shellegram_set_chat_id(*args)\r\n\t\t\t\tif args.length > 0\r\n\t\t\t\t\tprint_status(\"Setting the chat_id Telegram to #{args[0]}\")\r\n\t\t\t\t\t@chat_id = args[0]\r\n\t\t\t\telse\r\n\t\t\t\t\tprint_error(\"Please provide a value\")\r\n\t\t\t\tend\r\n\t\t\tend",
"def chat\n @_chat ||=\n if payload\n if payload.is_a?(Hash)\n payload['chat'] || payload['message'] && payload['message']['chat']\n else\n payload.try(:chat) || payload.try(:message).try!(:chat)\n end\n end\n end",
"def chats=(value)\n @chats = value\n end",
"def sent_to_me=(value)\n @sent_to_me = value\n end",
"def hipchat=(arg)\n raise ArgumentError, \"hipchat expected a string, not a #{arg.class}\" unless arg.is_a?(String)\n @hipchat = arg\n end",
"def chat_display_name=(value)\n @chat_display_name = value\n end",
"def set_modchat(level)\n send \"/modchat #{level}\"\n end",
"def chat\n return @chat\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instantiates a new userScopeTeamsAppInstallation and sets the default values. | def initialize()
super
@odata_type = "#microsoft.graph.userScopeTeamsAppInstallation"
end | [
"def initialize()\n super\n @odata_type = \"#microsoft.graph.teamworkApplicationIdentity\"\n end",
"def installed_apps()\n return MicrosoftGraph::Me::JoinedTeams::Item::InstalledApps::InstalledAppsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.teamworkUserIdentity\"\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.educationTeamsAppResource\"\n end",
"def create_application_token!(user)\n ApplicationToken.create_token(\n current_user: current_user,\n user_id: user.id,\n params: { application: \"default\" }\n )\n end",
"def setup_lti_users\n setup_application_instance\n @student = FactoryBot.create(:user)\n @student.confirm\n @student_token = AuthToken.issue_token(\n {\n application_instance_id: @application_instance.id,\n user_id: @student.id,\n context_id: @lms_course_id,\n lti_roles: [\"urn:lti:role:ims/lis/Learner\"],\n lms_course_id: @lms_course_id,\n },\n )\n\n @instructor = FactoryBot.create(:user)\n @instructor.confirm\n @instructor_token = AuthToken.issue_token(\n {\n application_instance_id: @application_instance.id,\n user_id: @instructor.id,\n context_id: @lms_course_id,\n lti_roles: [\"urn:lti:role:ims/lis/Instructor\"],\n lms_course_id: @lms_course_id,\n },\n )\n\n @admin = FactoryBot.create(:user)\n @admin.confirm\n @admin.add_to_role(\"administrator\")\n @admin_token = AuthToken.issue_token(\n {\n application_instance_id: @application_instance.id,\n user_id: @admin.id,\n context_id: @lms_course_id,\n lti_roles: [\"urn:lti:role:ims/lis/Administrator\"],\n lms_course_id: @lms_course_id,\n },\n )\nend",
"def teams_app=(value)\n @teams_app = value\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsAppXAppAssignmentSettings\"\n end",
"def initialize(username, token, organization, flows)\n @username, @token, @organization, @flows = username, token, organization, flows\n puts \"##\"\n puts \"## Starting #{@username} @ #{@organization}\"\n puts \"##\"\n end",
"def create_app_installation_access_token(installation, options = T.unsafe(nil)); end",
"def teams_app_definition=(value)\n @teams_app_definition = value\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.teamworkConversationIdentity\"\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.iosVppAppAssignmentSettings\"\n end",
"def user_set_to_default_app_type\n return if @current_user.app_type_valid?\n\n current_user.app_type_id = all_user_app_type_ids.first\n current_user.save\n end",
"def teams_app_settings=(value)\n @teams_app_settings = value\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.skypeUserConversationMember\"\n end",
"def create(body = {})\n @client.team_app.create(body)\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windows10TeamGeneralConfiguration\"\n end",
"def setup_user_applications\n @user = User.find_by(email: 'state1_epi@example.com')\n # Make sure API access is enabled for this user.\n @user.update!(api_enabled: true)\n\n # Create OAuth applications\n @user_patient_read_write_app = OauthApplication.create(\n name: 'user-test-patient-rw',\n redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n scopes: 'user/Patient.*'\n )\n\n # Create OAuth applications\n @user_everything_app = OauthApplication.create(\n name: 'user-test-patient-rw',\n redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n scopes: 'user/Patient.* user/QuestionnaireResponse.read user/Observation.read user/RelatedPerson.* user/Immunization.*'\n )\n\n # Create access tokens\n @user_patient_token_rw = Doorkeeper::AccessToken.create(\n resource_owner_id: @user.id,\n application_id: @user_patient_read_write_app.id,\n scopes: 'user/Patient.*'\n )\n\n # Create access tokens\n @user_everything_token = Doorkeeper::AccessToken.create(\n resource_owner_id: @user.id,\n application_id: @user_everything_app.id,\n scopes: 'user/Patient.* user/QuestionnaireResponse.read user/Observation.read user/RelatedPerson.* user/Immunization.*'\n )\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GPS version Returns an array of projects that are similar if project exists | def project_exists
if self.check_project_exists == true
return (Project.select{ |proj| proj.project_type == self.project_type } && Project.select{ |proj| proj.street1.to_f.between?((self.street1.to_f - 0.02), (self.street1.to_f + 0.02))} && Project.select{ |proj| proj.street2.to_f.between?((self.street2.to_f - 0.02), (self.street2.to_f + 0.02 ))})
else
return []
end
end | [
"def nearby_projects(projects,latitude,longitude)\n @projects_seventy_five = @matched_projects\n # to remove duplicates from array\n @projects_fifty = @projects_seventy_five - @projects_fifty\n @seventy_five = false\n @hundred = false\n matched_projects = projects.near([latitude, longitude], 50, units: :km) # within 50 kilometres of user address\n if matched_projects.size > 0\n @matched_projects = matched_projects\n # to remove duplicates from array\n @projects_seventy_five = (@matched_projects - @projects_seventy_five)\n @hundred = true # 100% match\n else\n @seventy_five = true # 75% match\n end\n end",
"def known_omnibus_projects\n # iterate through min/max versions for all product names\n # and collect the name for both versions\n projects = %w{ 0.0.0 1000.1000.1000 }.collect do |v|\n @version = v\n omnibus_project\n end\n # remove duplicates and return multiple known names or return the single\n # project name\n projects.uniq || projects\n end",
"def check_project_exists\n\n # if latitude is within +/- 2 ten-thounsandths of another project's latitude it is the same\n (Project.select{ |proj| proj.project_type == self.project_type }.count > 0 && Project.select{ |proj| proj.street1.to_f.between?((self.street1.to_f - 0.002), (self.street1.to_f + 0.002))}.count > 0 && Project.select{ |proj| proj.street2.to_f.between?((self.street2.to_f - 0.02), (self.street2.to_f + 0.02))}.count > 0)\n end",
"def get_matching_files(proj)\n dupes_found = {}\n archive_sigs_to_check = []\n file_sigs_to_check = []\n files_this_project = []\n proj.project_archives.each{|pa|\n archive_sigs_to_check.push pa.signature\n pa.project_files.each{|pf|\n file_sigs_to_check.push pf.signature\n files_this_project.push pf # while we're at it -- will need later\n }\n }\n # uniquify and remove nil sigs\n archive_sigs_to_check = archive_sigs_to_check.uniq.reject{|la| la.nil?}\n file_sigs_to_check = file_sigs_to_check.uniq.reject{|la| la.nil?}\n \n # Check signatures\n archive_match = ProjectArchive.find_all_by_signature(archive_sigs_to_check)\n file_match = ProjectFile.find_all_by_signature(file_sigs_to_check)\n\n\n # Then, construct the hash. Go through the PA and PF again and match\n # Them up to sigs\n archive_match.each{|am|\n # Make the mini-array - separate out the Project\n archive_value = [am.project_id, am]\n # Find all archives in this project that match by signature\n proj.project_archives.find_all_by_signature(am.signature).each{|pa|\n # if am and pa are the same, skip it ; otherwise add even if\n # they're in the same project\n next if am.id == pa.id\n dupes_found[pa] = [] unless dupes_found[pa]\n dupes_found[pa].push archive_value\n }\n }\n \n file_match.each{|fm|\n # Make the mini-array - separate out the Project\n fmpa = fm.project_archive\n fmpap = fmpa.project unless fmpa.nil?\n fmpapid = fmpap.id unless fmpap.nil?\n next if fmpapid.nil? # If it doesn't have a project, just skip it\n file_value = [fmpapid, fm]\n # Find all files in this project that match by signature\n files_this_project.each{|ftp|\n if ftp.signature == fm.signature then\n # skip it if they're the same file\n next if ftp.id == fm.id\n dupes_found[ftp] = [] unless dupes_found[ftp]\n dupes_found[ftp].push file_value\n end\n }\n }\n dupes_found\n end",
"def project_versions(project)\n project_issues(project).collect(&:fixed_version).compact.uniq\n end",
"def existing_projects\n Project.project_hashes\n end",
"def remove_dups(projects)\n\t\t projects.uniq #=> projects\n\t\t return projects.uniq\n\tend",
"def check_by_project\n _r = false\n # global_project_breakdown returns multidimensional array containing different project in each line\n # Each line contains 5 elements: Project Id, max_order_total, max_order_price, Net amount sum by project & Item net price\n a = global_project_breakdown(purchase_order_items.order(:project_id))\n d = a.detect { |f| (f[1] > 0 && (f[3] > f[1])) || (f[2] > 0 && (f[4] > f[2])) }\n _r = d.nil? ? false : true\n end",
"def projects_need_update(projects)\n return if projects.nil? || Thread.current[:gitosis_project_updates].nil?\n Thread.current[:gitosis_project_updates] << projects\n Thread.current[:gitosis_project_updates].flatten!\n Thread.current[:gitosis_project_updates].uniq!\n Thread.current[:gitosis_project_updates].compact!\n end",
"def project_versions(project,issues)\n issues.collect(&:fixed_version).compact.uniq\n end",
"def search_for_projects(query_array)\n siteproperties = Guiproperties.new\n\t ret_arr = Array.new\n\t\tquery_array.each do |q|\n\t\t\tq = \"%\"+q.to_s+\"%\"\n if siteproperties.isMySQL()\n\t\t\t tmp_proj = Project.find(:all, :conditions=>[\"(UPPER(title) LIKE ? OR UPPER(description) LIKE ?) AND is_public = ?\", q.upcase, q.upcase, 1])\n else\n\t\t\t tmp_proj = Project.find(:all, :conditions=>[\"(UPPER(title) LIKE ? OR UPPER(description) LIKE ?) AND is_public = ?\", q.upcase, q.upcase, 't'])\n end\n\t\t\tfor proj in tmp_proj\n\t\t\t\tret_arr << proj\n\t\t\tend\n\t\tend\n\t\tret_arr = remove_dups(ret_arr)\n\t\treturn ret_arr\n\tend",
"def pledged_projects\n pledges.map { |pledge| pledge.project }.uniq\n end",
"def ring_projects\n @ring_projects ||= strategy.rings.each_with_index.map do |r,idx|\n ObsProject.new(\"#{rings_project_name}:#{idx}-#{r}\", \"#{idx}-#{r}\")\n end\n end",
"def get_available_project_names(file_array)\n name_results = Array.new\n for project_file in file_array\n if project_file.end_with? \".pbxproj\"\n file = File.open(project_file, \"rb\")\n file_contents = file.read\n results = file_contents.scan(/productName = ([^;]*);|PRODUCT_NAME = ([^;]*);/)\n name_results.concat(results)\n end\n end\n \n clean_name_results = name_results.flatten(1).uniq\n clean_name_results -= %w{\"$(TARGET_NAME)\"} #Remove irrelevant items\n \n if clean_name_results.length > 1 #If there are multiple results remove 'tests' if it wont leave 0 items\n \ttest_count = 0\n\t\n\tfor matched_project_name in file_array\n\t if matched_project_name.end_with? \"Tests\"\n test_count += 1\n\t end\n\tend\n\t\n\tif test_count < clean_name_results.length\n clean_name_results.delete_if {|i| i.to_s == ''}\n \t clean_name_results.delete_if {|i| i.end_with? \"Tests\"}\n \tend\n end\n \n return clean_name_results\nend",
"def build_projects_in_efforts\n @projects_in_efforts = @item_assignments_efforts.map { |assignment| assignment.demand.project }.uniq\n end",
"def project_plt(begda,endda)\n \n project_list = []\n wip = 0\n\n #Find the projects\n projects = Project::find(:all, :conditions => [\"planend >= ? and planend <= ? and status = ?\", begda, endda, Project::StatusClosed])\n projects.each do |project|\n if !project.worktype.is_continuous\n plt = (project.updated_at.to_date - project.planbeg + 1).to_f\n projectdata = { :project_id => project.id,\n :name => project.name,\n :country_id => project.country_id,\n :planeffort => project.planeffort,\n :plt => plt,\n :worktype_id => project.worktype }\n project_list << projectdata\n end\n end\n\n return project_list\n end",
"def projects\n wayfinder.decorated_ephemera_projects\n end",
"def projects_by_path\n strong_memoize(:projects_by_path) do\n Project.eager_load(:route, namespace: [:route])\n .where_full_path_in(unique_project_paths)\n .index_by(&:full_path)\n end\n end",
"def projects_tracked\n timings = Timing.for_period_of_time(self.id, 1.month.ago, Time.now)\n if timings.present?\n timings.map(&:project_id).uniq\n else\n []\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GPS version check for projects that have similar streets reversing street order as necessary. | def check_project_exists
# if latitude is within +/- 2 ten-thounsandths of another project's latitude it is the same
(Project.select{ |proj| proj.project_type == self.project_type }.count > 0 && Project.select{ |proj| proj.street1.to_f.between?((self.street1.to_f - 0.002), (self.street1.to_f + 0.002))}.count > 0 && Project.select{ |proj| proj.street2.to_f.between?((self.street2.to_f - 0.02), (self.street2.to_f + 0.02))}.count > 0)
end | [
"def street_similar(form_street_address,va_street_address)\n return false if va_street_address.nil?\n return va_street_address.jarowinkler_similar(form_street_address) > 0.8 ? true : false\n end",
"def nearby_projects(projects,latitude,longitude)\n @projects_seventy_five = @matched_projects\n # to remove duplicates from array\n @projects_fifty = @projects_seventy_five - @projects_fifty\n @seventy_five = false\n @hundred = false\n matched_projects = projects.near([latitude, longitude], 50, units: :km) # within 50 kilometres of user address\n if matched_projects.size > 0\n @matched_projects = matched_projects\n # to remove duplicates from array\n @projects_seventy_five = (@matched_projects - @projects_seventy_five)\n @hundred = true # 100% match\n else\n @seventy_five = true # 75% match\n end\n end",
"def get_street new_location\n\t\tfourth = [\"Hospital\", \"Cathedral\", \"Monroeville\"]\n\t\tfifth = [\"Downtown\", \"Hillman\", \"Museum\"]\n\t\tboth = [new_location, @driver.current_location]\n\t\t\n\t\treturn nil if both[0] == both[1]\n\t\treturn \"Fourth Ave.\" if fourth.include?(both[0]) && fourth.include?(both[1])\n\t\treturn \"Fifth Ave.\" if fifth.include?(both[0]) && fifth.include?(both[1])\n\t\treturn \"Foo St.\" if both.include?(\"Hospital\") && both.include?(\"Hillman\")\n\t\treturn \"Bar St.\" if both.include?(\"Cathedral\") && both.include?(\"Museum\")\n\t\t\n\t\tnil #this should never be returned unless something went wrong\n\tend",
"def get_street(new_loc)\n curr_loc = @driver.location nil\n\n return 'Fourth Ave.' if (@val.fourth_check new_loc, curr_loc).is_a? String\n return 'Fifth Ave.' unless (@val.fifth_check new_loc, curr_loc).zero?\n return 'Foo St.' unless (@val.foo_check new_loc, curr_loc) == 'no'\n @val.bar_check new_loc, curr_loc\n end",
"def project_exists\n\n if self.check_project_exists == true\n return (Project.select{ |proj| proj.project_type == self.project_type } && Project.select{ |proj| proj.street1.to_f.between?((self.street1.to_f - 0.02), (self.street1.to_f + 0.02))} && Project.select{ |proj| proj.street2.to_f.between?((self.street2.to_f - 0.02), (self.street2.to_f + 0.02 ))})\n else\n return []\n end\n end",
"def test_RefLib_003_Streets\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_RefLib_003_Streets\")\n puts2(\"#######################\")\n \n puts2(\"\")\n puts2(\"USPS Street Suffix\")\n USPS_STREET_SUFFIX.sort.each do | name, abbrev |\n puts2(\" Abbreviation of #{name}, is #{abbrev}\")\n end\n \n puts2(\"\")\n puts2(\"USPS Secondary Unit Designators\")\n USPS_SECONDARY_UNIT_DESIGNATOR.sort.each do | name, abbrev |\n puts2(\" #{name}, is abbreviated #{abbrev}\")\n end\n \n end",
"def assigned_version_roadways\n version = assigned_version\n\n if version # you need to ensure that there is even an inspection that was moved through assigned\n typed_version = TransamAsset.get_typed_version(version)\n\n if version.respond_to? :reify # if the highway structure returns a version you can use its version to find the versions associated with roadways\n return typed_version.roadways\n else # otherwise you have a highway structure that is \"live\" ie what is the DB right now and you have to figure out what versions of roadways are associated\n # given the time of assignment\n # you know that if a roadway wasnt updated since the time of assignment that those roadways were like that at assignment. they can be included in roadways of the assigned version\n time_of_assignment = assigned_inspection_version.created_at\n results = typed_version.roadways.where('updated_at <= ?', time_of_assignment).to_a\n\n # therefore you only need to check roadways updated after time of assignment\n # for those roadways, you find the version that is closest and before the time of assignment\n # versions save the object BEFORE the change\n # therefore to get the version at time of assignment you need the first version that happened after the time of assignment\n typed_version.roadways.where('updated_at > ?', time_of_assignment).each do |roadway|\n ver = roadway.versions.where('created_at > ?', time_of_assignment).where.not(event: 'create').order(:created_at).first\n results << ver.reify if ver\n end\n return results\n end\n end\n end",
"def street_lookups\n [:google, :google_premier, :yahoo, :bing, :geocoder_ca, :yandex, :nominatim]\n end",
"def supports_multiple_ips?\n Gem::Version.new(location.hv_group_version) >= Gem::Version.new('4.1.0')\n end",
"def assume_parts\n # Check if unit is in street number\n # 1) If street number has - or / unit is the smallest length\n # 2) If street number is all nums except 1 letter, letter is unit\n search_for_unit_in_street_num if @parts[:unit].nil? && @parts[:street_number]\n\n # Search for the street_name elsewhere\n search_for_street_name if @parts[:street_name].nil?\n\n # set puerto rico as the state\n @parts[:state] = @parts[:country] if @parts[:state].nil? && @parts[:country] == 'pr'\n\n return if @parts[:bus].nil? || @parts[:bus].empty?\n\n search_for_label_in_bus if @parts[:street_label].nil?\n search_for_state_in_bus if @parts[:state].nil?\n\n end",
"def test_rbs_have_matching_osm_tests\n # List of tests that don't have a matching OSM test for a valid reason\n # No \"Warn\" will be issued for these\n # input the ruby file name, eg `xxxx.rb` NOT `test_xxx_rb`\n noMatchingOSMTests = ['ExampleModel.rb',\n 'autosize_hvac.rb',\n # Not enabled\n 'afn_single_zone_ac.rb']\n\n base_dir = $ModelDir\n all_ruby_paths = Dir.glob(File.join(base_dir, '*.rb'));\n all_ruby_filenames = all_ruby_paths.map{|p| File.basename(p)};\n\n all_ruby_filenames.each do |filename|\n if !noMatchingOSMTests.include?(filename)\n # Check if there is a matching OSM file\n matching_osm = File.join(base_dir, filename.sub('.rb', '.osm'))\n\n # If you want to be stricter than warn, uncomment this\n # assert File.exists?(matching_osm), \"There is no matching OSM test for #{filename}\"\n\n if File.exists?(matching_osm)\n v = OpenStudio::IdfFile.loadVersionOnly(matching_osm)\n # Seems like something we should definitely fix anyways, so throwing\n if not v\n fail \"Cannot find versionString in #{matching_osm}\"\n end\n\n # If there is a version, check that it's not newer than current bindings\n model_version = v.get.str\n\n if Gem::Version.new(model_version) > Gem::Version.new($SdkVersion)\n # Skip instead of fail\n skip \"Matching OSM Model version is newer than the SDK version used (#{model_version} versus #{$SdkVersion})\"\n end\n else\n # If there isn't a matching, we warn, but we'll still run it\n # It might make sense if you have just added it recently\n warn \"There is no matching OSM test for #{filename}\"\n end\n end\n end\n end",
"def check_final \n\t\t@driver.current_location == \"Monroeville\" || @driver.current_location == \"Downtown\"\n\tend",
"def needs_geocode_lookup?\n changed_state = %w(street_name zip_code city state country).map { |field| send(:\"#{field}_changed?\") }\n changed_state.include?(true)\n end",
"def is_gps_address? address\n\t# Blank spaces are ignored.\n\taddress = address.gsub(' ', '')\n\taddress = address.gsub(' ', '')\n\n\tfloat_pattern = '(-)?[[:digit:]]+(\\.)?+[[:digit:]]+'\n\tgps_pattern = float_pattern + ',' + float_pattern\n\treturn (address.match gps_pattern) != nil\nend",
"def street_areSame?(street)\n if(@street == street)\n true\n else\n false\n end\nend",
"def find_previous_version\n thisVersion = Gem::Version.new($SdkVersion)\n\n # We parse the test/ folder for all osm tests\n out_files = Dir.glob(File.join($OutOSWDir, '*'))\n re_version = Regexp.new('.*\\.osm_(\\d\\.\\d\\.\\d)_out\\.osw')\n version_strings = out_files.select { |f| f.match(re_version) }.map { |f| f.scan(re_version).first.last }.uniq\n # We sort them by the actual version\n versions = version_strings.map { |v| Gem::Version.new(v) }.sort\n\n if versions.include?(thisVersion)\n thisIndex = versions.index(thisVersion)\n if thisIndex > 0\n previousVersion = versions[thisIndex - 1]\n return previousVersion\n else\n puts \"Cannot find a previous version for #{$SdkVersion} as it's the oldest known\"\n return nil\n end\n else\n lastVersion = versions.last\n return lastVersion if thisVersion > lastVersion\n\n puts \"Cannot find a previous version for #{$SdkVersion} as it's older than the oldest known\"\n return nil\n end\nend",
"def used_elsewhere?\n # check the changes table to see if this location is being used \n # for more than one change, so really this should be called\n # used_in_more_than_one_place?\n loc_changes = Change.find(:all, :conditions => {:new_value => self.id, :change_type => [Change::PERSON_LOCATION, Change::PERSON_MAIN_LOCATION]})\n if loc_changes.length >= 2\n retval = true\n else\n retval = false\n end\n retval\n end",
"def resolve version\n op, version = version.strip.split\n version, op = op, '=' unless version\n version_numbers.find do |other|\n case op\n when '=' ; other == version\n when '>' ; other > version\n when '>=' ; other >= version\n when '>~'\n other[0..1] == version[0..1] && other >= version\n end\n end\n end",
"def check_overlap_single(route)\n tracks = []\n\n route.paths.each do |path|\n a = path.a\n b = path.b\n\n tracks << [path.hex, a.num, path.lanes[0][1]] if a.edge?\n tracks << [path.hex, b.num, path.lanes[1][1]] if b.edge?\n\n # check track between edges and towns not in center\n # (essentially, that town needs to act like an edge for this purpose)\n if b.edge? && a.town? && (nedge = a.tile.preferred_city_town_edges[a]) && nedge != b.num\n tracks << [path.hex, a, path.lanes[0][1]]\n end\n if a.edge? && b.town? && (nedge = b.tile.preferred_city_town_edges[b]) && nedge != a.num\n tracks << [path.hex, b, path.lanes[1][1]]\n end\n end\n\n tracks.group_by(&:itself).each do |k, v|\n raise GameError, \"Route cannot reuse track on #{k[0].id}\" if v.size > 1\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Details: Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array. For example: solution([1, 2, 10, 50, 5]) should return [1,2,5,10,50] solution(nil) should return [] | def solution(nums)
nums.to_a.sort
end | [
"def solution(nums)\n nums.nil? ? [] : nums.sort\nend",
"def sort_array(nums)\n nums.nil? ? [] : nums.sort\nend",
"def introspective_sort(array)\n return array if array.empty?\n\n depth_limit = (2 * Math.log10(array.size) / Math.log10(2)).floor\n quick_sort(array, depth_limit)\nend",
"def sorting(numbers)\n numbers.sort\nend",
"def sort_array_asc(integer_array)\n helper_array = integer_array.sort!\n return helper_array\nend",
"def using_sort(array)\n array.sort\nend",
"def recursive_sort_wrap some_array\n recursive_sort some_array, []\nend",
"def smallest_integer(list_of_nums)\n if list_of_nums.empty?\n puts nil\n else\n list_of_nums.sort!\n puts list_of_nums[0]\n end\nend",
"def sort_array_asc(array)\n return array.sort;\nend",
"def optimal_tourney_sort(array)\n sorted_array = []\n pq = PriorityQueue.new\n array.each { |num| pq << num }\n sorted_array << pq.remove_min until pq.size == 1\n sorted_array\nend",
"def sort_array_asc(integers)\n integers.sort\nend",
"def sort_array_asc(int_array)\n \n int_array.sort\n \nend",
"def sort_array_asc(array)\n array.sort\nend",
"def ordenar_arreglo array\n array.sort\nend",
"def merge_sort(array, i= 0)\r\n\ti += 1\r\n\treturn array if array.length == 1\r\n\t\tprint \"array#{i}: #{array}\\n\"\r\n\t\ta = merge_sort(array.slice!(0..array.length/2-1), i)\r\n\t\tprint \"a#{i}: #{a}\\n\"\t\t\r\n\t\tb = merge_sort(array, i)\r\n\t\tprint \"b#{i}: #{b}\\n\"\r\n\t\tsorted = []\r\n\tuntil a.first.nil? || b.first.nil?\r\n\t\tprint \"sorting: a#{i}: #{a}, b#{i}: #{b}\\n\"\r\n\t\tsorted << (a.first < b.first ? a.slice!(0) : b.slice!(0))\r\n\t\tprint \"sorted step: #{sorted}\\n\"\r\n\tend\r\n\tuntil a.first.nil?\r\n\t\tsorted << a.slice!(0)\r\n\tend\r\n\tuntil b.first.nil?\r\n\t\tsorted << b.slice!(0)\r\n\tend\r\n\tprint \"sorted: #{sorted}, i: #{i}\\n\"\r\n\tsorted\r\nend",
"def sort_array_desc(integers)\n integers.sort.reverse\nend",
"def flatten_and_sort(array)\n array.flatten.sort\nend",
"def flatten_and_sort(array)\n array.flatten.sort\nend",
"def tournament_sort(array)\n return optimal_tourney_sort(array) if array.size <= MAX_SIZE\n\n bracketize(array)\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /regionextras GET /regionextras.json | def index
@regionextras = Regionextra.all
end | [
"def region\n @regions = @company.companyregions\n respond_with @regions\n end",
"def regions\n client.get_stats('/stats/regions')\n end",
"def regions\n @carrierRegions = []\n if session[:carrier]\n soap_client = MyFreightWorldCarrier.new\n @carrierRegions = soap_client.getRegions(session[:carrier][\"token\"])\n end\n\n render :json => @carrierRegions\n end",
"def geographic_regions\n self.dig_for_array(\"geographicRegions\")\n end",
"def geographic_regions\n self.dig_for_array(\"listingSummary\", \"geographicRegions\")\n end",
"def cities_in_region\n render json: City.where(region_id: controller_params).order(:name)\n end",
"def index\n\n @regions = Region.all\n\n render json: @regions\n\n end",
"def index\n @regiones = Region.all\n\n render json: @regiones\n end",
"def all\n subregions = Subregions.all( params[:urn] )\n render :json => { :subregions => subregions }\n end",
"def index\n @especies_regiones = EspecieRegion.all\n end",
"def query_tax_region_jurisdictions(options={})\n path = \"/api/v2/compliance/taxregionjurisdictions\"\n get(path, options)\n end",
"def get_shipping_regions\n shipping_regions = ShippingRegion.all\n json_response(shipping_regions)\n end",
"def show\n @uip_region = UipRegion.find(params[:id])\n\n render json: @uip_region\n end",
"def show\n @subregion = Subregion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subregion }\n end\n end",
"def get_aws_region\n\n\n begin\n\n url = 'http://169.254.169.254/latest/dynamic/instance-identity/document'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n\n hashOfLookupValues = JSON.parse(response)\n lookupRegion = hashOfLookupValues[\"region\"]\n\n rescue\n logonFailed('Unable to perform region lookup. Is this an EC2 instance? and does it have access to http://169.254.169.254')\n end\n\n return lookupRegion\n\n end",
"def search_regions(region)\n options = {\n :q => region,\n }\n\n regions = []\n\n puts \"Search with options \" + options.inspect\n\n response = connection.get(\"region\", options )\n puts \"responce is \" + response.inspect\n\n if response.status == 200\n regions.push response.body[\"region.regions\"][0]['region'][0]\n end\n\n regions\n end",
"def get_md_regions\n response = @client.get_md_regions! do |soap|\n soap.input = soap.action = \"GetMDRegions\"\n soap.namespace = @namespace\n end\n\n h = response.to_hash[:get_md_regions_response][:region_list] #this can throw\n\n [h[:region]].compact.flatten rescue Array.new #this should not throw\n end",
"def get_region\n logger.debug(\"fetching region from meta-data service\")\n az = HTTP.get(\n [\n self.class.const_get(:INSTANCE_PROFILE_HOST),\n self.class.const_get(:INSTANCE_PROFILE_AZ_PATH),\n ].join(\"/\")\n ).body.to_s.strip\n az.sub!(/[a-zA-Z]+$/, \"\")\n logger.debug(\"region from meta-data service: #{az}\")\n az\n end",
"def query_tax_regions(options={})\n path = \"/api/v2/compliance/taxregions\"\n get(path, options)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /regionextras POST /regionextras.json | def create
@regionextra = Regionextra.new(regionextra_params)
respond_to do |format|
if @regionextra.save
format.html { redirect_to @regionextra, notice: 'Regionextra was successfully created.' }
format.json { render :show, status: :created, location: @regionextra }
else
format.html { render :new }
format.json { render json: @regionextra.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @region = Region.new(region_params)\n\n if @region.save\n render json: @region, status: :created, location: @region\n else\n render json: @region.errors, status: :unprocessable_entity\n end\n end",
"def createregion\n region_name = params[\"regionName\"]\n region_active = params[\"active\"] == \"true\"\n @carrierRegions = []\n if session[:carrier]\n soap_client = MyFreightWorldCarrier.new\n @carrierRegions = soap_client.createRegion(session[:carrier][\"token\"], region_name, region_active)\n end\n\n render :json => @carrierRegions\n end",
"def update\n respond_to do |format|\n if @regionextra.update(regionextra_params)\n format.html { redirect_to @regionextra, notice: 'Regionextra was successfully updated.' }\n format.json { render :show, status: :ok, location: @regionextra }\n else\n format.html { render :edit }\n format.json { render json: @regionextra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @regionextras = Regionextra.all\n end",
"def create\n @region = Region.new(region_params)\n\n if @region.save\n render :show, status: :created, location: @region\n else\n render json: @region.errors, status: :unprocessable_entity\n end\n end",
"def insertregionzip\n region_id = params[\"regionId\"]\n country_id = 1\n zip_code = params[\"zipCode\"]\n excluded = params[\"excluded\"]\n @carrierRegion = nil\n if session[:carrier]\n soap_client = MyFreightWorldCarrier.new\n @carrierRegion = soap_client.insertRegionZip(session[:carrier][\"token\"], region_id, country_id, zip_code, excluded)\n end\n\n render :json => @carrierRegion\n end",
"def region_params\n params.require(:region).permit!\n end",
"def insertregionstate\n region_id = params[\"regionId\"]\n country_id = 1\n state = params[\"state\"]\n excluded = params[\"excluded\"]\n @carrierRegion = nil\n if session[:carrier]\n soap_client = MyFreightWorldCarrier.new\n @carrierRegion = soap_client.insertRegionState(session[:carrier][\"token\"], region_id, country_id, state, excluded)\n end\n\n render :json => @carrierRegion\n end",
"def create\n @uip_region = UipRegion.new(params[:uip_region])\n\n if @uip_region.save\n render json: @uip_region, status: :created, location: @uip_region\n else\n render json: @uip_region.errors, status: :unprocessable_entity\n end\n end",
"def insertregionziprange\n region_id = params[\"regionId\"]\n country_id = 1\n starting_zip_code = params[\"startingZipCode\"]\n ending_zip_code = params[\"endingZipCode\"]\n excluded = params[\"excluded\"]\n @carrierRegion = nil\n if session[:carrier]\n soap_client = MyFreightWorldCarrier.new\n @carrierRegion = soap_client.insertRegionZipRange(session[:carrier][\"token\"], region_id, country_id, starting_zip_code, ending_zip_code, excluded)\n end\n\n render :json => @carrierRegion\n end",
"def region\n @regions = @company.companyregions\n respond_with @regions\n end",
"def create\n @admin_region = Admin::Region.new(admin_region_params)\n\n respond_to do |format|\n if @admin_region.save\n format.html { redirect_to @admin_region, notice: 'Region was successfully created.' }\n format.json { render :show, status: :created, location: @admin_region }\n else\n format.html { render :new }\n format.json { render json: @admin_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @region = Region.new(region_param)\n\n respond_to do |format|\n if @region.save\n format.html { redirect_to @region, notice: 'Region was successfully created.' }\n format.json { render json: @region, status: :created, location: @region }\n else\n format.html { render action: \"new\" }\n format.json { render json: @region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(attributes = {})\n # Add the region\n @regions << Region.new(attributes)\n \n @regions.last\n end",
"def create\n @map_region = Map::Region.new(params[:map_region])\n\n respond_to do |format|\n if @map_region.save\n format.html { redirect_to @map_region, notice: 'Region was successfully created.' }\n format.json { render json: @map_region, status: :created, location: @map_region }\n else\n format.html { render action: \"new\" }\n format.json { render json: @map_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subregion = Subregion.new(params[:subregion])\n\n respond_to do |format|\n if @subregion.save\n format.html { redirect_to @subregion, notice: 'Registro creado satisfactoriamente.' }\n format.json { render json: @subregion, status: :created, location: @subregion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subregion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @newregion = Newregion.new(newregion_params)\n\n respond_to do |format|\n if @newregion.save\n format.html { redirect_to @newregion, notice: 'Newregion was successfully created.' }\n format.json { render :show, status: :created, location: @newregion }\n else\n format.html { render :new }\n format.json { render json: @newregion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @regionextra.destroy\n respond_to do |format|\n format.html { redirect_to regionextras_url, notice: 'Regionextra was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @regionenvironment = Regionenvironment.new(regionenvironment_params)\n\n respond_to do |format|\n if @regionenvironment.save\n format.html { redirect_to @regionenvironment, notice: 'Regionenvironment was successfully created.' }\n format.json { render :show, status: :created, location: @regionenvironment }\n else\n format.html { render :new }\n format.json { render json: @regionenvironment.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /regionextras/1 PATCH/PUT /regionextras/1.json | def update
respond_to do |format|
if @regionextra.update(regionextra_params)
format.html { redirect_to @regionextra, notice: 'Regionextra was successfully updated.' }
format.json { render :show, status: :ok, location: @regionextra }
else
format.html { render :edit }
format.json { render json: @regionextra.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @region = Region.find(params[:id])\n\n if @region.update(region_params)\n head :no_content\n else\n render json: @region.errors, status: :unprocessable_entity\n end\n end",
"def update\n do_load_resource\n get_project_if_exists\n do_authorize_instance\n\n @original_region_name = @region.name\n\n if @region.update(region_params)\n respond_show\n else\n respond_change_fail\n end\n end",
"def update\n respond_to do |format|\n if @especie_region.update(especie_region_params)\n format.html { redirect_to @especie_region, notice: 'Especie region was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @especie_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @map_region = Map::Region.find(params[:id])\n\n respond_to do |format|\n if @map_region.update_attributes(params[:map_region])\n format.html { redirect_to @map_region, notice: 'Region was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @map_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @region.update(region_params)\n @regions = Region.all\n format.js { render :file=> 'regions/update_regions.js.erb', notice: 'Region was successfully updated.' }\n format.json { render :show, status: :ok, location: @region }\n else\n format.html { render :edit }\n format.json { render json: @region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @regionenvironment.update(regionenvironment_params)\n format.html { redirect_to @regionenvironment, notice: 'Regionenvironment was successfully updated.' }\n format.json { render :show, status: :ok, location: @regionenvironment }\n else\n format.html { render :edit }\n format.json { render json: @regionenvironment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_region.update(tipo_region_params)\n format.html { redirect_to @tipo_region, notice: 'Tipo region was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipo_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subregion = Subregion.find(params[:id])\n\n respond_to do |format|\n if @subregion.update_attributes(params[:subregion])\n format.html { redirect_to @subregion, notice: 'Registro editado satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subregion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_region.update(admin_region_params)\n format.html { redirect_to @admin_region, notice: 'Region was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_region }\n else\n format.html { render :edit }\n format.json { render json: @admin_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @region.update_attributes(params[:region])\n flash[:notice] = 'Region was successfully updated.'\n format.html { redirect_to([:admin, @region]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @region.errors, \n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @newregion.update(newregion_params)\n format.html { redirect_to @newregion, notice: 'Newregion was successfully updated.' }\n format.json { render :show, status: :ok, location: @newregion }\n else\n format.html { render :edit }\n format.json { render json: @newregion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_region_of_service(*args)\n raise ArgumentError.new('The method `update_region_of_service` requires 2 arguments (service-id and region-code).') if args.size != 2\n self.class.put(\"/services/#{args[0]}/regions/#{args[-1]}.json?apikey=#{apikey}\", :body => {})\n end",
"def update\n @uip_region = UipRegion.find(params[:id])\n\n if @uip_region.update(params[:uip_region])\n head :no_content\n else\n render json: @uip_region.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @conservedregion.update(conservedregion_params)\n format.html { redirect_to @conservedregion, notice: 'Conservedregion was successfully updated.' }\n format.json { render :show, status: :ok, location: @conservedregion }\n else\n format.html { render :edit }\n format.json { render json: @conservedregion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @renew_region.update(renew_region_params)\n format.html { redirect_to @renew_region, notice: 'Renew region was successfully updated.' }\n format.json { render :show, status: :ok, location: @renew_region }\n else\n format.html { render :edit }\n format.json { render json: @renew_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_data\n region = Region.find(params[:id])\n data = MultiJson.load(@region.json_data || \"{}\")\n\n # TODO: merge incoming data\n\n region.json_data = MultiJson.dump(data, :pretty => true)\n\n redirect_to :action => :show, :id => id\n end",
"def update\n respond_to do |format|\n if @world_region.update(world_region_params)\n format.html { redirect_to @world_region, notice: 'World region was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_region }\n else\n format.html { render :edit }\n format.json { render json: @world_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @regional_request.modified_by = current_user.id\n respond_to do |format|\n if @regional_request.update(regional_request_params)\n format.html { redirect_to @regional_request, notice: 'Regional request was successfully updated.' }\n format.json { render :show, status: :ok, location: @regional_request }\n else\n format.html { render :edit }\n format.json { render json: @regional_request.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /regionextras/1 DELETE /regionextras/1.json | def destroy
@regionextra.destroy
respond_to do |format|
format.html { redirect_to regionextras_url, notice: 'Regionextra was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @region.destroy\n\n respond_to do |format|\n format.html { redirect_to regions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @region.destroy\n\n head :no_content\n end",
"def destroy\n @region.destroy\n respond_to do |format|\n format.html { redirect_to regions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @region = Region.find(params[:id])\n @region.destroy\n\n respond_to do |format|\n format.html { redirect_to regions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_region.destroy\n respond_to do |format|\n format.html { redirect_to admin_regions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @region.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_regions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @regione = Regione.find(params[:id])\n @regione.destroy\n\n respond_to do |format|\n format.html { redirect_to regioni_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @especie_region.destroy\n respond_to do |format|\n format.html { redirect_to especies_regiones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @map_region = Map::Region.find(params[:id])\n @map_region.destroy\n\n respond_to do |format|\n format.html { redirect_to map_regions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @conservedregion.destroy\n respond_to do |format|\n format.html { redirect_to conservedregions_url, notice: 'Conservedregion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @us_region.destroy\n respond_to do |format|\n format.html { redirect_to(admin_us_reps_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted US Region #{@us_region.name}\")\n end",
"def destroy\n @admin_region.destroy\n respond_to do |format|\n format.html { redirect_to admin_regiones_url, notice: 'Region was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub_region = SubRegion.find(params[:id])\n @sub_region.destroy\n\n respond_to do |format|\n format.html { redirect_to(sub_regions_url) }\n format.xml { head :ok }\n end\n end",
"def deleteregion\n region_id = params[\"regionId\"]\n @carrierRegions = []\n if session[:carrier]\n soap_client = MyFreightWorldCarrier.new\n @carrierRegions = soap_client.deleteRegion(session[:carrier][\"token\"], region_id)\n end\n\n render :json => @carrierRegions\n end",
"def destroy\n @uip_region = UipRegion.find(params[:id])\n @uip_region.destroy\n\n head :no_content\n end",
"def destroy\n @subregion = Subregion.find(params[:id])\n @subregion.destroy\n\n respond_to do |format|\n format.html { redirect_to subregions_url, notice: 'Registro eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @regional = Regional.find(params[:id])\n @regional.destroy\n\n respond_to do |format|\n format.html { redirect_to regionals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @target_region = TargetRegion.find(params[:id])\n @target_region.destroy\n\n respond_to do |format|\n format.html { redirect_to(target_regions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @renew_region.destroy\n respond_to do |format|\n format.html { redirect_to renew_regions_url, notice: 'Renew region was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin need function that takes and argument that argument will be an array reference value to check against if the next number is bigger than reference value it becomes the reference value at the end of iterating over each item the reference value the largest number =end | def max_value(our_array)
reference = -100000
our_array.each do |number|
if number > reference
reference = number
end
end
reference
end | [
"def max_number(our_array)\n\treference = -1000000\n\tour_array.each do |number|\n\t\tif number > reference\n\t\t\treference = number\n\t\tend\n\tend\n\treference\nend",
"def largest(array)\n index = 0 #1\n greatest_num = array[index] #5 \n while index < array.length #0 < 5 1 < 5\n if array[index] > greatest_num #if 5 > 5 17 > 5\n greatest_num = array[index] # 17 \n end\n index += 1\n end\n greatest_num\nend",
"def find_greatest(numbers)\n saved_number = nil\n\n numbers.each do |num|\n saved_number ||= num\n if saved_number >= num\n next\n else\n saved_number = num\n end\n end\n \n saved_number\nend",
"def max_in_array()\n my_array = [10,140,4,3,120, -7, 300]\n largest_num = nil\n num_idx = 0\n while num_idx < my_array.length\n current_num = my_array[num_idx]\n if largest_num == nil\n largest_num = current_num\n elsif largest_num < current_num\n largest_num = current_num\n end\n num_idx += 1\n end\n return largest_num\nend",
"def find_greatest(numbers)\n saved_number = nil\n\n numbers.each do |num|\n saved_number ||= num # assign to first value\n if saved_number >= num\n next\n else\n saved_number = num\n end\n end\n\n saved_number\nend",
"def find_max_value(array) # method 2 using block and if\n x = array[0]\n array.length.times { |index| if array[index] > x\n x = array[index]\n end\n }\n x\nend",
"def largest_integer_brute_force_approach(array)\n inspector = array.sort[0] - 1 #Find the smallest possible integer value that can be in the array\n index = 0 \n while index < array.length do #Iterate over all the elements in the array\n if array[index] > inspector #if an array element is bigger than the inspector\n inspector = array[index] #Reassign the value of the inspector to be said element\n end\n index+=1\n end\n inspector #Return the final value of the inspector\nend",
"def next_largest_number (array, given_number)\n array.find {|number| number > given_number}\nend",
"def largest_integer(list_of_nums)\n\n return nil if largest_integer == []\n\n big_num = list_of_nums[0] #set big_num variable equal to the first index in the array\n list_of_nums.each do |num| #iterate over the array\n if num > big_num #compare each element in the array to the variable big_num\n big_num = num # set big_num equal to the element if the num is bigger than first index\n end\n end\n p big_num #print big num variable\n end",
"def max(array)\n\tn = 0\n\tarray.each do |x|\n\t\tif x > n\n\t\t\t n = x\n\t\tend\n\tend\n\t puts n\nend",
"def greatest_number(num_array)\n num_array.sort.pop\nend",
"def find_next_greater_element(array)\n (0...array.length).each do |i|\n smallest_after = 100000\n (i...array.length).each do |j|\n if array[j] > array[i] && array[j] < smallest_after\n smallest_after = array[j]\n end\n end\n puts \"Next greatest for #{array[i]} is #{smallest_after}\"\n end\n\n\n\nend",
"def max_by(array)\n largest = nil\n largest_ret = nil\n array.each do |el|\n val = yield(el)\n largest, largest_ret = el, val if largest.nil? || val > largest_ret\n end\n largest\nend",
"def find_max_value(array)\n array.max { |item|\n return array.max\n }\n \nend",
"def max_by(arr)\n max = arr.first\n for el in arr\n max = el if yield(el) > yield(max)\n end\n max\nend",
"def biggest_number(array_of_integers)\n # TODO\nend",
"def big_dif(array)\n new_number = array.max - array.sort[-2]\nend",
"def highestnumber2 arr\n idx = 0 \n idx2 = 0 \n max = arr[0][0]\n\n while idx <= arr.length - 1\n\n if (highestnumber arr[idx]) > max\n max = highestnumber arr[idx]\n idx2 = idx \n end \n idx = idx + 1\n end\n return arr[idx2]\nend",
"def get_next_highest(num, array_num)\n retval = nil\n if ! num.nil? && num != -1\n arr_size = array_num.size\n sorted_nums = array_num.sort\n num_index = sorted_nums.index(num)\n if num_index == arr_size - 1\n retval = 100\n else\n retval = sorted_nums[num_index + 1]\n end\n end\n return retval\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overwrites slug_exists? from Slug. We allow duplicate slugs on different published_at dates. | def slug_exists?
Article.on(published_at).where(slug: slug).exists?
end | [
"def slug_unique?(test_slug, existing = existing_slugs)\n !existing.include?(test_slug)\n end",
"def slug_unique?(slug)\n self.class.find_by(slug: slug).nil?\n end",
"def slug_is_unique\n true\n end",
"def slug_unchanged?(slug)\n self.slug == slug\n end",
"def slugged?\n !slug.blank?\n end",
"def slug_needs_update?\n slug.blank? || (word_slug? and send(\"#{source_column}_changed?\") and base_slug != slug.gsub(/\\-[0-9]+$/,''))\n end",
"def auto_generate_slug\n return true unless self.slug.nil?\n return true if self.respond_to?(:published?) && !self.published?\n self.slug = self.interpolate_slug\n end",
"def slug?\n !! slug\n end",
"def new_with_slugs?\n new_record? && slug.present?\n end",
"def stale_slug?\n !((permanent_slug? && slug && !slug.empty?) || (slug_source_value.nil? || slug_source_value.empty?))\n end",
"def new_with_slugs?\n if localized?\n # We need to check if slugs are present for the locale without falling back\n # to a default\n new_record? && _slugs_translations.fetch(I18n.locale.to_s, []).any?\n else\n new_record? && _slugs.present?\n end\n end",
"def slug_changed?\n saved_change_to_slug?\n end",
"def persisted_with_slug_changes?\n persisted? && slug_changed?\n end",
"def found_using_outdated_friendly_id?\n @finder_slug.id != slug.id\n end",
"def found_using_outdated_friendly_id?\n @finder_slug.id != slug.id\n end",
"def stale_slug?\n !(\n (permanent_slug? && !slug_value.blank?) ||\n slug_source_value.blank?\n ) ||\n !(!new? && (dirty_attributes.keys.map(&:name) &\n (self.class.slug_options[:scope] || [])).compact.blank?\n )\n end",
"def pages_slug_validation\n return unless catalog\n\n return unless catalog.pages.exists?(slug: slug)\n\n errors.add :slug, I18n.t(\"validations.item_type.pages_slug\")\n end",
"def found_using_outdated_friendly_id?\n finder_slug.id != slug.id\n end",
"def slug_unique_in_clinic?\n Department.in_clinic(self).where(slug: slug).count == 0\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
START Feed Action Tests | def test_get_feed
get :feed
assert_response :success
end | [
"def test_mp3_feed_works\n get \"/podcast_feed/all/mp3/rss.xml\"\n assert last_response.ok?\n end",
"def test\n @entries = @feed.test\n rescue Exception => e\n flash[:error] = e.message\n redirect_to(admin_feeds_url)\n end",
"def test_feed_user\n user = create(:user)\n changesets = create_list(:changeset, 3, :user => user, :num_changes => 4)\n create(:changeset_tag, :changeset => changesets[1])\n create(:changeset_tag, :changeset => changesets[1], :k => \"website\", :v => \"http://example.com/\")\n _other_changeset = create(:changeset)\n\n get :feed, :params => { :format => :atom, :display_name => user.display_name }\n\n assert_response :success\n assert_template \"list\"\n assert_equal \"application/atom+xml\", response.content_type\n\n check_feed_result(changesets)\n end",
"def test1Action\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyAction' => [\n []\n ]\n }\n }\n )\n end",
"def feed; command FEED; end",
"def atest_ID_25891_scheduled_posts_02\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n sleep 5\n go_to_scheduled_tab_on_your_post_page\n verify_text \"Your Posts\",\"Current Drafts\", \"Scheduled Posts\", \"Published Posts\", \"Scheduled\"\n assert $profile_edit_post.exists?\n assert $profile_delete.exists?\n assert $count_of_scheduled.exists?\n end",
"def do_task_work\n @web.add_feed( @thing, @category, @message, @feedOptions )\n end",
"def run_start(config)\n puts \"The test run is starting\"\n end",
"def test_00120_profilepage_check_new_activity_feed\n @topicdetail_page = @topiclist_page.go_to_topic(\"A Watir Topic\")\n title = \"Test q created by Watir - #{get_timestamp}\"\n @topicdetail_page.create_conversation(type: :question,\n title: title,\n details: [{type: :text, content: \"Watir test description\"}])\n\n @profile_page.goto_profile\n @browser.wait_until { !@profile_page.question_list_in_activity_pane.activity_at_title(title).nil? }\n activity_card = @profile_page.question_list_in_activity_pane.activity_at_title(title)\n activity_card.click_conv_link\n @browser.wait_until { @convdetail_page.convdetail.present? }\n assert @convdetail_page.root_post_title.text =~ /#{title}/ \n end",
"def test_00130_profilepage_check_activity_feed_link\n @profile_page.goto_profile\n @browser.wait_until { @profile_page.profile_activity_item.present? }\n\n @browser.wait_until { @profile_page.question_list_in_activity_pane.activity_list.size > 0 }\n activity_card = @profile_page.question_list_in_activity_pane.activity_list[0]\n conv = activity_card.conv_title\n activity_card.click_conv_link\n\n @browser.wait_until { @convdetail_page.convdetail.present? }\n assert @convdetail_page.convdetail.text.include? conv\n end",
"def subscribe_feed(url)\n open_feeds_menu\n find('#add-subscription').click\n expect(page).to have_css '#subscribe-feed-popup'\n within '#subscribe-feed-popup' do\n fill_in 'Feed', with: url\n find('#subscribe-submit').click\n end\n\n # Ensure entries have finished loading\n expect(page).to have_no_css 'div#loading'\nend",
"def feed( category, message, feedOptions = nil )\n feedTask = FeedTask.new( @web, self, category, message, feedOptions )\n feedTask.perform()\n end",
"def test02_flag_repost_article_TC_24323\n\t\trepostArticlePop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T2: FAILED! User unable to flag post.\"\n\t\tend\n\tend",
"def run test_identifier=nil\n @dispatcher.run!\n # start\n message(\"start\")\n suite_setup,suite_teardown,setup,teardown,tests=*parse(test_identifier)\n if tests.empty? \n @dispatcher.exit\n raise RutemaError,\"No tests to run!\"\n else\n # running - at this point all checks are done and the tests are active\n message(\"running\")\n run_scenarios(tests,suite_setup,suite_teardown,setup,teardown)\n end\n message(\"end\")\n @dispatcher.exit\n @dispatcher.report(tests)\n end",
"def atest_ID_25891_scheduled_posts\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n schedule_post(\"Living\",\"House & Home\")\n go_to_scheduled_tab_on_your_post_page\n verify_text \"test_ID_25890_published_posts\",\"Your Posts\",\"Current Drafts\", \"Scheduled Posts\", \"Published Posts\", \"Scheduled\"\n verify_elements_on_scheduled_post \"test_ID_25891_scheduled_posts\"\n verify_scheduled_post_count_updated_after_deleting_scheduled_post\n end",
"def test_ID_25889_current_drafts_03\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n verify_draft_count_updated_after_creating_new_draft\n end",
"def test2Actions\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyActionWithParams' => [\n [ 'Param1', 'Param2' ]\n ],\n 'DummyAction' => [\n []\n ]\n }\n }\n )\n end",
"def test_count_articles_for_user_with_feed\n feed = UserFeed.find(6) #NErr the Blog\n count = VwArticlesForUser.count_articles_for_user(feed, :feed, 3)\n assert count == 2\n end",
"def test02_post_open_blog_repostArticle_TC_24313_243414\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open_article)\n\t\t\n\t\tsleep 3\n\t\trepost \"Repost text #{random}\" \n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Class method version of Gorilla::Unitnormalize, to handle, e.g., Enumerable, Numeric, and Range objects. | def normalize input, &block
case input
when Range
normalize(input.min, &block)..normalize(input.max, &block)
when Enumerable
input.map { |unit| normalize unit, &block }
when Numeric
normalize Unit.new(input), &block
else # Unit, etc.
input.normalize(&block)
end
end | [
"def convert_units(obj, un)\n begin\n obj.convert_units(un) # for GPhys etc\n rescue\n obj.convert2(un) # for UNumeric etc\n end\n end",
"def normalize_units(u)\n if u.blank?\n u = nil\n else\n u = u.to_s\n u = UNIT_SYN[u] || u\n u = u.to_s.gsub('^','**').tr(' ','*')\n begin\n ::Units.u(u)\n rescue\n u = nil\n end\n end\n u\n end",
"def normalize\n set_magnitude(1)\n end",
"def unit_(v_)\n (self - v_).normalize\n end",
"def normalize(value)\n send(\"normalize_#{@type}\", value)\n end",
"def convert_to_standard_units\n if self.class.units && self.unit then\n self.numerical_response = self.class.units.convert(self.numerical_response, :from => self.unit, :to => self.class.units.standard_unit) \n end\n end",
"def normalize( value )\n value\n end",
"def unit \n\t\t\tunitq = self.dup\n\t\t\tmagnitude = self.abs\n\t\t\tunitq[0] /= magnitude\n\t\t\tunitq[1] /= magnitude\n\t\t\tunitq[2] /= magnitude\n\t\t\tunitq[3] /= magnitude\n\t\t\treturn unitq\n\t\tend",
"def normalized\n vec = Vector2.new(@v)\n vec.normalize!\n end",
"def normalize\n @value = case @kind\n when 'fixed' then @value*1024\n when 'enum', 'range' then @value.map{ |v| v*1024 }\n end if @unit == 'GB'\n end",
"def normalized\n @value\n end",
"def normalize(min, max)\n map { |v| v.respond_to?(:-) ? (v - min) / (max - min) : v }\n end",
"def normalized\n @normalized ||= valid_range? ? range : normalized_range(range)\n rescue Exception => e \n # puts e.message\n value\n end",
"def normalize!\n self.replace self.normalize\n end",
"def convert_from_standard_units\n self.raw_numerical_response = self.numerical_response\n if !self.unit.blank? && self.class.units then\n self.numerical_response = self.class.units.convert(self.numerical_response, :from => self.class.units.standard_unit, :to => self.unit) \n end\n end",
"def normalize(x)\n if x.ndim == 2\n s = Numo::SFloat::Math.sqrt((x**2).sum(axis: 1))\n x / s.reshape(s.shape[0], 1)\n elsif x.ndim == 1\n s = Numo::SFloat::Math.sqrt((x**2).sum)\n x / s\n end\nend",
"def normalize(object, attribute, value); normalize_value(value) end",
"def normalize(value)\n Array(attrs[:normalize]).each do |method|\n next unless method.is_a?(Symbol)\n\n value = value.send(method) if value.respond_to?(method)\n end\n\n value\n end",
"def stat_normalized_distribution\n if first.kind_of?(Array)\n asum = esum = 0.0\n each { |a,e| asum += a; esum +=e }\n collect { |a,e| [a/asum, e/esum] }\n else\n a = 1.0/length\n esum = stat_sum.to_f\n collect { |e| [a,e/esum] }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns whether a unit was defined as metric. ==== Example class Coolness true end Coolness.new(1, :megaFonzie).metric? => true | def metric?
unit and self.class.rules[unit][:metric] || false
end | [
"def metric?\n @metric\n end",
"def metric_ton? = unit == 'metric-ton'",
"def is_metric?(unit)\n return (unit == \"mm\" || unit == \"cm\" || unit == \"m\" || unit == \"km\")\n end",
"def metric?\n false\n end",
"def cup_metric? = unit == 'cup-metric'",
"def square_meter? = unit == 'square-meter'",
"def pint_metric? = unit == 'pint-metric'",
"def pixel_per_meter? = unit == 'pixel-per-meter'",
"def metric? method_name\n method_name.to_s.end_with? '_metric'\n end",
"def square_kilometer? = unit == 'square-kilometer'",
"def karat? = unit == 'karat'",
"def micrometer? = unit == 'micrometer'",
"def kilowatt? = unit == 'kilowatt'",
"def kilometer? = unit == 'kilometer'",
"def meter_per_second? = unit == 'meter-per-second'",
"def unit?\n !@unit.nil?\n end",
"def megawatt? = unit == 'megawatt'",
"def cubic_meter? = unit == 'cubic-meter'",
"def is_meter m\r\n return false unless m.instance_of? Meter\r\n return true\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get exception status detail | def status_details(exception)
StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n"))
end | [
"def status_details\n return nil unless cause.respond_to? :status_details\n cause.status_details\n end",
"def status\n return 404 if NOT_FOUND_ERRORS.include? @exception.class.to_s\n @exception.respond_to?(:http_status) ? @exception.http_status : 500\n end",
"def get_http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatch::ExceptionWrapper.respond_to?(\n :status_code_for_exception\n )\n http_status =\n ActionDispatch::ExceptionWrapper.status_code_for_exception(\n exception.class.name\n )\n end\n\n http_status\n end",
"def status_code\n @status_code ||= ActionDispatch::ExceptionWrapper.new(env, exception).status_code\n end",
"def status_detail\n return @status_detail\n end",
"def status_error desc\n throw :status_error, desc\n end",
"def exception_details(e, msg); end",
"def extract_status(src)\n return if src.nil?\n src = src.exception if src.is_a?(ExecReport)\n # noinspection RailsParamDefResolve\n src.try(:http_status) || src.try(:status) || src.try(:code) ||\n src.try(:dig, :status) || src.try(:response).try(:dig, :status)\n end",
"def status_detail\n @status_detail\n end",
"def status_message\n @data[:status_message]\n end",
"def status_code\n return nil unless cause.respond_to? :status_code\n cause.status_code\n end",
"def http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatch::ExceptionWrapper.respond_to?(\n :status_code_for_exception\n )\n http_status =\n ActionDispatch::ExceptionWrapper.status_code_for_exception(\n exception.class.name\n )\n end\n\n http_status\n end",
"def status_code\n self.class.status_code\n end",
"def extract_information_from(env)\n exception = env['action_dispatch.exception']\n exception_wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)\n @rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[exception.class.name]\n @message = exception.message\n @status_code = exception_wrapper.status_code\n end",
"def exception_details e, msg\n [\n \"#{msg}\",\n \"Class: <#{e.class}>\",\n \"Message: <#{e.message.inspect}>\",\n \"---Backtrace---\",\n \"#{Minitest.filter_backtrace(e.backtrace).join(\"\\n\")}\",\n \"---------------\",\n ].join \"\\n\"\n end",
"def exit_status_from_exception; end",
"def message\n @response.status_message\n end",
"def exception_info(e)\n backtrace = Array(e.backtrace)[0, 500]\n\n res = {\n 'class' => e.class.to_s,\n 'message' => e.message,\n 'backtrace' => backtrace.join(\"\\n\"),\n 'rollup' => Digest::MD5.hexdigest(\"#{e.class}#{backtrace[0]}\")\n }\n\n if original = (e.respond_to?(:original_exception) && e.original_exception)\n remote_backtrace = []\n remote_backtrace << original.message\n if original.backtrace\n remote_backtrace.concat(Array(original.backtrace)[0,500])\n end\n res['remote_backtrace'] = remote_backtrace.join(\"\\n\")\n end\n\n res\n end",
"def error_details\n return @error_details\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all CPEs and their associated variants. The 'live' field in the output indicates whether any advisory has been shipped for that CPE and variant. This API does not require authentication. :apiurl: /api/v1/security/cpes :apimethod: GET :apiresponseexample: file:publican_docs/Developer_Guide/api_examples/cpes.json | def cpes
@variants = Variant.all.group_by{|variant| variant.cpe || ''}.sort_by{|cpe,v| cpe}
end | [
"def index\n if params[:cep]\n @api_ceps = Api::Cep.find_by(cep: params[:cep])\n if @api_ceps\n render json: {ceps: @api_ceps}, status: 202\n else\n render json: {error: 'CEP not found'}, status: 404\n end\n else\n @api_ceps = Api::Cep.all\n render json: {ceps: @api_ceps}, status: 202\n end\n end",
"def index\n @pecs = Pec.all\n end",
"def index\n @cps = Cp.all\n end",
"def find_cpe(cpe, document, without_versions)\n cves = []\n cpe_nodes = document[\"configurations\"][\"nodes\"]\n cpe_nodes.each do |cpe_nodes_elem|\n if cpe_nodes_elem.has_key?(\"cpe_match\")\n cves.push( get_cve_data(document) ) if scroll_cpe_match(cpe, cpe_nodes_elem[\"cpe_match\"], without_versions)\n end\n if cpe_nodes_elem.has_key?(\"children\")\n cpe_nodes_elem[\"children\"].each do |children_elem|\n cves.push( get_cve_data(document) ) if scroll_cpe_match(cpe, children_elem[\"cpe_match\"], without_versions)\n end\n end\n end\n #cves.each { |elem| (#puts '[find_cpe] cves: ' + elem.to_s) }\n return cves.uniq\n end",
"def index\n @ceps = Cep.all\n end",
"def index\n @capexes = Capex.all\n end",
"def index\n @pcs = Pc.all\n end",
"def vpcs\n @vpcs ||= init_vpcs\n end",
"def get_variants\n return [] if is_pdc?\n get_variants_by_package.values.flatten.uniq\n end",
"def cpe\n\t\t\t\t\twhere(:reference_name => \"cpe\").select('DISTINCT value')\n\t\t\t\tend",
"def index\n @v2_pessoas = V2::Pessoa.all\n end",
"def list(jss)\n return Casper.list(@jss, \"computers\", \"computers\") \n end",
"def index\n @pc_infos = PcInfo.all\n end",
"def index\n @c_povolanis = CPovolani.all\n end",
"def index\n @prospecto_meta_corto_plazos = ProspectoMetaCortoPlazo.all\n end",
"def index\n @excps = Excp.all\n end",
"def live_variants\n return self.variants.where(:status => ['Active', 'Inactive'])\n end",
"def index\n @cops = Cop.all\n end",
"def index\n @pvprovisions = Pvprovision.all\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a SUBSCRIBE frame. Sets `ack` header to 'auto' unless it is already set to 'client' or 'clientindividual'. | def subscribe_frame d, h
h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack])
create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]
end | [
"def subscribe_frame d, h\n h[:ack] = 'auto' unless h[:ack] == 'client'\n create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]\n end",
"def test_client_ack_with_symbol_10\n if @conn.protocol != Stomp::SPL_10\n assert true\n return\n end\n queue = make_destination()\n @conn.subscribe queue, :ack => :client\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_10\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has one required header, message-id, which must contain a value \n # matching the message-id for the MESSAGE being acknowledged.\n @conn.ack msg.headers['message-id']\n }\n checkEmsg(@conn)\n end",
"def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end",
"def test_client_ack_with_symbol_12\n if @conn.protocol != Stomp::SPL_12\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # The ACK frame MUST include an id header matching the ack header \n # of the MESSAGE being acknowledged.\n @conn.ack msg.headers['ack']\n }\n checkEmsg(@conn)\n end",
"def ack_frame *args\n create_ack_or_nack 'ACK', args\n end",
"def ack(subscription_headers, message)\n #p [:ack, message.headers[\"message-id\"]]\n if message.headers[\"message-id\"].to_s.strip != \"\" && subscription_headers[\"ack\"].to_s == \"client\"\n SMQueue.dbg { [:smqueue, :ack, :message, message].inspect }\n connection.ack message.headers[\"message-id\"], { }\n else\n SMQueue.dbg { [:smqueue, :ack, :not_acknowledging, message].inspect }\n end\n if ENV['PAUSE_SMQUEUE']\n $stderr.print \"press enter to continue> \"\n $stderr.flush\n $stdin.gets\n end\n end",
"def unsubscribe_frame f, h\n id = f.is_a?(OnStomp::Components::Frame) ? f[:id] : f\n create_frame('UNSUBSCRIBE', [{:id => id}, h]).tap do |f|\n raise ArgumentError, 'subscription ID could not be determined' unless f.header?(:id)\n end\n end",
"def api_create_and_send(master, side_table = nil)\n data = { subscriber: make_hash }\n data[:subscriberMessage] = master.subscriber_message_data\n data[:subscriber][:allowResubscribe] = true\n data[:sideTable] = side_table.payload_hash unless side_table.nil?\n\n path = '/composite/subscribeAndSend'\n attrs = data[:subscriber][:attributes][:attributes]\n # attrs has the form [ {name: :attr1, value: 'val1'}, {name: ...}, ...]\n email = attrs.select {|h| h[:name] == :email}.first[:value]\n master_id = master.subscriber_message_data[:masterId]\n info(\"Yesmail: subscribeAndSend #{email} to master #{master_id}\")\n handler.post(data, path)\n end",
"def create_subscription\n pub_client.create_logical_replication_slot(sub_name)\n sub_client.create_subscription(sub_name, subscription_conninfo, [pub_name], :create_slot => false)\n end",
"def create_and_send_ack\n send(create_ack)\n end",
"def create_2xx_ack\n #todo ACK must have the same credentials as INVITE.\n ack = create_subsequent_request(\"ACK\", false)\n end",
"def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\n end",
"def ack_frame *args\n headers = args.last.is_a?(Hash) ? args.pop : {}\n m_id = args.shift\n m_id = m_id[:'message-id'] if m_id.is_a?(OnStomp::Components::Frame)\n create_frame('ACK', [{:'message-id' => m_id}, headers]).tap do |f|\n raise ArgumentError, 'no message-id to ACK' unless f.header?(:'message-id')\n end\n end",
"def gen_subscriber\n subscriber = @context.socket(ZMQ::SUB)\n\n # Set timeout (TODO add option for customize timeout)\n subscriber.setsockopt(ZMQ::RCVTIMEO, @conf[:timeout_s] * 10**3)\n subscriber.connect(@conf[:subscriber_endpoint])\n\n subscriber\n end",
"def retain_acked= new_retain_acked\n update_grpc = Google::Cloud::PubSub::V1::Subscription.new name: name,\n retain_acked_messages: !(!new_retain_acked)\n @grpc = service.update_subscription update_grpc, :retain_acked_messages\n @resource_name = nil\n end",
"def gen_subscriber\n subscriber = @context.socket(ZMQ::SUB)\n\n # Set timeout (TODO add option for customize timeout)\n subscriber.setsockopt(ZMQ::RCVTIMEO, @wait_timeout * 10**3)\n subscriber.connect(@subscriber_endpoint)\n\n subscriber\n end",
"def ack\n @server.send(Protocol::Basic::Ack.new(:delivery_tag => properties[:delivery_tag]))\n end",
"def get_again(ackmode)\n received = nil\n assert_nothing_raised() {\n connection_subscribe(@queuename, { \"ack\" => ackmode })\n received = @conn.receive \n }\n #\n assert_not_nil(received, \"something should be received\")\n assert_equal(@test_message, received.body, \"received should again match sent\")\n assert_not_nil(received.headers[\"message-id\"], \"message ID should be present\")\n #\n assert_nothing_raised() {\n @conn.ack(received.headers[\"message-id\"]) if ackmode == \"client\"\n }\n received\n end",
"def subscribe(params = {})\n @connection ||= stub_connection\n @subscription = self.class.channel_class.new(connection, CHANNEL_IDENTIFIER, params.with_indifferent_access)\n @subscription.singleton_class.include(ChannelStub)\n @subscription.subscribe_to_channel\n @subscription\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates an ACK frame | def ack_frame *args
create_ack_or_nack 'ACK', args
end | [
"def sendAck\n $LOG.debug \"Sending ACK\"\n send_msg ack Messages::EndType::ACK\n end",
"def ack_frame *args\n headers = args.last.is_a?(Hash) ? args.pop : {}\n m_id = args.shift\n m_id = m_id[:'message-id'] if m_id.is_a?(OnStomp::Components::Frame)\n create_frame('ACK', [{:'message-id' => m_id}, headers]).tap do |f|\n raise ArgumentError, 'no message-id to ACK' unless f.header?(:'message-id')\n end\n end",
"def create_and_send_ack\n send(create_ack)\n end",
"def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\n end",
"def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end",
"def nack_frame *args\n create_ack_or_nack 'NACK', args\n end",
"def create_2xx_ack\n #todo ACK must have the same credentials as INVITE.\n ack = create_subsequent_request(\"ACK\", false)\n end",
"def ack\n @server.send(Protocol::Basic::Ack.new(:delivery_tag => properties[:delivery_tag]))\n end",
"def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end",
"def ack(frame)\n @@queue_manager.ack(self, frame)\n end",
"def ack(error=nil)\n ack = HL7::Message.new\n msh = ack.standard_msh\n msh.receiving_application = self.msh.sending_application\n msh.receiving_facility = self.msh.sending_facility\n msh.message_type = {:message_code=>'ACK',:trigger_event=>self.msh.message_type.trigger_event,:message_structure=>'ACK'}\n msh.processing_id = self.msh.processing_id\n msh.message_control_id = \"K%X\" % Time.now.to_i\n ack << msh\n msa = HL7::Msa.new\n msa.segment = \"MSA\"\n msa.control_id = self.msh.message_control_id\n if self.msh.accept_acknowledgement_type.blank? and self.msh.application_acknowledgement_type.blank?\n # we are using old-style ACKs\n if error\n msa.code = \"AE\"\n msa.text = error\n else\n msa.code = \"CA\"\n msa.text = \"Normal acknowledgement.\"\n end\n else\n # we are using new-style ACKs\n ack_type = self.msh.accept_acknowledgement_type\n if error\n if ack_type == \"AL\" or ack_type == \"ER\"\n msa.code = \"CE\"\n msa.text = error\n else\n return nil\n end\n else\n if ack_type == \"AL\" or ack_type == \"SU\"\n msa.code = \"CA\"\n msa.text = \"Normal acknowledgement.\"\n else\n return nil\n end # if ack_type\n end # if error\n end # if\n ack << msa\n return ack\n end",
"def create\n @ack = Ack.new(params[:ack])\n\n respond_to do |format|\n if @ack.save\n format.html { redirect_to(@ack, :notice => 'Ack was successfully created.') }\n format.json { render :json => @ack, :status => :created, :location => @ack }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @ack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def screencast_frame_ack(session_id:)\n {\n method: \"Page.screencastFrameAck\",\n params: { sessionId: session_id }.compact\n }\n end",
"def ack?\n @bytes.first == Message::ACK\n end",
"def test_0010_ack_send_receive\n ack_client_test(:ackparm => \"ack\", :times => 1, :mod => \"0010\")\n end",
"def test_client_ack_with_symbol_12\n if @conn.protocol != Stomp::SPL_12\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # The ACK frame MUST include an id header matching the ack header \n # of the MESSAGE being acknowledged.\n @conn.ack msg.headers['ack']\n }\n checkEmsg(@conn)\n end",
"def ack(message_or_ack_id, headers = {})\n raise Stomp::Error::NoCurrentConnection if @closed_check && closed?\n raise Stomp::Error::ProtocolErrorEmptyHeaderKey if headers.has_key?(\"\")\n raise Stomp::Error::ProtocolErrorEmptyHeaderValue if @protocol == Stomp::SPL_10 && headers.has_value?(\"\")\n raise Stomp::Error::MessageIDRequiredError if message_or_ack_id.nil? || message_or_ack_id == \"\"\n headers = headers.symbolize_keys\n\n case @protocol\n when Stomp::SPL_12\n # The ACK frame MUST include an \"id\" header matching the \"ack\" header \n # of the MESSAGE being acknowledged.\n headers[:id] = message_or_ack_id\n when Stomp::SPL_11\n # ACK has two REQUIRED headers: \"message-id\", which MUST contain a value \n # matching the message-id header of the MESSAGE being acknowledged and \n # \"subscription\", which MUST be set to match the value of SUBSCRIBE's \n # id header.\n headers[:'message-id'] = message_or_ack_id\n raise Stomp::Error::SubscriptionRequiredError unless headers[:subscription]\n else # Stomp::SPL_10\n # ACK has one required header, \"message-id\", which must contain a value \n # matching the message-id for the MESSAGE being acknowledged.\n headers[:'message-id'] = message_or_ack_id\n end\n _headerCheck(headers)\n slog(:on_ack, log_params, headers)\n transmit(Stomp::CMD_ACK, headers)\n end",
"def begin_frame tx, h\n create_transaction_frame 'BEGIN', tx, h\n end",
"def ack(subscription_headers, message)\n #p [:ack, message.headers[\"message-id\"]]\n if message.headers[\"message-id\"].to_s.strip != \"\" && subscription_headers[\"ack\"].to_s == \"client\"\n SMQueue.dbg { [:smqueue, :ack, :message, message].inspect }\n connection.ack message.headers[\"message-id\"], { }\n else\n SMQueue.dbg { [:smqueue, :ack, :not_acknowledging, message].inspect }\n end\n if ENV['PAUSE_SMQUEUE']\n $stderr.print \"press enter to continue> \"\n $stderr.flush\n $stdin.gets\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates an NACK frame | def nack_frame *args
create_ack_or_nack 'NACK', args
end | [
"def ack_frame *args\n create_ack_or_nack 'ACK', args\n end",
"def makeframe(packetdata)\n\t\tif packetdata.size > 255\n\t\t\tprint_error(\"#{rhost}:#{rport} - MODBUS - Packet too large: #{packetdata.inspect}\")\n\t\t\treturn\n\t\tend\n\t\tpayload = \"\"\n\t\tpayload += [@modbuscounter].pack(\"n\")\n\t\tpayload += \"\\x00\\x00\\x00\" #dunno what these are\n\t\tpayload += [packetdata.size].pack(\"c\") # size byte\n\t\tpayload += packetdata\n\tend",
"def create_packet(lookup_host, transaction_ID) \n packet = [transaction_ID, FLAGS, QUESTIONS, ANSWERS, AUTHORITY_RRS, ADDITIONAL_RRS].pack(\"S>S>S>S>S>S>\")\n packet += encode_lookup_host(lookup_host)\n packet += [TYPE_A, CLASS_IN].pack(\"S>S>\")\n \n return packet\nend",
"def makePacket(destIP, sourceIP, type, seqNum, ackNum)\n\tpacket = Packet.new\n\n\tpacket.destIP = destIP\n\tpacket.sourceIP = sourceIP\n\tpacket.type = type\n\tpacket.seqNum = seqNum\n\tpacket.ackNum = ackNum\n\n\tif(type == 0)\n\t\tpacket.data = \"This is ack #{ackNum}\"\n\telsif(type == 1)\n\t\tpacket.data = \"This is packet #{seqNum}\"\n\telse\n\t\tpacket.data = \"This is an EOT\"\n\tend\n\t\t\n\n\treturn packet\nend",
"def new_frame( cfg, prefix = nil )\n keys = cfg.__desc.keys.map {|k| k.to_s}\n keys.sort!\n keys.map! {|k| k.to_sym}\n\n Frame.new(cfg, prefix.to_s, keys, 0)\n end",
"def make_netbios(payload)\n [payload.length & 0x00ffffff, payload].pack(\"Na*\")\nend",
"def transmit_frame(kind = :standard, identifier = 0, length = 0, frame_data = 0)\n case frame_data\n when String\n data = frame_data.bytes.map { |b| b.to_s(16).rjust(2, '0') }.join.rjust(length * 2, '0')\n else\n data = frame_data.to_s(16).rjust(length * 2, '0')\n end\n\n case kind\n when :standard\n identifier = (identifier & 0x7ff).to_s(16).rjust(3, '0')\n frame = StandardFrame.new(:identifier => identifier, :data => data, :dlength => length.to_s)\n when :extended\n identifier = (identifier & 0x1fffffff).to_s(16).rjust(8, '0')\n frame = ExtendedFrame.new(:identifier => identifier, :data => data, :dlength => length.to_s)\n else\n raise 'invalid frame kind'\n end\n\n if frame.errors.any?\n raise \"invalid frame: #{frame.errors.join(\"\\n\")}\"\n else\n response = issue_command(:transmit, { :frame => frame })\n end\n\n @serial.read(1) if RETURN_CODE[response.return_code] == :ok\n\n response\n end",
"def begin_frame tx, h\n create_transaction_frame 'BEGIN', tx, h\n end",
"def create_frame\n frames.last.copy\n end",
"def frame(ethertype, payload, opts = {})\n src_mac = opts[:src_mac] || @src_mac\n dst_mac = opts[:dst_mac] || @dst_mac\n ethertype = [ ethertype ].pack('S>') if ethertype.class <= Integer\n frm = dst_mac + src_mac + ethertype + payload\n inject(frm) unless opts[:noinject] or opts[:norecurse]\n frm\n end",
"def send_frame(command, headers={}, body='')\n headers['content-length'] = body.size.to_s\n response = StompServer::StompFrame.new(command, headers, body)\n stomp_send_data(response)\n end",
"def build\n mount_frames\n transmit\n end",
"def write_frame_nonblock frame\n ser = serializer.frame_to_bytes frame\n push_write_buffer ser, frame\n end",
"def inject(frame)\n tap_hdr = [ '', frame[12, 2] ].pack('a2a2')\n @raw.write(tap_hdr + frame)\n @raw.flush\n end",
"def create_and_send_ack\n send(create_ack)\n end",
"def prepare_and_write_ndmp_msg(msg, all_but_last_char=false, times=1, flags=0)\n msg.header.sequence_num = @next_sequence_num\n @next_sequence_num += 1\n msg.header.timestamp = Time.now.to_i\n\n frag = msg.header.to_xdr + msg.body\n write_ndmp_frag(frag, all_but_last_char, times, flags)\n end",
"def send_packet\n vprint_status('Protocol finished setup. Going to send packet.')\n msg = \"17 #{@packet_payload.length}\\n#{@packet_payload}\"\n plen = BF_BLOCKSIZE - (msg.length % BF_BLOCKSIZE)\n # padding\n msg += 'B' * plen\n @encryption_queue.push(msg)\n @keep_reading_socket = false\n handle_write\n end",
"def msgpack_factory; end",
"def build(args={})\n klass = FRAME_TYPE_MAP[args[:type].to_i]\n if(klass == FrameType::Response)\n klass.new(:response => args[:data])\n elsif(klass == FrameType::Error)\n klass.new(:error => args[:data])\n elsif(klass == FrameType::Message)\n unpacked = args[:data].unpack(\"Q>s>a16a#{args[:size]}\")\n klass.new(\n Hash[*([:timestamp, :attempts, :message_id, :message].zip(unpacked).flatten)]\n )\n else\n raise TypeError.new \"Unknown frame type received: #{args[:type].inspect} - #{klass.inspect}\"\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a heartbeat frame (serialized as a single "\n" character) | def heartbeat_frame
OnStomp::Components::Frame.new
end | [
"def sendHeartbeat()\n send!(0, :HB, -1, -1, -1, -1)\n end",
"def send_heartbeat(sequence)\n send_packet(Opcodes::HEARTBEAT, sequence)\n end",
"def make_event_frame( payload )\n\t\tframe = Mongrel2::WebSocket::Frame.new( '', 0, '', {}, payload )\n\t\tframe.opcode = :text\n\n\t\treturn frame.to_s\n\tend",
"def create_heartbeat(body, opts = {})\n data, _status_code, _headers = create_heartbeat_with_http_info(body, opts)\n return data\n end",
"def send_heartbeat\n send_message DCell::Message::Heartbeat.new\n @heartbeat = after(self.class.heartbeat_rate) { send_heartbeat }\n end",
"def sendHeartbeat()\n if NodeAgent.instance.connected?\n send!(:HB, -1, -1, -1, -1)\n else\n # haven't heard from nodeHandler yet, resend initial message\n sendWHOAMI\n end\n end",
"def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT], @session.seq)\n end",
"def send_frame(data)\n frame = WebSocket::Frame::Outgoing::Client.new version: @handshake.version,\n data: data, type: :text\n @socket.send frame.to_s, 0\n end",
"def makeframe(packetdata)\n\t\tif packetdata.size > 255\n\t\t\tprint_error(\"#{rhost}:#{rport} - MODBUS - Packet too large: #{packetdata.inspect}\")\n\t\t\treturn\n\t\tend\n\t\tpayload = \"\"\n\t\tpayload += [@modbuscounter].pack(\"n\")\n\t\tpayload += \"\\x00\\x00\\x00\" #dunno what these are\n\t\tpayload += [packetdata.size].pack(\"c\") # size byte\n\t\tpayload += packetdata\n\tend",
"def create\n @heartbeat = current_user.heartbeats.build(heartbeat_params)\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @heartbeat, notice: 'Heartbeat Record Created' }\n format.json { render :show, status: :created, location: @heartbeat }\n else\n format.html { render :new }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_heartbeat\n if tcp_connection_established? && !@handling_skipped_hearbeats && @last_server_heartbeat\n if @last_server_heartbeat < (Time.now - (self.heartbeat_interval * 2)) && !reconnecting?\n logger.error \"[amqp] Detected missing server heartbeats\"\n self.handle_skipped_hearbeats\n end\n send_frame(Protocol::HeartbeatFrame)\n end\n end",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def start_heartbeat\n @hb_received_at = Time.now\n send_heartbeat\n @heartbeat_timer = @reactor.periodical_timer(@heartbeat_interval) { send_heartbeat }\n end",
"def send_heartbeat(test_req_id = nil)\n msg = FP::Messages::Heartbeat.new\n test_req_id && msg.test_req_id = test_req_id\n send_msg(msg)\n end",
"def make_websocket_frame( opts={} )\n\t\topts = TEST_WEBSOCKET_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_WEBSOCKET_HEADERS )\n\n\t\tMongrel2.log.debug \"WebSocket frame, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend",
"def write frame\n @socket.write frame\n end",
"def send_frame(command, headers={}, body='')\n headers['content-length'] = body.size.to_s\n response = StompServer::StompFrame.new(command, headers, body)\n stomp_send_data(response)\n end",
"def next_heartbeat\n Time.now + heartbeat_interval.to_f / 1000.0\n end",
"def sample_packhdr_be_nsec\n \"\\xA1\\xB2<M\" +\n \"S\\xFEn')6\\xA0)\\x00\\x00\\x02\\x1F\\x00\\x00\\x02\\x1F\" +\n \"\\x00\\x00\\xFF\\xFF\\x00\\x00\\x00\\x01\" # padding\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tyear, tmonth, tweek assigned where setting spent_on attributes these attributes make time aggregations easier | def spent_on=(date)
super
self.tyear = spent_on ? spent_on.year : nil
self.tmonth = spent_on ? spent_on.month : nil
self.tweek = spent_on ? spent_on.cweek : nil
end | [
"def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n self.spent_from = date\n self.spent_to = self.spent_from.advance(:hours=>hours) if self.spent_from && hours\n end",
"def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n end",
"def date_time_grouping; end",
"def set_attributes\n @total=0\n @week_total=0\n days=(@finish-@start).to_i + 1 #/60/60/24+1 \n if (7-@start.wday) < days and days < 8\n @total+=total_hours(@start.wday,@finish.wday)\n @week_total=@total\n else\n @total+=total_hours(@start.wday,6)\n days -= (7-@start.wday)\n @total+=total_hours(0,@finish.wday)\n days-=(@finish.wday+1)\n @week_total=@total if days==0\n week_total=total_hours(0,6)\n @total+=week_total * days / 7\n @week_total=week_total if days != 0\n end\n end",
"def group_matter_time_spent(col)\n total_data,table_headers,conditions,data = {},{},{},[]\n if params[:report][:summarize_by] == \"lead_lawyer\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:employee_user_id).each do |label,matters|\n \n key = nil\n matters.each do|matter|\n key = matter.get_lawyer_name unless key\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n actual_duration = @dur_setng_is_one100th ? one_hundredth_timediffernce(e.actual_duration) : one_tenth_timediffernce(e.actual_duration)\n bill_hours += actual_duration\n end\n \n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.contact ? matter.contact.name : \"\",matter.contact ? matter.contact.accounts[0] ? matter.contact.accounts[0].name : \"\" : \"\",matter.matter_no,matter.matter_category,matter.matter_status ? matter.matter_status.alvalue : \"\",rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n \n conditions[key] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[key] = data\n sum_hrs(conditions,key)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n \n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:label_client),t(:label_Account),t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"#{t(:text_projected)} #{t(:text_hour)}\"]\n elsif params[:report][:summarize_by] == \"client\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:contact_id).each do |label,matters|\n key = nil\n matters.each do|matter|\n key = matter.contact ? matter.contact.name : nil unless key\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.get_lawyer_name,matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"\" : \"\",matter.matter_no,matter.matter_category,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n\n conditions[key] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[key] = data\n sum_hrs(conditions,key)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n\n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:text_select_lawyer),\"#{t(:label_Account)}\",t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n elsif params[:report][:summarize_by] == \"account\"\n ehrs,bhrs,rhrs = 0,0,0\n matters = col.collect do |matter|\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n account = matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"None\" : \"None\"\n [matter.name,matter.get_lawyer_name,matter.contact ? matter.contact.name : \"\",matter.matter_no,matter.matter_category,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours),account]\n end\n matters_hash = {}\n matters.each do |matter|\n key = matter.pop\n if matters_hash.has_key?(key)\n matters_hash[key] << matter\n else\n matters_hash[key] = [matter]\n end\n end\n matters_hash.each do |label,matters|\n matters.each do |matter|\n ehrs += matter[-3].to_f\n bhrs += matter[-2].to_f\n rhrs += matter[-1].to_f\n end\n conditions[label] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[label] = matters\n sum_hrs(conditions,label)\n end\n \n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:text_select_lawyer),t(:label_client),t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n elsif params[:report][:summarize_by] == \"lit_type\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:matter_category).each do |label,matters|\n matters.each do|matter|\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.contact ? matter.contact.name : \"\",matter.get_lawyer_name,matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"\" : \"\",matter.matter_no,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n label = label.try(:capitalize)\n conditions[label] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[label] = data\n sum_hrs(conditions,label)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n\n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:label_client),t(:text_select_lawyer),\"#{t(:label_Account)}\",t(:text_matter_id),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n end\n alignment = {0=> :left,1=> :left,2=> :left,3=> :center,4=> :center,5=>:center,6=> :center,7=> :center,8=> :center} if params[:format] == \"pdf\"\n [total_data,table_headers,conditions,column_widths,alignment]\n end",
"def worktype_tracking(begda,endda)\n teams=Team.find(:all)\n curdate = begda\n wt_total = []\n until curdate > endda do\n teams.each do |team|\n wt_team_month = calculate_worktype_distribution(curdate,team.id)\n # get the total time and calculate percentages\n sum_of_times_booked = 0\n wt_team_month.keys.each do |wt|\n sum_of_times_booked += wt_team_month[wt][:daysbooked]\n end\n\n wt_team_month.keys.each do |wt|\n perc = (wt_team_month[wt][:daysbooked] / sum_of_times_booked)*100\n wt_total << { :month => Date::ABBR_MONTHNAMES[curdate.month], \n :team_id => team.id,\n :worktype_id => wt,\n :daysbooked => wt_team_month[wt][:daysbooked],\n :perc => perc} \n end\n end\n\n curdate = curdate >> 1\n end\n return wt_total\n end",
"def time_accounted_month_wise_data\n\t\tduration,method_name=\"month\",'time_accounted_month_wise'\n\t\ttime_accounted(duration,method_name)\n\t\tset_title(\"#{@user.full_name.titleize}'s Time Accounted -Month wise\")\n\t\tset_sub_caption\n\tend",
"def time_spent; end",
"def hour_metrics; end",
"def total_hours \n @total_hours ||= timesheets \n .where('day BETWEEN ? AND ?', Date.today.beginning_of_week, Date.today.end_of_week)\n .sum {|p| p.teacher + p.conversation + p.study} \n end",
"def get_total_time_swam\n relay_timings = meeting_relay_swimmers.collect { |mrs| mrs.get_timing_instance.to_hundreds }\n ind_timings = meeting_individual_results.collect { |mir| mir.get_timing_instance.to_hundreds }\n total_hundreds = (relay_timings + ind_timings).inject { |sum, hundreds| sum + hundreds }\n Timing.new(total_hundreds)\n end",
"def booked_time_for_year(event, unit)\n year = event.starts_at.year\n Event\n .where.not(id: event.id)\n .where(calendars.present? ? {calendar: calendars} : nil)\n .where(kinds.present? ? {kind: kinds} : nil)\n .where(creator: event.household_users)\n .where(starts_at: Time.zone.local(year)...Time.zone.local(year + 1))\n .to_a.sum(&unit)\n end",
"def skill_time_vs_completed_tasks\n\n end",
"def time_accounted_and_creditable_month_wise_data\n\t\tduration,method_name=\"creditable_month\",'time_accounted_and_creditable_month_wise'\n\t\ttime_accounted_and_creditable(duration,method_name)\n\t\tset_title(\"#{@user.full_name.titleize}'s Time Accounted vs. Creditable - Month wise\")\n\t\tset_sub_caption\n\tend",
"def time_accounted_and_creditable_week_wise_data\n\t\tduration,method_name=\"creditable_week\",'time_accounted_and_creditable_week_wise'\n\t\ttime_accounted_and_creditable(duration,method_name)\n\t\tset_title(\"#{@user.full_name.titleize}'s Time Accounted vs. Creditable - Week wise\")\n\t\tset_sub_caption\n\tend",
"def usage_summary(now=DateTime.now)\n summary = {\n this_month: { secs: 0, hours: 0, overage: {}, ondemand: {}, cost: 0.00 },\n current: [],\n history: [],\n }\n year = now.utc.year\n month = now.utc.month\n thismonth = sprintf(\"%d-%02d\", year, month)\n summary[:this_month][:period] = thismonth\n monthly_usages.order('\"yearmonth\" desc, \"use\" asc').slice(0,48).each do |mu|\n msum = {\n period: mu.yearmonth,\n type: mu.use,\n secs: mu.value.to_i,\n hours: mu.value.fdiv(3600).round(3),\n cost: mu.retail_cost.round(2), # expose only what we charge customers, whether we charge them or not.\n }\n summary[:history].push msum\n if mu.yearmonth == thismonth\n summary[:current].push msum\n end\n end\n\n # calculate current totals based on the User's plan. This determines overages.\n plan_hours = plan.hours\n base_monthly_cost = plan.amount # TODO??\n plan_is_premium = plan.has_premium_transcripts?\n\n # if plan is \"basic\", calculate ondemand premium and overages.\n if !plan_is_premium\n summary[:current].each do |msum|\n\n # if there is premium usage, it must be on-demand, so pass on the msum cost.\n if msum[:type] == MonthlyUsage::PREMIUM_TRANSCRIPTS && msum[:hours] > 0\n summary[:this_month][:ondemand][:cost] = msum[:cost]\n summary[:this_month][:ondemand][:hours] = msum[:hours].round(3)\n summary[:this_month][:cost] += msum[:cost]\n summary[:this_month][:hours] += msum[:hours].round(3)\n summary[:this_month][:secs] += msum[:secs]\n\n # basic plan, basic usage.\n elsif msum[:type] == MonthlyUsage::BASIC_TRANSCRIPTS\n\n # month-to-date hours\n summary[:this_month][:hours] += msum[:hours].round(3)\n summary[:this_month][:secs] += msum[:secs]\n\n # check for overage\n if msum[:hours] > plan_hours\n summary[:this_month][:overage][:hours] = msum[:hours] - plan_hours\n # we do not charge for basic plan overages. instead we just prevent them at upload time.\n #summary[:this_month][:overage][:cost] = (OVERAGE_HOURLY_RATE * summary[:this_month][:overage][:hours]).round(2)\n #summary[:this_month][:cost] += summary[:this_month][:overage][:cost]\n end\n end\n end\n\n # otherwise, plan is premium. sum this month and check for overages only.\n else\n summary[:current].each do |msum|\n #Don't double count usage for users in orgs.\n if !(msum[:type] == MonthlyUsage::PREMIUM_TRANSCRIPT_USAGE && self.organization)\n summary[:this_month][:hours] += msum[:hours].round(3)\n summary[:this_month][:secs] += msum[:secs]\n summary[:this_month][:cost] += msum[:cost]\n end\n if msum[:type] == MonthlyUsage::PREMIUM_TRANSCRIPTS\n if msum[:hours] > plan_hours\n summary[:this_month][:overage][:hours] = msum[:hours] - plan_hours\n summary[:this_month][:overage][:cost] = (OVERAGE_HOURLY_RATE * summary[:this_month][:overage][:hours]).round(2)\n summary[:this_month][:cost] += summary[:this_month][:overage][:cost]\n end\n end\n end\n if summary[:this_month][:overage][:cost]\n # since we had an overage for the month, ignore any specific retail costs for this month,\n # and treat the overage as the total for the month. This is because we don't want to charge 2x\n # if an on-demand retail cost contributed to the overage.\n summary[:this_month][:cost] = summary[:this_month][:overage][:cost]\n end\n end\n\n # return\n summary\n end",
"def calculated_spend_by_month\n return if !organisation.respond_to?(:payments) || organisation.payments.count == 0\n res_hsh = {}\n group_by = case ActiveRecord::Base.connection.adapter_name\n when 'MySQL'\n # https://github.com/django/django/blob/master/django/db/backends/mysql/base.py#L207\n \"CAST(DATE_FORMAT(date, '%Y-%m-01 00:00:00') AS DATETIME)\"\n else # PostgreSQL\n # https://github.com/django/django/blob/master/django/db/backends/postgresql_psycopg2/operations.py#L35\n \"DATE_TRUNC('month', date)\"\n end\n ft_sums = organisation.payments.sum(:value, :conditions => {:date_fuzziness => nil}, :group => group_by).to_a\n fuzzy_sums = organisation.payments.all(:select => 'SUM(value) AS value, date, date_fuzziness', :conditions => \"date_fuzziness IS NOT NULL\", :group => 'date, date_fuzziness')\n\n fuzzy_sums.each{ |fs| ft_sums += fs.averaged_date_and_value }\n\n ft_sums.each do |ft_sum|\n res_hsh[ft_sum.first.to_date.beginning_of_month] = res_hsh[ft_sum.first.to_date.beginning_of_month].to_f + ft_sum.last\n end\n\n months_with_vals = res_hsh.sort\n \n first_month, last_month = months_with_vals.first, months_with_vals.last\n spend_by_month_array(first_month.first, last_month.first, months_with_vals)\n end",
"def work_hours_per_year\n (52 - paid_time_off_week_count) * 40\n end",
"def time_accounted_week_wise_data\n\t\tduration,method_name=\"week\",'time_accounted_week_wise'\n\t\ttime_accounted(duration,method_name)\n\t\tset_title(\"#{@user.full_name.titleize}'s Time Accounted -Week wise\")\n\t\tset_sub_caption\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /stay_times GET /stay_times.json | def index
@stay_times = StayTime.all
end | [
"def index\n get_todays_data\n\n respond_to do |format|\n format.html { }\n format.json { json_response(@set_times) }\n end\n end",
"def index\n @time_entries = TimeEntry.all\n render :json => @time_entries, status: :ok\n end",
"def index\n \n @task_times = @task.task_times.order(\"stopped_at desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @task_times }\n end\n end",
"def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end",
"def index\n @timekeepings = Timekeeping.all\n end",
"def list\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end",
"def index\n @meeting_times = MeetingTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meeting_times }\n end\n end",
"def index\n @class_times = ClassTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @class_times }\n end\n end",
"def index\n @time_slots = TimeSlot.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@time_slots) }\n\t\tend\n end",
"def test_get_all_times\n url = format('%s/times?token=%s', @ts.instance_variable_get(:@baseurl),\n @ts.instance_variable_get(:@token))\n\n stub_request(:get, /.*times.*/)\n .to_return(body: JSON.dump([Hash['this' => 'should be in a list']]))\n\n assert_equal(@ts.get_times,\n [Hash['this' => 'should be in a list']])\n end",
"def index\n @meal_times = MealTime.all\n end",
"def index\n @available_times = AvailableTime.all\n end",
"def index\n render json: Roomservice.where(stay_id: params[:stay_id])\n end",
"def index\n @timetable_class_times = TimetableClassTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @timetable_class_times }\n end\n end",
"def index\n\t\t@war_times = @war.war_times\n\tend",
"def test_get_time_for_activity\n url = format('%s/times?activity=dev&token=%s',\n @ts.instance_variable_get(:@baseurl),\n @ts.instance_variable_get(:@token))\n\n stub_request(:get, /.*times.*/)\n .to_return(body: JSON.dump([Hash['this' => 'should be in a list']]))\n\n assert_equal(@ts.get_times(Hash['activity' => ['dev']]),\n [Hash['this' => 'should be in a list']])\n end",
"def index\n @stop_times = StopTime.all\n respond_to do |format|\n format.html { render :index }\n format.xml { render xml: @stop_times, status: :ok }\n format.json { render json: @stop_times, status: :ok }\n end\n end",
"def index\n @service_times = ServiceTime.all\n end",
"def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /stay_times POST /stay_times.json | def create
@stay_time = StayTime.new(stay_time_params)
respond_to do |format|
if @stay_time.save
format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }
format.json { render :show, status: :created, location: @stay_time }
else
format.html { render :new }
format.json { render json: @stay_time.errors, status: :unprocessable_entity }
end
end
end | [
"def index\n @stay_times = StayTime.all\n end",
"def create\n @timing = Timing.new(params[:timing].slice(:start, :stop, :days, :parent_class, :parent_id, :active))\n if @timing.save\n render json: @timing\n else\n render json: { error: 'error: could not save timing' }\n end\n end",
"def create\n @time_gap = TimeGap.new(params[:time_gap])\n\n respond_to do |format|\n if @time_gap.save\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully created.' }\n format.json { render json: @time_gap, status: :created, location: @time_gap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n busy_shifts = params[:busy_shift]\n if busy_shifts\n busy_shifts[:day].length.times do |index|\n day = busy_shifts[:day][index]\n start_time = busy_shifts[:start_time][index]\n end_time = busy_shifts[:end_time][index]\n @busy_shifts = current_user.busy_shifts.create(:day => day, :start_time => start_time, :end_time => end_time)\n end\n render json: current_user.busy_shifts\n else\n render json: {errors: \"Could not create busy shifts there was a error\"}\n end\n end",
"def create\n\t\t@war_time = WarTime.new(war_time_params)\n\t\t@war_time.war = @war\n\n\t\trespond_to do |format|\n\t\t\tif @war_time.save\n\t\t\t\tback_page = war_times_path(@war)\n\t\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\t\tformat.html { redirect_to back_page, notice: 'Time was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: back_page }\n\t\t\telse\n\t\t\t\tformat.html { broadcast_errors @war_time, (['start_at', 'end_at', 'max_unanswered']) }\n\t\t\t\tformat.json { render json: @war_time.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n cnt = params[:tutor_availability][:repeat].to_i - 1\n params[:tutor_availability].delete :repeat\n @tutor_availability = TutorAvailability.new(params[:tutor_availability])\n\n respond_to do |format|\n if @tutor_availability.save\n if cnt > 0\n for i in 1..cnt\n new_ta = TutorAvailability.new(params[:tutor_availability])\n new_ta.start_time = @tutor_availability.start_time + 604800*i\n new_ta.save\n end\n end\n format.html { redirect_to tutor_availabilities_path, notice: 'Tutor availability was successfully created.' }\n format.json { render json: @tutor_availability, status: :created, location: @tutor_availability }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutor_availability.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @working_time = WorkingTime.new(params[:working_time])\n\n respond_to do |format|\n if current_user.time_tables[0].working_times << @working_time\n format.html { redirect_to time_tables_path }\n format.json { render json: @working_time, status: :created, location: @working_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@timekeeping = Timekeeping.new(timekeeping_params)\n\t@timekeeping = Timekeeping.new\n\t@timekeeping.clock_in = DateTime.current\n respond_to do |format|\n if @timekeeping.save\n format.html { redirect_to @timekeeping, notice: 'Timekeeping was successfully created.' }\n format.json { render :show, status: :created, location: @timekeeping }\n else\n format.html { render :new }\n format.json { render json: @timekeeping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @time_tracker = TimeTracker.new({ started_at: Time.current, status: 'running' }.merge(time_tracker_params))\n\n respond_to do |format|\n if @time_tracker.save\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully created.' }\n format.json { render :show, status: :created, location: @time_tracker }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @timeslot = Timeslot.new(timeslot_params)\n @timeslot.save!\n render :json => @timeslot.as_json\n end",
"def create\n @tummy_time = TummyTime.new(tummy_time_params)\n\n respond_to do |format|\n if @tummy_time.save\n format.html { redirect_to @tummy_time, notice: 'Tummy time was successfully created.' }\n format.json { render :show, status: :created, location: @tummy_time }\n else\n format.html { render :new }\n format.json { render json: @tummy_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stime = Stime.new(stime_params)\n\n respond_to do |format|\n if @stime.save\n format.html { redirect_to @stime, notice: 'Stime was successfully created.' }\n format.json { render :show, status: :created, location: @stime }\n else\n format.html { render :new }\n format.json { render json: @stime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cooking_time = CookingTime.new(cooking_time_params)\n\n respond_to do |format|\n if @cooking_time.save\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cooking_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @appointment_time = AppointmentTime.new(appointment_time_params)\n\n respond_to do |format|\n if @appointment_time.save\n format.html { redirect_to @appointment_time, notice: 'Appointment time was successfully created.' }\n format.json { render :show, status: :created, location: @appointment_time }\n else\n format.html { render :new }\n format.json { render json: @appointment_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @task_time = @task.task_times.build(params[:task_time])\n\n respond_to do |format|\n if @task_time.save\n format.html { redirect_to task_time_path(@task,@task_time), notice: 'Task time was successfully created.' }\n format.json { render json: @task_time, status: :created, location: @task_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tee_time = TeeTime.new(tee_time_params)\n\n respond_to do |format|\n if @tee_time.save\n format.html { redirect_to root_url }\n format.json { render :show, status: :created, location: @tee_time }\n else\n format.html { render :new }\n format.json { render json: @tee_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @time_availalbe = TimeAvailable.new(params[:time_availalbe])\n\n respond_to do |format|\n if @time_availalbe.save\n format.html { redirect_to @time_availalbe, :notice => 'Time Available was successfully created.' }\n format.json { render :json => @time_availalbe, :status => :created, :location => @time_availalbe }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @time_availalbe.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def available_worktimes\n place_id = extract_id(params, :place)\n @place = Place.find_by_id(place_id)\n speciality_id = extract_id(params, :speciality)\n @speciality = Speciality.find_by_id(speciality_id)\n doctor_id = extract_id(params, :doctor)\n @doctor = User.find_by_id(doctor_id)\n @patient = User.find_by_id(params[:patient_id])\n if params[:take_time_into_account]\n # HACK -> parsing parameters\n start = Worktime.new(params[:date_time]).start_date \n else\n start = Date.today.to_date\n end\n @days = [ start.to_date ]\n for i in [1,2,3,4] \n @days << start.to_date + i.day\n end\n respond_to do |format|\n format.html { render :template => \"visit_reservations/available_worktimes\" }\n end\n end",
"def create\n @work_time = WorkTime.new(work_time_params)\n\n respond_to do |format|\n if @work_time.save\n format.html { redirect_to @work_time, notice: 'Work time was successfully created.' }\n format.json { render :show, status: :created, location: @work_time }\n else\n format.html { render :new }\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /stay_times/1 PATCH/PUT /stay_times/1.json | def update
respond_to do |format|
if @stay_time.update(stay_time_params)
format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' }
format.json { render :show, status: :ok, location: @stay_time }
else
format.html { render :edit }
format.json { render json: @stay_time.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @task_time = @task.task_times.find(params[:id])\n\n respond_to do |format|\n if @task_time.update_attributes(params[:task_time])\n format.html { redirect_to task_time_path(@task,@task_time), notice: 'Task time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n if @time_gap.update_attributes(params[:time_gap])\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tummy_time.update(tummy_time_params)\n format.html { redirect_to @tummy_time, notice: 'Tummy time was successfully updated.' }\n format.json { render :show, status: :ok, location: @tummy_time }\n else\n format.html { render :edit }\n format.json { render json: @tummy_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @timekeeping.update(timekeeping_params)\n format.html { redirect_to @timekeeping, notice: 'Timekeeping was successfully updated.' }\n format.json { render :show, status: :ok, location: @timekeeping }\n else\n format.html { render :edit }\n format.json { render json: @timekeeping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @timing = Timing.find(params[:id])\n if @timing.update_attributes(params[:timing].slice(:start, :stop, :days, :active))\n render json: @timing\n else\n render json: { error: 'error: could not update timing' }\n end\n end",
"def update\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n if @meal_time.update_attributes(params[:meal_time])\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cooking_time.update(cooking_time_params)\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meeting_time = MeetingTime.find(params[:id])\n\n respond_to do |format|\n if @meeting_time.update_attributes(params[:meeting_time])\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n if @working_time.update_attributes(params[:working_time])\n format.html { redirect_to time_tables_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shift_time = ShiftTime.find(params[:id])\n\n respond_to do |format|\n if @shift_time.update_attributes(params[:shift_time])\n format.html { redirect_to @shift_time, notice: 'Shift time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shift_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @food_time = FoodTime.find(params[:id])\n\n respond_to do |format|\n if @food_time.update_attributes(params[:food_time])\n format.html { redirect_to @food_time, :notice => 'Food time was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @food_time.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stime.update(stime_params)\n format.html { redirect_to @stime, notice: 'Stime was successfully updated.' }\n format.json { render :show, status: :ok, location: @stime }\n else\n format.html { render :edit }\n format.json { render json: @stime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @meeting_time.update(meeting_time_params)\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @set_time.update(set_time_params)\n format.html { redirect_to @set_time, notice: 'Set time was successfully updated.' }\n format.json { render :show, status: :ok, location: @set_time }\n else\n format.html { render :edit }\n format.json { render json: @set_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opportunity = Opportunity.find(params[:opportunity_id])\n\n respond_to do |format|\n if @opportunity_time.update(opportunity_time_params)\n # format.html { redirect_to @opportunity_time, notice: 'Opportunity time was successfully updated.' } # Original\n format.html { redirect_to @opportunity, notice: 'Opportunity time was successfully updated.' }\n format.json { render :show, status: :ok, location: @opportunity_time }\n else\n format.html { render :edit }\n format.json { render json: @opportunity_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @airtime = Airtime.find(params[:id])\n\n respond_to do |format|\n if @airtime.update_attributes(params[:airtimes])\n format.html { redirect_to @airtime, notice: 'Airtime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @airtime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @meal_time.update(meal_time_params)\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully updated.' }\n format.json { render :show, status: :ok, location: @meal_time }\n else\n format.html { render :edit }\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n if @my_time_trial.update_attributes(params[:my_time_trial])\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /stay_times/1 DELETE /stay_times/1.json | def destroy
@stay_time.destroy
respond_to do |format|
format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @time_gap = TimeGap.find(params[:id])\n @time_gap.destroy\n\n respond_to do |format|\n format.html { redirect_to time_gaps_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food_time = FoodTime.find(params[:id])\n @food_time.destroy\n\n respond_to do |format|\n format.html { redirect_to food_times_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @meal_time = MealTime.find(params[:id])\n @meal_time.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hurdle_time = HurdleTime.find(params[:id])\n @hurdle_time.destroy\n\n respond_to do |format|\n format.html { redirect_to hurdle_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @task_time = @task.task_times.find(params[:id])\n @task_time.destroy\n\n respond_to do |format|\n format.html { redirect_to task_times_url(@task) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @appointment_time.destroy\n respond_to do |format|\n format.html { redirect_to appointment_times_url, notice: 'Appointment time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flight_time.destroy\n respond_to do |format|\n format.html { redirect_to flight_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @staff_time.destroy\n respond_to do |format|\n format.html { redirect_to staff_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tummy_time.destroy\n respond_to do |format|\n format.html { redirect_to tummy_times_url, notice: 'Tummy time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tee_time.destroy\n respond_to do |format|\n format.html { redirect_to root_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @showtime.destroy\n respond_to do |format|\n format.html { redirect_to showtimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal_time.destroy\n respond_to do |format|\n format.html { redirect_to meal_times_url, notice: 'Meal time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_getter.destroy\n respond_to do |format|\n format.html { redirect_to time_getters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timekeeping.destroy\n respond_to do |format|\n format.html { redirect_to timekeepings_url, notice: 'Timekeeping was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cooking_time.destroy\n respond_to do |format|\n format.html { redirect_to cooking_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stime.destroy\n respond_to do |format|\n format.html { redirect_to stimes_url, notice: 'Stime was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bed_time = BedTime.find(params[:id])\n @bed_time.destroy\n\n respond_to do |format|\n format.html { redirect_to bed_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oncall_time = OncallTime.find(params[:id])\n @oncall_time.destroy\n\n respond_to do |format|\n format.html { redirect_to oncall_times_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of open hours grouped by same days | def grouped_open_hours
open_hours = []
start_day = nil
end_day = nil
current_period = nil
standard_hours.sort.each_with_index do |o, i|
if not o.open?
period = "Stengt"
else
period = I18n.l(o.open_time, format: :time) + " - " + I18n.l(o.close_time, format: :time)
end
# Track day
if start_day == nil
start_day = o.day
current_period = period
end
# Previous group ended, add it
if period != current_period
day = I18n.t("days.#{start_day}")
if end_day != nil
day += " - " + I18n.t("days.#{end_day}")
end
# Hverdager custom string
if start_day == "monday" and end_day == "friday"
day = "Hverdager"
end
open_hours.append([day, current_period])
current_period = period
start_day = o.day
end_day = nil
end
# Update period end
if start_day != o.day
end_day = o.day
end
# Last day closes period
if i >= standard_hours.count - 1
day = I18n.t("days.#{start_day}")
if end_day != nil
day += " - " + I18n.t("days.#{o.day}")
end
open_hours.append([day, current_period])
end
end
open_hours
end | [
"def group_days_of_hours\n last_opens_match, last_closes_match, last_closed_match = nil, nil, nil\n matched_days = []\n groups = []\n\n DAYS.each do |day|\n hours = hours_for_day(day)\n if !matched_days.empty? && hours_match(last_closed_match, hours[0], last_opens_match, hours[1], last_closes_match, hours[2])\n matched_days << day\n next\n elsif !matched_days.empty?\n groups << [matched_days, last_closed_match, last_opens_match, last_closes_match]\n end \n\n # Continue on the next iteration with a new value\n matched_days = [day]\n last_closed_match = hours[0]\n last_opens_match, last_closes_match = hours[1], hours[2]\n end\n\n # Catch the last one\n groups << [matched_days, last_closed_match, last_opens_match, last_closes_match]\n\n\n if groups.size > 1\n # Do a little surgery to handle if the end of the week is the same as the start of the week to group them correctly\n g1 = groups[0]\n g2 = groups[groups.size - 1]\n if hours_match(g1[1], g2[1], g1[2], g2[2], g1[3], g2[3]) then\n g3 = groups.pop\n g3[0].reverse_each { |dow| groups[0][0].unshift(dow) }\n end\n\n # Make sure not to display a 'closed' first, because it looks bad\n if groups[0][1] == true then\n first = groups.shift\n groups << first\n end\n\n end\n\n\n return groups\n end",
"def parsed_opening_hours\n @opening_hours ||= opening_hours.group_by(&:weekday).flat_map do |day|\n {\n day[0] => day[1].flat_map do |hour|\n {\n opening: hour.opening,\n closing: hour.closing\n }.reject { |_, v| v.nil? }\n end\n }\n end\n end",
"def grouped_office_hours\n merged_hours.map { |hash_list|\n days = if hash_list.length == 1\n hash_list.first[:day]\n elsif hash_list.length > 1\n \"#{hash_list.first[:day]} - #{hash_list.last[:day]}\"\n end\n {:hours => hash_list.first[:hours],\n :day => days }\n }.delete_if {|hash| hash[:hours].blank? }\n end",
"def opening_hours\n hours = @data[:godziny_pracy]\n keys = {weekdays: :dni_robocze, saturdays: :soboty, sundays: :niedz_i_sw}\n Hash[\n keys.map do |h, x|\n value = unless hours[x].nil?\n [hours[x][:godziny].to_s, hours[x][:uwagi].to_s]\n end\n\n [h, value]\n end\n ]\n end",
"def opening_time_on(day)\n time = day\n hours = nil\n month_times = @times[time.month]\n if month_times.is_a? Hash then\n month_times.each_pair do |days_range, hours_for|\n if days_range.include? time.day then\n hours = hours_for\n break\n end\n end\n else\n hours = month_times\n end\n\n if weekend?(time) and hours != nil and hours.begin < @weekend_open then\n hours = (@weekend_open...hours.end)\n end\n\n return hours\n end",
"def group_by_hour\n group_by { |e| e.timestamp.hour }\n end",
"def available_hours\n available_hours = []\n location.operation_hours.times do |i|\n available_hours << (location.open_at + i.hour).strftime(\"%I:%M %p\")\n end\n return available_hours\n end",
"def day_opening_slots(day_openings)\n available_day_slots = []\n\n day_openings.each do |o|\n (o.starts_at.to_i...o.ends_at.to_i).step(30.minutes) do |slot|\n the_slot = Time.at(slot).utc.to_datetime\n available_day_slots << the_slot unless available_day_slots.include?(the_slot)\n end\n end\n\n available_day_slots\n end",
"def getReleasedHours (openingHour, date)\n releasedHours = []\n tempHour = openingHour.from\n interval = openingHour.company.schedule_interval\n\n # Enquanto o tempHour estiver no intervalo do OpeningHour e o interval for maior que 0 vai incrementando o tempHour\n while tempHour.between?(openingHour.from, openingHour.to) && interval > 0 do\n releasedHours << Time.zone.local(date.year, date.month, date.day, tempHour.hour, tempHour.min, tempHour.sec)\n tempHour += interval\n end\n\n return releasedHours\n end",
"def get_hours_array hours\n hours_array = []\n hours.each { |h| hours_array << h.date }\n return hours_array\n end",
"def each_open_day\n each do |day, times|\n unless times.empty?\n yield day, times\n end\n end\n end",
"def hours_on(date)\n # List of TimeEntry objects\n entries = client.time.all(date.to_time)\n return hours_from_entries(entries)\n end",
"def events_in_day(day)\n days_events = []\n for event in @objects\n if event.starts_at.strftime('%j').to_s == day.strftime('%j').to_s \n if event.starts_at.strftime('%H').to_i >= @start_hour and event.ends_at.strftime('%H').to_i <= @end_hour and event.starts_at.strftime('%H').to_i != 0\n days_events << event\n end\n end\n end\n return days_events\n end",
"def grid\n Date::DAYNAMES.map do |name|\n daily_hours = send(name.downcase)\n HOURS.map do |hour|\n daily_hours.include? hour\n end\n end\n end",
"def open_close_times(date)\n open_close = @open_close[as_string(date)] || @open_close[as_sym(date)] || @default_open_close\n open_close.collect { |h| Time.parse(\"#{as_string(date)} #{h}\") }\n end",
"def early_openers\n data_hash = return_data_hash\n early_open = []\n\n data_hash.each do |uuid, location|\n if location[\"hours\"]\n hours = JSON.parse(location[\"hours\"])\n # checks that Sunday hours exist\n if hours[\"sunday\"] && hours[\"sunday\"][0][0]\n # deletes the \"Saturday night spillover\" hours\n hours[\"sunday\"].delete_at(0) if hours[\"sunday\"].length > 1\n # checks if business is open before 10, or the entire 24 hrs\n if hours[\"sunday\"][0][0].length < 5 || hours[\"sunday\"][0][0] == \"00:00\"\n early_open << {uuid => location}\n end\n end\n end\n end\n\n puts early_open\nend",
"def show_opening_hours(times, formatted_times, event_date)\n result = 'Not Open Today'\n event_day = transformToFourSquareDay(event_date.in_time_zone.wday)\n times.each_with_index do |time, index|\n unless time.days.index(event_day).nil?\n result = formatted_times[index].open[0].renderedTime\n end\n end\n result\n end",
"def trucks_currently_open\n trucks = self.class.get_truck_data\n date = self.class.get_time\n\n trucks_open_now = []\n trucks.each do |truck|\n if date.strftime('%H:%M') <= truck[\"end24\"] && \n date.strftime('%H:%M') > truck[\"start24\"]\n trucks_open_now << truck[\"applicant\"]\n end \n end\n p trucks_open_now\n end",
"def hours\n @hours ||= []\n return @hours if !@hours.empty?\n src['hours'].each{|h| @hours << Stormglass::Hour.new(h) }\n @hours\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /graphium/cities GET /graphium/cities.json | def index
@graphium_cities = Graphium::City.all
end | [
"def cities\n self.class.get(\"/v1/cities\")\n end",
"def cities(country_code)\n request(:get, \"/api/cities?country=#{country_code}\")\n end",
"def index\n \n render json: @cities\n end",
"def city\n fetch('dune.cities')\n end",
"def find_cities\n cities = CS.cities(params[:state_id].to_sym, params[:country_id].to_sym)\n\n respond_to do |format|\n format.json { render json: cities.to_a }\n end\n end",
"def city\n fetch('game_of_thrones.cities')\n end",
"def cities(parameters = {})\n query(:cities, parameters)['geonames']\n end",
"def city\n fetch('fma_brotherhood.cities')\n end",
"def index\n @cities = City.all\n\n render json: @cities\n end",
"def print_city_list\n\n # simply call the print_vertices function of the graph API\n @query.get_graph.each_key { |city| puts \"#{get_city_info(city,\"name\")}\"}\n\n end",
"def show_cities\n\n @cities = City.where(\"country_id = ?\", params[:country_id])\n\n render json: @cities\n \n end",
"def cities\n @companies = Company.distinct.pluck(:city)\n render json: @companies\n end",
"def index\n @api_cities = Api::City.all\n\n render json: @api_cities\n end",
"def cities\n respond_with City.all.as_json(only:[:id, :name])\n end",
"def city\n fetch('parks_and_rec.cities')\n end",
"def cities(country)\n response = client.call(:get_cities_by_country, \n message: { 'CountryName' => country })\n if response.success?\n XMLCitiesParser.new(\n response.body[:get_cities_by_country_response][:get_cities_by_country_result]\n ).to_cities\n end\n end",
"def index\n @served_cities = ServedCity.all\n end",
"def cities_in_region\n render json: City.where(region_id: controller_params).order(:name)\n end",
"def parse_and_add_cities\n\n cities_list = @json_dict['metros'] \n cities_list.each do |city_dict|\n @json_graph_api.add_vertex(city_dict['code'],city_dict)\n @city_to_code[city_dict['name']] = city_dict['code']\n end\n\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /graphium/cities POST /graphium/cities.json | def create
@graphium_city = Graphium::City.new(graphium_city_params)
respond_to do |format|
if @graphium_city.save
format.html { redirect_to @graphium_city, notice: 'City was successfully created.' }
format.json { render :show, status: :created, location: @graphium_city }
else
format.html { render :new }
format.json { render json: @graphium_city.errors, status: :unprocessable_entity }
end
end
end | [
"def parse_and_add_cities\n\n cities_list = @json_dict['metros'] \n cities_list.each do |city_dict|\n @json_graph_api.add_vertex(city_dict['code'],city_dict)\n @city_to_code[city_dict['name']] = city_dict['code']\n end\n\n end",
"def index\n @graphium_cities = Graphium::City.all\n end",
"def create\n @city = City.new(city_params)\n\n if @city.save\n render json: @city, status: :created, location: @city\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def create\n if $cities.key?(@name)\n redirect_to :action => 'view'\n else\n new_city = City.new(\n name: params[:name],\n landmark: params[:landmark],\n population: params[:population],\n )\n new_city.save\n redirect_to :action => 'view'\n end\n end",
"def cities\n self.class.get(\"/v1/cities\")\n end",
"def create\n @api_city = Api::City.new(api_city_params)\n\n if @api_city.save\n render json: @api_city, status: :created, location: @api_city\n else\n render json: @api_city.errors, status: :unprocessable_entity\n end\n end",
"def create\n @city = City.new(city_params)\n\n if @city.save\n render json: @city, status: :created, location: @city\n # 'city model was successfully created.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def index\n \n render json: @cities\n end",
"def store_all_cities(json_obj)\n cities = json_obj['metros'].each{ |city|\n timezone = city['timezone']\n country = city['country']\n name = city['name']\n code = city['code']\n population = city['population']\n continent = city['continent']\n coordinates = city['coordinates']\n region = city['region']\n linked_cities = []\n new_node = Node.new(code,name,country,continent,timezone,coordinates,population,region, linked_cities)\n node_hash[code] = new_node\n continent_hash[continent] << name\n }\n end",
"def create\n @sitecity = Sitecity.new(params[:sitecity])\n\n respond_to do |format|\n if @sitecity.save\n format.html { redirect_to @sitecity, notice: t(:sitecity_create_success) }\n format.json { render json: @sitecity, status: :created, location: @sitecity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sitecity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_city\n\n user = User.find_by(id: params[:id])\n city = City.create(name: params[:name], country: params[:country])\n UserCity.create(user: user, city: city)\n render json: user\n \n end",
"def create\n @city = City.new(params[:city])\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render json: @city, status: :created, location: @city }\n else\n format.html { render action: \"new\" }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @db_city = DbCity.new(db_city_params)\n if @db_city.save\n render json: @db_city\n else\n render json: @db_city.errors, status: :unprocessable_entity\n end\n end",
"def cities(country_code)\n request(:get, \"/api/cities?country=#{country_code}\")\n end",
"def create\n @categories_city = CategoriesCity.new(categories_city_params)\n\n respond_to do |format|\n if @categories_city.save\n format.html { redirect_to @categories_city, notice: 'Categories city was successfully created.' }\n format.json { render :show, status: :created, location: @categories_city }\n else\n format.html { render :new }\n format.json { render json: @categories_city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @indonesia_city = IndonesiaCity.new(indonesia_city_params)\n\n respond_to do |format|\n if @indonesia_city.save\n format.html { redirect_to indonesia_cities_path, notice: 'Kota berhasil dibuat.' }\n format.json { render :show, status: :created, location: @indonesia_city }\n else\n format.html { render :new }\n format.json { render json: @indonesia_city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend",
"def find_cities\n cities = CS.cities(params[:state_id].to_sym, params[:country_id].to_sym)\n\n respond_to do |format|\n format.json { render json: cities.to_a }\n end\n end",
"def create\n @dataele_city = DataeleCity.new(params[:dataele_city])\n\n respond_to do |format|\n if @dataele_city.save\n format.html { redirect_to @dataele_city, notice: 'Dataele city was successfully created.' }\n format.json { render json: @dataele_city, status: :created, location: @dataele_city }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dataele_city.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /graphium/cities/1 PATCH/PUT /graphium/cities/1.json | def update
respond_to do |format|
if @graphium_city.update(graphium_city_params)
format.html { redirect_to @graphium_city, notice: 'City was successfully updated.' }
format.json { render :show, status: :ok, location: @graphium_city }
else
format.html { render :edit }
format.json { render json: @graphium_city.errors, status: :unprocessable_entity }
end
end
end | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @city.update(city_params)\n format.json { head :no_content }\n else\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @city.update(city_params)\n render json: @city\n # 'city was successfully updated.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def update\n @city = City.find(params[:id])\n\n if @city.update(city_params)\n head :no_content\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def update\n @api_city = Api::City.find(params[:id])\n\n if @api_city.update(api_city_params)\n head :no_content\n else\n render json: @api_city.errors, status: :unprocessable_entity\n end\n end",
"def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @major_city.update(major_city_params)\n format.html { redirect_to @major_city, notice: 'Major city was successfully updated.' }\n format.json { render :show, status: :ok, location: @major_city }\n else\n format.html { render :edit }\n format.json { render json: @major_city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put\n request_method('PUT')\n end",
"def update\n respond_to do |format|\n \n if @city.update(:name => city_params[:name].strip, :state_id => city_params[:state_id])\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @graph.update_attributes_from_request(update_params)\n head :no_content\n end",
"def update\n @city = City.find_by_id(params[:id])\n\n respond_to do |format|\n if @city.update_attributes(params[:city])\n format.html { redirect_to @city, notice: t(:city_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:visit][:client] = Client.find(params[:visit][:client].to_i)\n @visit = Visit.find(params[:id])\n\n respond_to do |format|\n if @visit.update_attributes(params[:visit])\n format.html { redirect_to @visit, notice: 'Visit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @visit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ge_city_api.update(ge_city_api_params)\n format.html { redirect_to @ge_city_api, notice: 'Ge city api was successfully updated.' }\n format.json { render :show, status: :ok, location: @ge_city_api }\n else\n format.html { render :edit }\n format.json { render json: @ge_city_api.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @city.update_attributes(params[:city])\n format.html { redirect_to(cities_path, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @city.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_geonode = Admin::Geonode.find(params[:id])\n\n respond_to do |format|\n if @admin_geonode.update_attributes(params[:admin_geonode])\n format.html { redirect_to @admin_geonode, notice: 'Geonode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_geonode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, body, options = {})\n options[:body] = body\n json_request('PUT', path, options)\n end",
"def update_mobile_carrier(args = {}) \n put(\"/mobile.json/#{args[:carrierId]}\", args)\nend",
"def update\n json_update(factType,factType_params, FactType)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /graphium/cities/1 DELETE /graphium/cities/1.json | def destroy
@graphium_city.destroy
respond_to do |format|
format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @api_city.destroy\n\n head :no_content\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_graph(path)\n client(path).delete_graph(service_name(path), section_name(path), graph_name(path))\n end",
"def delete_graph_by_id(id)\n post_query(\"/json/delete/graph/#{id}\")\n end",
"def destroy\n @admin_geonode = Admin::Geonode.find(params[:id])\n @admin_geonode.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_geonodes_url }\n format.json { head :no_content }\n end\n end",
"def datadelete\n\n current_email = current_user.email\n athena_name = current_email[/[^@]+/]\n\n @neo = Neography::Rest.new(ENV['NEO4J_URL'] || \"http://localhost:7474\")\n\n category_name = params[:category]\n\n ret = {:response => \"All good\"}\n\n if category_name == \"living group\" or category_name == \"work\"\n ret = {:response => \"Can't delete living gorup or work categories!\"}\n else\n if params[:name]\n connection_name = params[:name]\n puts \"DELETING CONNECTION TO #{connection_name} IN CATEGORY #{category_name}\"\n @neo.execute_query(\"START n=node(*) MATCH (n)-[r:`#{category_name}`]->(x) WHERE (n.athena ='#{athena_name}' and x.athena='#{connection_name}') DELETE r;\")\n else\n puts \"DELETING CATEGORY #{category_name}\"\n @neo.execute_query(\"START n=node(*) MATCH (n)-[r:`#{category_name}`]->() WHERE n.athena ='#{athena_name}' DELETE r;\")\n end\n end\n \n render :json => ret.to_json\n end",
"def destroy\n @dataele_city = DataeleCity.find(params[:id])\n @dataele_city.destroy\n\n respond_to do |format|\n format.html { redirect_to dataele_cities_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to admin_cities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n\n head :no_content\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to cities_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @sitecity = Sitecity.find_by_url(params[:id])\n @sitecity.destroy\n\n respond_to do |format|\n format.html { redirect_to sitecities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @complex_graph = ComplexGraph.find(params[:id])\n @complex_graph.destroy\n\n respond_to do |format|\n format.html { redirect_to url_for(:controller=>:service, :action => :index) }\n format.json { head :no_content }\n end\n end",
"def delete(path, params={}); make_request(:delete, host, port, path, params); end",
"def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to(countries_url) }\n format.xml { head :ok }\n end\n end",
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Link to kata: Description: Fix the function I created this function to add five to any number that was passed in to it and return the new value. It doesn't throw any errors but it returns the wrong number. Can you help me fix the function? Answer: | def addFive(num)
num + 5
end | [
"def add_five(number)\n number + 5\nend",
"def increaseSum(sum, num)\n return sum += num;\nend",
"def times_three_and_plus_five(number)\n\t\n total = (number * 3) + 5\n puts total\n \nend",
"def round_to_next_5(n)\n n % 5 == 0 ? n : (n/5 + 1) * 5\nend",
"def times_three_and_plus_five(number)\n number * 3 + 5\n end",
"def sum_of_fifth\r\n\tresult = []\r\n\t(2..(5*(9**5))).each do |num| # upper bound is (9^5 + 9^5 + 9^5 + 9^5 + 9^5)\r\n\t\tarry = ((num.to_s).split'').map { |i| i.to_i }\r\n\t\tarry.each_with_index do |dig, idx|\r\n\t\t\tarry[idx] = dig ** 5\r\n\t\tend\r\n\t\tresult.push num if arry.reduce(:+) == num\r\n\tend\r\n\treturn result.reduce(:+)\r\nend",
"def arithmetic1(number)\n return (number*5)-20 \nend",
"def sum_to(n)\n\nend",
"def add_up(integer)\n x = 0\n for i in 1..integer\n x+=i\n end \n puts x\n return x\nend",
"def sum(number)\n if number == 1\n 1\n else\n number + sum(number - 1)\n end\nend",
"def expand5to10(a)\n expd = chainadd(a)\n (a + expd)\n end",
"def multiply_fifteen n\n n * 15\nend",
"def add_up(num)\n\tsum = 0;\n\t(1..num).each { |x| sum += x }\n\tsum\nend",
"def SimpleAdding(num\n total = 1.upto(num).reduce(&:+)\n total \nend",
"def helpful(input)\n puts input\n if input > 5\n return input\n else\n input += 1\n helpful input\n end\nend",
"def f(x)\n\t# TODO change the return value to fix the function\n\tx = (2 +5*x - x**2)/5.0\n\treturn x\nend",
"def plus_one(number)\n number + 1\nend",
"def simple_adding(num)\n 1.upto(num).reduce(:+)\nend",
"def sum(n)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /productors GET /productors.json | def index
@productors = Productor.all
end | [
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def index\n @products = Product.all\n render json: @products\n end",
"def index\n @productos_jsons = ProductosJson.all\n end",
"def get_product_list\n request_path = \"/products\"\n return RestClient.get(@api+request_path)\n end",
"def show\n render json: product, serializer: Api::V1::ProductSerializer\n end",
"def index\n @product_vendors = ProductVendor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_vendors }\n end\n end",
"def show\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end",
"def index\n # @composers = Composer.all\n @composers = @category.composers \n\n render json: @composers \n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventories }\n end\n end",
"def index\n products = @product_search\n .products\n .page(params[:page])\n .per(params[:per_page])\n .records\n\n render json: products, each_serializer: Api::V1::ProductSerializer\n end",
"def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def index\n load_group if products_params[:group_id]\n load_producer if products_params[:producer_id]\n\n products = ProductsCollection.new(group: @group, producer: @producer).relation\n\n render json: ProductsSerializer.new(products)\n end",
"def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end",
"def show\n @supplier = Supplier.find(params[:id])\n @products = Product.where(:supplier_id => @supplier.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @supplier }\n end\n end",
"def index\n @produtors = Produtor.all\n end",
"def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end",
"def index\n @product_managers = ProductManager.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_managers }\n end\n end",
"def index\n @orden_products = OrdenProduct.all\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /productors POST /productors.json | def create
@productor = Productor.new(productor_params)
respond_to do |format|
if @productor.save
format.html { redirect_to @productor, notice: 'Productor was successfully created.' }
format.json { render :show, status: :created, location: @productor }
else
format.html { render :new }
format.json { render json: @productor.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n price: product[:price],\n desc: product[:desc])\n if !@product.save\n render json: @product.errors.full_messages, status: 422\n end\n end\n render 'api/products/index'\n else\n @product = Product.new(product_params)\n if @product.save\n render 'api/products/show'\n else\n render json: @product.errors.full_messages, status: 422\n end\n end\n end",
"def create\n \n @orden_product = OrdenProduct.new(orden_product_params)\n \n respond_to do |format|\n if @orden_product.save\n format.html { redirect_to @orden_product, notice: 'Orden product was successfully created.' }\n format.json { render :show, status: :created, location: @orden_product }\n else\n format.html { render :new }\n format.json { render json: @orden_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @produto = Produto.new(produto_params)\n\n if @produto.save\n render json: @produto, status: :created, location: @produto\n else\n render json: @produto.errors, status: :unprocessable_entity\n end\n end",
"def create\n @creator_product = CreatorProduct.new(creator_product_params)\n\n respond_to do |format|\n if @creator_product.save\n format.html { redirect_to @creator_product, notice: 'Creator product was successfully created.' }\n format.json { render :show, status: :created, location: @creator_product }\n else\n format.html { render :new }\n format.json { render json: @creator_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @productonegocio = Productonegocio.new(params[:productonegocio])\n\n respond_to do |format|\n if @productonegocio.save\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully created.' }\n format.json { render json: @productonegocio, status: :created, location: @productonegocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @productos_json = ProductosJson.new(productos_json_params)\n\n respond_to do |format|\n if @productos_json.save\n format.html { redirect_to @productos_json, notice: 'Productos json was successfully created.' }\n format.json { render action: 'show', status: :created, location: @productos_json }\n else\n format.html { render action: 'new' }\n format.json { render json: @productos_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product_owner = ProductOwner.new(params[:product_owner])\n\n respond_to do |format|\n if @product_owner.save\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully created.' }\n format.json { render json: @product_owner, status: :created, location: @product_owner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product_owner = ProductOwner.new(product_owner_params)\n\n respond_to do |format|\n if @product_owner.save\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully created.' }\n format.json { render :show, status: :created, location: @product_owner }\n else\n format.html { render :new }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @produtor = Produtor.new(produtor_params)\n\n respond_to do |format|\n if @produtor.save\n format.html { redirect_to @produtor, notice: 'Produtor was successfully created.' }\n format.json { render :show, status: :created, location: @produtor }\n else\n format.html { render :new }\n format.json { render json: @produtor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n product = Product.new(params[:product])\n\n if product.save\n response = formatted_response(true, product, t('api.message.catalog.products.create.success'))\n else\n response = formatted_response(false, product.errors, t('api.message.catalog.products.create.failure'))\n end\n\n render :json => response\n end",
"def create\n @product = current_vendor.vendor_products.new(vendor_product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to vendor_products_url, notice: 'product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product_modifier = ProductModifier.new(product_modifier_params)\n\n respond_to do |format|\n if @product_modifier.save\n format.html { redirect_to @product_modifier, notice: 'Product modifier was successfully created.' }\n format.json { render :show, status: :created, location: @product_modifier }\n else\n format.html { render :new }\n format.json { render json: @product_modifier.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @related_product = RelatedProduct.new(params[:related_product])\n\n respond_to do |format|\n if @related_product.save\n format.html { redirect_to @related_product, notice: 'Related product was successfully created.' }\n format.json { render json: @related_product, status: :created, location: @related_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @related_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @producteur = Producteur.new(params[:producteur])\n\n respond_to do |format|\n if @producteur.save\n format.html { redirect_to @producteur, notice: 'Producteur was successfully created.' }\n format.json { render json: @producteur, status: :created, location: @producteur }\n else\n format.html { render action: \"new\" }\n format.json { render json: @producteur.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.json { render json: @product.to_api, status: :created, location: @product }\n format.xml { render xml: @product.to_api, status: :created, location: @product }\n else\n format.json { render json: @product.errors, status: :unprocessable_entity }\n format.xml { render xml: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @establecimiento_producto = EstablecimientoProducto.new(establecimiento_producto_params)\n\n if @establecimiento_producto.save\n render json: @establecimiento_producto, status: :created, location: @establecimiento_producto\n else\n render json: @establecimiento_producto.errors, status: :unprocessable_entity\n end\n end",
"def create\n \n @productos_especiale = current_user.productos_especiales.build(productos_especiale_params)\n\n respond_to do |format|\n if @productos_especiale.save\n format.html { redirect_to @productos_especiale, notice: 'Productos especiale was successfully created.' }\n format.json { render :show, status: :created, location: @productos_especiale }\n else\n format.html { render :new }\n format.json { render json: @productos_especiale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @orden_producto = OrdenProducto.new(orden_producto_params)\n\n respond_to do |format|\n if @orden_producto.save\n format.html { redirect_to @orden_producto, notice: 'Orden producto was successfully created.' }\n format.json { render :show, status: :created, location: @orden_producto }\n else\n format.html { render :new }\n format.json { render json: @orden_producto.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns Allows us to get individual returns from the API | def returns(periodKey)
self.class.get(url("returns", periodKey), headers: @headers )
end | [
"def index\n @returns = Return.all\n end",
"def index\n @returneds = Returned.all\n end",
"def find_returns\n\t\tbus = Bus.find(params[:bus_id])\n\t\t@return_buses = bus.find_returns(params[:dep_id] == '0' ? true : false).select{|rb| (!rb.maximum_seats || rb.available_tickets(params[:dep_id] == '0' ? 'to_waterloo' : 'from_waterloo') > 0) && rb.date == params[:ret_date].to_date}.collect{|rb| [(params[:dep_id] != '0' ? 'UW Campus' : rb.destination.name) + ', ' + ((params[:dep_id] == '0') ? rb.arrive_time.strftime(\"%k:%M\") : rb.depart_time.strftime(\"%k:%M\")), rb.id]}\n\n\t\trender :partial => \"tickets/buying5\"\n\tend",
"def returned(options = {})\n options = { returned_date: Date.current }.merge(options)\n request_params = {\n 'orderID' => order_id,\n 'cartItems' => { 'CartItem' => cart_items.map(&:to_hash) },\n 'returnedDate' => xml_date(options[:returned_date])\n }\n\n response = TaxCloud.client.request :returned, request_params\n TaxCloud::Responses::Returned.parse response\n end",
"def index\n @returns = Return.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @returns }\n end\n end",
"def get_Results()\n \t return @outputs[\"Results\"]\n \tend",
"def index\n @return_details = ReturnDetail.all\n respond_to do |format|\n format.html\n format.json { render :json => @return_details }\n end\n end",
"def returns\n # retrieve logs of type book_return, performed by the current user and apply params filter\n @q = Log.book_return.includes(:book).where(user: current_user).ransack(params[:q])\n # apply pagination to the result above\n @returns = @q.result.paginate(page: params[:page], per_page: 20).order(id: :desc)\n end",
"def returned(options = {})\n options = { :returned_date => Date.today }.merge(options)\n request_params = {\n 'orderID' => order_id,\n 'cartItems' => { 'CartItem' => cart_items.map(&:to_hash) },\n 'returnedDate' => options[:returned_date]\n }.merge(TaxCloud.auth_params)\n\n TaxCloud.client.request :returned, :body => request_params\n end",
"def results\n response.results\n end",
"def list_returns(filter_store_code,\r\n filter_created_at,\r\n filter_status = nil,\r\n sort = nil)\r\n # Prepare query url.\r\n _path_url = '/v2/ecommerce/returns'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'filter[store_code]' => filter_store_code,\r\n 'filter[created_at]' => filter_created_at,\r\n 'filter[status]' => filter_status,\r\n 'sort' => sort\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n OAuth2.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n ListReturnResponse.from_hash(decoded)\r\n end",
"def fetch_data\n resp = HTTParty.get(\"http://data.mtgox.com/api/1/BTCUSD/ticker\")\n buy = resp[\"return\"][\"buy\"][\"display\"]\n sell = resp[\"return\"][\"sell\"][\"display\"]\n \n return {:buy => buy, :sell => sell}\nend",
"def get_post_return_addresses\r\n\r\n # prepare query url\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/post/return-addresses'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare and execute HttpRequest\r\n _request = @http_client.get _query_url\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # validate response against endpoint and global error codes\r\n if _context.response.status_code == 404\r\n return nil\r\n end\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n return _context.response.raw_body\r\n end",
"def index\n @gst_returns = GstReturn.all\n end",
"def get_post_return_addresses\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/post/return-addresses'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def all(options = nil)\n request = Request.new(@client)\n path = \"/invoices\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n a = Array.new\n body = response.body\n for v in body['invoices']\n tmp = Invoice(@client)\n tmp.fill_with_data(v)\n a.push(tmp)\n end\n\n return_values.push(a)\n \n\n \n return_values[0]\n end",
"def return_values\n Calls.new(select(&:returned?))\n end",
"def index\n @return_reasons = ReturnReason.all\n end",
"def get_results\n\n # An internal counter to get the next\n # set of results from the API\n @result_count = 0\n\n # An array into which the API results can\n # be collected\n @results = []\n\n # Get the first set of results from the API\n json_response = self.query\n\n while true\n\n # Exit the loop if the API doesn't return\n # any results and set the \"skip\" attribute\n # to nil\n if json_response['result_count'] == 0\n self.skip= nil\n break\n end\n\n # Add the count of the returned results to the\n # internal result counter's current value\n @result_count += json_response['result_count']\n\n # Append the current results to the results\n # array\n @results << json_response['results']\n\n # Set the \"skip\" attribute to the value\n # on the internal result counter\n self.skip= @result_count\n\n # Get the next set of results from the API\n json_response = self.query\n\n # A simple progress bar\n print \"#\"\n\n end\n\n # Print the total result count to the console\n puts \"\\nFound #{@result_count} results.\"\n\n return @results\n\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this determines the reading order from the stub_object_type (default ltr unless the object type contains one of the possible "rtl" designations) | def book_reading_order
return 'right-to-left' if stub_object_type.include?('rtl') || stub_object_type.include?('r-l')
'left-to-right'
end | [
"def reading_order\n return unless content_md_creation_style == :simple_book\n\n if content_structure == 'simple_book_rtl'\n 'right-to-left'\n else\n 'left-to-right'\n end\n end",
"def reading_direction\n\t return MangaUtils::ReadingDirection::RIGHT_TO_LEFT\n\tend",
"def getRTL()\n return @rtl\n end",
"def language_direction\n \"ltr\"\n end",
"def direction\n # For future reference\n # Hebrew - U+05D0 to U+05EA, U+05F0 to U+05F2, U+05BE, U+05C0, U+05C3, U+05F3, U+05F4, U+05B0 to U+05C4, U+0591 to U+05AF.\n # Arabic - U+0600 to U+06FF, U+0750 to U+077F, U+FB50 to U+FDFF, U+FE70 to U+FEFF, U+10E60 to U+10E7F.\n # ltrChars = 'A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF'+'\\u2C00-\\uFB1C\\uFDFE-\\uFE6F\\uFEFD-\\uFFFF',\n # rtlChars = '\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC',\n\n dir = options[:font][:direction]\n if dir == :auto\n if /[\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC]/.match(text_content)\n 'right-to-left'\n else\n 'left-to-right'\n end\n else\n dir\n end\n end",
"def chosen_direction\n sort_order.direction.to_sym if matching_sort_order?\n end",
"def text_direction\n Archangel.t(\"language.#{locale}.direction\", default: \"ltr\")\n end",
"def read\n obj = @unpacker.read\n case obj\n when Extension::InnerTabulation\n @read[obj.index]\n when Numeric, Symbol, Extension::NotTabulated, true, false, nil\n # not tabulated\n obj\n else\n @read << obj\n obj\n end\n end",
"def set_order_direction\n key = \"#{model.content_key}_order_direction\"\n preferred_direction = preference(key)\n\n @order_direction = if [Outpost::ASCENDING, Outpost::DESCENDING]\n .include?(params[:direction])\n set_preference(key, params[:direction])\n elsif preferred_direction.present?\n preferred_direction\n else\n list.default_order_direction\n end\n end",
"def reverse_chosen_direction\n reverse_sort_order.direction.to_sym if matching_sort_order?\n end",
"def character_order = locale_info(:layout, :orientation, :character_order)",
"def sort_order\n @@reverse_order.include?(ordered_sort_field) ? :reversed : :normal\n end",
"def direction\n # By default, little endian.\n return :little\n end",
"def directionality\n return @directionality\n end",
"def text_direction_css\n rtl_languages = [:he]\n if rtl_languages.include?(I18n.locale.to_sym)\n 'direction-rtl'\n else\n 'direction-ltr'\n end\n end",
"def loadDirection(dir)\n return 1 if dir.nil?\n return 1 if dir.eql(\"asc\")\n return -1\n end",
"def bit_order\n @bit_order ||= parent.respond_to?(:bit_order) ? parent.bit_order : :lsb0\n end",
"def text_direction\n I18n.t(\"languages.#{locale}.direction\", default: 'ltr')\n end",
"def set_direction dir\n return 'ASC' unless dir\n dir == 'ASC' ? 'DESC' : 'ASC'\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /investments GET /investments.json | def index
@investments = Investment.all
respond_to do |format|
format.html
format.json
end
end | [
"def index\n @investments = Investment.all\n\n render json: {investments: @investments}, root: false\n end",
"def index\n @investments = Investment.all\n end",
"def show\n @investment = Investment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investment }\n end\n end",
"def index\n @invests = Invest.all\n end",
"def list\n return @master.call :get, 'investigations.json'\n end",
"def index\n @investables = Investable.all\n end",
"def details(investment_id)\n API::request(:get, \"investments/#{investment_id}\")\n end",
"def index\n @me_investments = Me::Investment.all\n end",
"def index\n @investigations = Investigation.where(:visible => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @investigations }\n end\n end",
"def index\n @add_investments = AddInvestment.all\n end",
"def index\n @investors = Investor.all\n end",
"def show\n @investor = Investor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investor }\n end\n end",
"def index\n @investment_funds = InvestmentFund.all\n end",
"def index\n @investment_plans = (current_user) ? current_user.investment_plans : []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @investment_plans }\n end\n end",
"def find_investigations(options = {})\n validate_investigation_options options\n path = build_path '/investigation', options, investigation_paths\n params = build_params options, investigation_params\n get_resource path, params, options\n end",
"def index\n @investigates = Investigate.all\n end",
"def show\n @investment_type = InvestmentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investment_type }\n end\n end",
"def investment_payments(investment_id)\n API::request(:get, \"investments/#{investment_id}/investment_payments\")\n end",
"def index\n @api_v1_establishments = Establishment.all\n render json: @api_v1_establishments\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Record has a fixed barcode length | def shift_barcode_length
return unless record.barcode_length
shift_fixed_length(record.barcode_length)
end | [
"def determine_record_length(record_length)\n\n sans_size = TAR_CHUNK_SIZE-1\n\n if(record_length % TAR_CHUNK_SIZE != 0)\n record_length = (record_length + sans_size) & ~sans_size;\n end\n return record_length\n end",
"def barcode_validation(new_barcode)\n if new_barcode.to_s.length == 13\n control_sum_13(new_barcode)\n elsif new_barcode.to_s.length == 8\n control_sum_8(new_barcode)\n else\n false\n end\n end",
"def generate_barcode\n end",
"def barcode\n str_order = order.id.to_s.rjust(5, '0')\n str_cardinality = 1.to_s.rjust(3, '0')\n str_order + str_cardinality\n end",
"def barcode\n self.barcode = \"#{self.part_no}\" + \"-\" + \"#{self.start}\" + \"-\" + \"#{self.finish}\" + \"-\" + \"#{self.card_index}\"\n end",
"def get_barcode_content\n barcode_content = pad_number(self.client_id) + '-' + pad_number(self.client.serial_number)\n # increment the serial by one\n self.client.serial_number += 1\n barcode_content\n end",
"def is_corrected_barcode?(barcode_id, is)\n is != barcode_id && is.length != 4 && is.length != 8\n end",
"def recordSize\n @Length\n end",
"def width\n barcode.encoding.length * xdim\n end",
"def typeable_line(barcode=\"\")\n return nil unless (barcode =~ /^[0-9]{44}$/) && barcode.size == 44\n\n campo_1_a = \"#{barcode[0..3]}\"\n campo_1_b = \"#{barcode[19..23]}\"\n dv_1 = self.module10(\"#{campo_1_a}#{campo_1_b}\")\n campo_1_dv = \"#{campo_1_a}#{campo_1_b}#{dv_1}\"\n campo_linha_1 = \"#{campo_1_dv[0..4]}.#{campo_1_dv[5..9]}\"\n\n campo_2 = \"#{barcode[24..33]}\"\n dv_2 = self.module10(campo_2)\n campo_2_dv = \"#{campo_2}#{dv_2}\"\n campo_linha_2 = \"#{campo_2_dv[0..4]}.#{campo_2_dv[5..10]}\"\n\n campo_3 = \"#{barcode[34..43]}\"\n dv_3 = self.module10(campo_3)\n campo_3_dv = \"#{campo_3}#{dv_3}\"\n campo_linha_3 = \"#{campo_3_dv[0..4]}.#{campo_3_dv[5..10]}\"\n\n campo_linha_4 = \"#{barcode[4..4]}\"\n\n campo_linha_5 = \"#{barcode[5..18]}\"\n\n linha = \"#{campo_linha_1} #{campo_linha_2} #{campo_linha_3} #{campo_linha_4} #{campo_linha_5}\"\n\n return linha\n end",
"def data520\n max_length = 1879\n @thesis.abstract&.each_line do |line|\n # skip any blank lines. Mostly if multiple linebreaks were added to the text.\n next if line.strip.empty?\n\n # if the line length is valid for 520, add it\n if line.length < max_length\n @record.append(MARC::DataField.new(\n '520', '3', ' ',\n ['a', line.encode(options: :xml).strip]\n ))\n # split lines that remain too long into valid size strings\n else\n part = line.chars.to_a.each_slice(max_length).map(&:join)\n part.each do |part_line|\n @record.append(MARC::DataField.new(\n '520', '3', ' ',\n ['a', part_line.encode(options: :xml).strip]\n ))\n end\n end\n end\n end",
"def returnWidth\n ## 4 byte signed integer\n isWidth ? @RecordData[0] : UNKNOWN\n end",
"def barcode\n return if not_registered\n barcode_string.to_i(2)\n end",
"def pad_length\n offset = (lp_value_name.abs_offset + lp_value_name.to_binary_s.length) % 4\n (4 - offset) % 4\n end",
"def padded_width; end",
"def isWidth\n @RecordType == WIDTH\n end",
"def barcode\n (0..(11..17).to_a.sample).map{(0..9).to_a.sample}.join\n end",
"def barcode=(v)\n @barcode = alma_string v\n end",
"def coded_width\n @data[:coded_width]\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines the public IP address of the running AWS instance | def determine_public_ip
# 169.254.169.254 is the address of the AWS instance metadata service
# See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
`curl --silent -XGET http://169.254.169.254/latest/meta-data/public-ipv4`
end | [
"def aws_instance_ip\n `curl --silent -XGET http://169.254.169.254/latest/meta-data/local-ipv4`\n end",
"def my_public_ip\n if @my_public_ip\n @my_public_ip\n else\n #Use AWS instance data if available\n ip = `curl -s http://instance-data/latest/meta-data/public-ipv4`.chomp\n ip = nil unless $?.exitstatus == 0\n\n unless ip\n #Use DNS\n ip = `dig +short +tries=1 -4 myip.opendns.com @resolver1.opendns.com`.chomp\n ip = nil unless $?.exitstatus == 0 #Might be set to an error message if command failed\n end\n\n unless ip\n #Use 3rd party IP echo service\n ip = `curl -s http://ipecho.net/plain`.chomp\n ip = nil unless $?.exitstatus == 0\n end\n\n raise 'Could not get the public IP of the current machine' if ip.nil?\n\n @my_public_ip = ip\n end\n end",
"def public_ip_address(host)\n if host[\"hypervisor\"] == \"ec2\"\n curl_on(host, \"http://169.254.169.254/latest/meta-data/public-ipv4\").stdout.chomp\n else\n host.ip\n end\nend",
"def public_ip_address\n @instance.public_ip_address\n end",
"def get_public_ip\n case host_hash[:hypervisor]\n when /^(ec2|openstack)$/\n if self[:hypervisor] == 'ec2' && self[:instance]\n return self[:instance].ip_address\n elsif self[:hypervisor] == 'openstack' && self[:ip]\n return self[:ip]\n elsif self.instance_of?(Windows::Host)\n # In the case of using ec2 instances with the --no-provision flag, the ec2\n # instance object does not exist and we should just use the curl endpoint\n # specified here:\n # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html\n execute(\"wget http://169.254.169.254/latest/meta-data/public-ipv4\").strip\n else\n execute(\"curl http://169.254.169.254/latest/meta-data/public-ipv4\").strip\n end\n end\n end",
"def instance_ip_address(instance)\n @ec2.describe_instances(\n instance_ids: [instance],\n filters: [{ name: 'tag:aws:autoscaling:groupName', values: [@name] }]\n )\n .reservations[0].instances[0].public_ip_address\n end",
"def public_ip_address\n public_ip_addresses.first\n end",
"def public_ip_address\n ipv4_address\n end",
"def public_ip_address\n return @public_ip_address\n end",
"def public_ipv4\n return ec2_meta_data('public-ipv4')\n end",
"def public_ip\n get('tools/public_ip').body['ipv4'] || get('tools/public_ip').body['ipv6']\n end",
"def public_ip_of(server)\n server[:cloud][:public_ips].first rescue server[:ipaddress]\n end",
"def public_ip\n nodes.first.public_ip\n end",
"def get_public_ip_address\n rpc_get_fact_direct('public_ip')\n end",
"def fetch_public_ip(environment)\n if environment.load_balancer_ip_address\n return environment.load_balancer_ip_address\n end\n\n if environment.instances.length == 1 && environment.instances.first.public_hostname\n return environment.instances.first.public_hostname\n end\n\n warn \"#{environment.account.name}/#{environment.name} has no assigned public IP address or hostname.\"\n nil\n end",
"def is_public_ip(ec2,ip)\n return ec2.instances.filter('public-ip-address', ip) \n end",
"def acquire_ip_address\n unless public_ip = provider.provision_public_ip_address(vpc: vpc?)\n say \"Unable to acquire a public IP. Please check your account for capacity or service issues.\".red\n exit 1\n end\n public_ip\n end",
"def fetch_public_ip(instance_id)\n while true do\n desc = @@ec2.describe_instances({\n instance_ids: [instance_id]\n })\n ipaddr = desc.reservations[0].instances[0].public_ip_address\n if (IPAddress.valid? ipaddr)\n return ipaddr\n end\n sleep 5\n yield\n end\n end",
"def local_ip\n ip_address = nil\n\n if @options[:use_ec2_metadata_flag]\n ip_address = ec2_instance_metadata_local_ip\n end\n\n unless ip_address.nil? or valid_ip?(ip_address)\n ip_address = hostname_resolve_ip\n end\n\n unless valid_ip?(ip_address)\n ip_address = '0.0.0.0'\n end\n\n ip_address\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add host in the specified groups. ==== Attributes +host+ Hostname +groups+ Groups to assign ==== Examples add_groups('pa2web01', ['local', 'web']) add_groups('pa2sql01', ['local', 'mysql', 'heartbeat']) | def add_groups(host, groups=[])
for group in groups
if !GROUPS.key?(group) then
GROUPS[group] = []
end
GROUPS[group].push(host)
end
end | [
"def add_host_to_group(host_id, group_id)\n message = {\n 'method' => 'hostgroup.massAdd',\n 'params' => {\n 'groups' => [ {'groupid' => group_id} ],\n 'hosts' => [ {'hostid' => host_id} ]\n }\n }\n\n group_request(message)\n end",
"def add_host(data)\n result = @client.api_request(\n :method => \"hostgroup.massAdd\", \n :params => {\n :groups => [{:groupid => data[:groupid]}],\n :hosts => data[:hostids].map { |h| {:hostid => h} }\n }\n )\n result ? result['groupids'][0].to_i : nil\n end",
"def host(host, *groups)\n raise ArgumentError, \"host #{host} has no group\" if groups.empty?\n groups.each { |name| group(name, host) }\n end",
"def add_group(group, server_name = nil)\n addr_group = session.railgun.util.alloc_and_write_wstring(group)\n # https://docs.microsoft.com/zh-cn/windows/win32/api/lmaccess/ns-lmaccess-group_info_1\n # Set up the GROUP_INFO_1 structure.\n group_info_1 = [\n addr_group,\n 0x0\n ].pack(client.arch == ARCH_X86 ? \"VV\" : \"QQ\")\n result = client.railgun.netapi32.NetGroupAdd(server_name, 1, group_info_1, 4)\n client.railgun.multi([\n [\"kernel32\", \"VirtualFree\", [addr_group, 0, MEM_RELEASE]], # addr_group\n ])\n return result\n end",
"def add(group)\r\n @groupList.push(group)\r\n end",
"def add_group()\n group_name = @conf_group_name_text.get_value\n group_values = @conf_group_values_text.get_value\n\n group_values = expand_ranges(group_values)\n begin\n errval = nil\n group_values.each do |val|\n $attr[:groups].each_value do |arr|\n if arr.include?(val)\n errval = val\n fail\n end\n end\n end\n rescue RuntimeError\n MessageDialog.new(self, \"Value #{errval} is already in use by another group!\",\n \"Error Creating Group\", OK).show_modal\n return\n end\n $attr[:groups][group_name] = group_values\n write_groups()\n end",
"def add_group(group, gid=nil)\n\t\t\tend",
"def add_group( group )\n type_check( group, Elements::Group )\n assert( !name_defined?(name), \"name [#{name}] is already in use\" )\n \n @groups[group.name] = group\n end",
"def add_group(group, gid=nil)\n\t\t\t\tCfruby.controller.attempt(\"Adding group \\\"#{group}\\\"\", 'destructive') {\n\t\t\t\t\t# Only add the group if it's not already there\n\t\t\t\t\tif !group?(group)\n\t\t\t\t\t\tif(gid == nil)\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}'`\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}' -g #{gid.to_i()}`\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend",
"def add_hosts_group\n puppet_ip = any_hosts_as?(:loadbalancer) ? loadbalancer.ip : master.ip\n hosts_group = {\n \"name\" => \"Clamps Managed Hosts\",\n \"rule\" => [\"or\", [\"=\", %w[fact id], \"root\"]],\n \"parent\" => pe_infra_uuid,\n \"classes\" => {\n \"hosts\" => {\n \"purge_hosts\" => false,\n \"collect_all\" => true,\n \"host_entries\" => {\n \"puppet\" => { \"ip\" => puppet_ip }\n }\n }\n }\n }\n\n dispatcher.find_or_create_node_group_model(hosts_group)\nend",
"def createhostgroup(a,zbx)\n hostgroups = zbx.hostgroups.get_full_data(:name => \"#{a}\")\n if hostgroups.empty?\n zbx.hostgroups.create(:name => \"#{a}\")\n end\n end",
"def group(which, *args)\n which = which.to_sym\n\n # The groups Hash is defined so that unrecognized keys always auto-initialize\n # to a new Group instance (see the assignment in the initialize_with_groups method,\n # above). However, we explicitly assign here so that group declarations will\n # vivify the group object even if there are no host arguments. (Otherwise,\n # group(:app) won't actually instantiate a Group object for :app.)\n $hosts[which] ||= []\n args.each { |host| $hosts[which] << host }\n end",
"def add_group (db, name)\n\tdb.execute(\"INSERT INTO groups (name) VALUES (?)\", [name])\nend",
"def add_group( group )\n raise TypeError.new('not a group') unless group.is_a?(Ecore::Group)\n tmp_group_ids = self.group_ids.split(',')\n tmp_group_ids.delete(group.id)\n tmp_group_ids << group.id\n self.group_ids = tmp_group_ids.join(',')\n true\n end",
"def addUser name, pass, mail, site = \"\", *groupnames\n groupnames = groupnames.flatten\n userGroup = Modeles::Group.find_by_name name\n if userGroup.nil?\n userGroup = Modeles::Group.new :name => name\n else\n return nil\n end\n groups = [ userGroup ]\n groupnames.flatten.each do |groupname|\n group = Modeles::Group.find_by_name groupname\n if group.nil?\n group = Modeles::Group.new :name => groupname\n end\n groups << group\n end\n isAdmin = 0\n isAdmin = 1 if groupnames.include? \"root\" or name == \"root\"\n user = Modeles::User.new(:name => name, :pass => pass,\n :email => mail,\n :website => site,\n :isAdmin => isAdmin)\n user.groups = groups\n ret = user.save\n if ret\n UserInfos.new user\n end\n end",
"def add_ad_groups(campaign_id, ad_groups)\n\t\t\t\n\t\t\tgroups = []\n\t\t\tif ad_groups.is_a? Array\n\t\t\t\tgroups = ad_groups.map{ |gr| gr.to_hash(:camelcase) }\n\t\t\telsif ad_groups.is_a? BingAdsApi::AdGroup\n\t\t\t\tgroups = ad_groups.to_hash\n\t\t\telse \n\t\t\t\traise \"ad_groups must be an array of BingAdsApi::AdGroup\"\n\t\t\tend\n\t\t\tmessage = {\n\t\t\t\t:campaign_id => campaign_id, \n\t\t\t\t:ad_groups => {:ad_group => groups} }\n\t\t\tputs message\n\t\t\tresponse = call(:add_ad_groups, message)\n\t\t\treturn get_response_hash(response, __method__)\n\t\tend",
"def add_ad_groups(campaign_id, ad_groups)\n\n\t\t\tgroups = []\n\t\t\tif ad_groups.is_a? Array\n\t\t\t\tgroups = ad_groups.map{ |gr| gr.to_hash(:camelcase) }\n\t\t\telsif ad_groups.is_a? BingAdsApi::AdGroup\n\t\t\t\tgroups = ad_groups.to_hash\n\t\t\telse\n\t\t\t\traise \"ad_groups must be an array of BingAdsApi::AdGroup\"\n\t\t\tend\n\t\t\tmessage = {\n\t\t\t\t:campaign_id => campaign_id,\n\t\t\t\t:ad_groups => {:ad_group => groups} }\n\t\t\tresponse = call(:add_ad_groups, message)\n\t\t\treturn get_response_hash(response, __method__)\n\t\tend",
"def add_group(group_id)\n\t\t\n\t\t# ADD ERROR CHECKING HERE FOR INVALID GROUP -> TEST\n\n\t\tself.group_list |= [group_id]\n\t\tself.update_attribute(:group_list, self.group_list)\n\t\t\n\tend",
"def add_node_group( node, group )\n node_obj = self.get_node_obj( node )\n group = group.to_a\n \n # verify that group(s) exists in dashboard\n group.each do |g|\n unless NodeGroup.find_by_name(g)\n return \"SKIPPED: #{node_obj.name}. No group found for #{g}\"\n end\n end\n \n # obtaining dasboard group objects \n my_groups = []\n group.each { |n| my_groups << self.get_group_obj(n) }\n \n node_obj.node_groups = my_groups\n begin\n node_obj.save!\n return \"#{node_obj.name} added to group(s) #{group.inspect}\"\n rescue Exception => e\n return \"FAILED to add #{node_obj.name} to #{group.inspect} group: #{e.message}\"\n end\n \n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add disk to the virtual machine ==== Attributes +server+ Server object +size+ Disk size in bytes ==== Examples add_disk(server, 5) Add a 5GB disk add_disk(server, 10) Add a 10GB disk | def add_disk(server, size)
host = server.to_s
# Increment disk id
if !DISKS.key?(host) then
DISKS[host] = 0
else
DISKS[host] += 1
end
disk_id = DISKS[host]
disk_filename = ".vagrant/disks/" + host + "_" + disk_id.to_s + ".vdi"
server.vm.provider "virtualbox" do |v|
# Create disk if it not exist
unless File.exist?(disk)
v.customize ["createhd", "--filename", disk_filename, "--size", size * 1024 * 1024]
end
v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', disk_id, '--device', 0, '--type', 'hdd', '--medium', disk]
end
end | [
"def add_hdd_to_vbox_vm(client_name,vbox_disk_name)\n message = \"Attaching:\\tStorage to VM \"+client_name\n command = \"VBoxManage storageattach \\\"#{client_name}\\\" --storagectl \\\"#{$vbox_disk_type}\\\" --port 0 --device 0 --type hdd --medium \\\"#{vbox_disk_name}\\\"\"\n execute_command(message,command)\n return\nend",
"def attach_disk(path)\n\t\tmanage('storageattach', @name, '--storagectl', 'SATA', '--port', '1',\n\t\t\t'--type', 'hdd', '--medium', path)\n\tend",
"def add_disk(options={})\n fail \"Please provide a datastore\" unless options[:datastore].is_a? RbVmomi::VIM::Datastore\n\n ds = options[:datastore]\n file = options[:file]\n controller = options[:controller]\n controller ||= \"SCSI controller 0\"\n file_path = options[:file_path]\n\n if file_path.nil?\n file_path = ds.find_file_path(file)\n end\n\n full_file_path = \"[#{ds.info.name}] #{file_path}#{file}\"\n\n disk_backing_info = RbVmomi::VIM::VirtualDiskFlatVer2BackingInfo.new( :datastore => ds, \n :fileName => full_file_path, \n :diskMode => \"persistent\")\n\n vm_controllers = self.controllers\n\n vm_controller = nil\n vm_controllers.each { |c| vm_controller = c if c.deviceInfo.label == controller }\n fail \"Could not find Virtual Controller #{controller}\" if vm_controller.nil?\n\n # Because the unit number starts at 0, count will return the next value we can use\n unit_number = vm_controller.device.count\n\n capacityKb = ds.get_file_info(file).capacityKb\n disk = RbVmomi::VIM::VirtualDisk.new(:controllerKey => vm_controller.key, \n :unitNumber => unit_number,\n :key => -1,\n :backing => disk_backing_info,\n :capacityInKB => capacityKb)\n dev_spec = RbVmomi::VIM::VirtualDeviceConfigSpec.new( :operation => RbVmomi::VIM::VirtualDeviceConfigSpecOperation.new('add'),\n :device => disk)\n vm_spec = RbVmomi::VIM::VirtualMachineConfigSpec.new( :deviceChange => [*dev_spec] )\n\n puts \"Reconfiguring #{self.name} to add VMDK: #{full_file_path}\"\n self.ReconfigVM_Task( :spec => vm_spec ).wait_for_completion\n end",
"def attach_disk(disk)\n # Adding a new disk in newer vSphere versions\n # automatically cleans all system snapshots\n # https://github.com/OpenNebula/one/issues/5409\n if snapshots? || one_snapshots?\n error_msg = 'Existing sytem snapshots, cannot change disks. '\n error_msg << 'Please remove all snapshots and try again'\n raise error_msg\n end\n\n spec_hash = {}\n device_change = []\n\n # Extract unmanaged_keys\n unmanaged_keys = disk_keys\n vc_disks = vcenter_disks_get\n\n # Check if we're dealing with a StoragePod SYSTEM ds\n storpod = disk['VCENTER_DS_REF'].start_with?('group-')\n\n # Check if disk being attached is already connected to the VM\n raise 'DISK is already connected to VM' if disk_attached_to_vm(\n disk, unmanaged_keys, vc_disks\n )\n\n # Generate vCenter spec and reconfigure VM\n add_spec = calculate_add_disk_spec(disk)\n device_change << add_spec\n raise 'Could not generate DISK spec' if device_change.empty?\n\n extra_key = \"opennebula.mdisk.#{disk['DISK_ID']}\"\n extra_value = add_spec[:device].key.to_s\n\n spec_hash[:deviceChange] = device_change\n spec_hash[:extraConfig] =\n [{ :key => extra_key, :value => extra_value }]\n spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash)\n\n begin\n if storpod\n # Ask for StorageDRS recommendation\n # to reconfigure VM (AddDisk)\n sm = storagemanager\n\n # Disk id is -1 as I don't know\n # what disk id is going to be set\n disk_locator = [RbVmomi::VIM.PodDiskLocator(:diskId => -1)]\n\n # Disk locator is required for AddDisk\n vmpod_hash = {}\n vmpod_hash[:storagePod] = get_ds\n vmpod_hash[:disk] = disk_locator\n vmpod_config =\n RbVmomi::VIM::VmPodConfigForPlacement(\n vmpod_hash\n )\n\n # The storage pod selection requires initialize\n spod_hash = {}\n spod_hash[:initialVmConfig] = [vmpod_config]\n spod_select =\n RbVmomi::VIM::StorageDrsPodSelectionSpec(\n spod_hash\n )\n storage_spec = RbVmomi::VIM.StoragePlacementSpec(\n :type => :reconfigure,\n :podSelectionSpec => spod_select,\n :vm => self['_ref'],\n :configSpec => spec\n )\n\n # Query a storage placement recommendation\n result = sm\n .RecommendDatastores(\n :storageSpec => storage_spec\n ) rescue nil\n\n if result.nil?\n raise 'Could not get placement '\\\n 'specification for StoragePod'\n end\n\n if !result.respond_to?(:recommendations) ||\n result.recommendations.empty?\n raise 'Could not get placement '\\\n 'specification for StoragePod'\n end\n\n # Get recommendation key to be applied\n key = result.recommendations.first.key ||= ''\n\n if key.empty?\n raise 'Missing Datastore recommendation for StoragePod'\n end\n\n # Apply recommendation\n sm.ApplyStorageDrsRecommendation_Task(\n :key => [key]\n ).wait_for_completion\n\n # Add the key for the volatile disk to the\n # unmanaged opennebula.disk.id variables\n unit_number =\n spec_hash[:deviceChange][0][:device]\n .unitNumber\n controller_key =\n spec_hash[:deviceChange][0][:device]\n .controllerKey\n key =\n get_vcenter_disk_key(\n unit_number,\n controller_key\n )\n spec_hash = {}\n reference = {}\n reference[:key] =\n \"opennebula.disk.#{disk['DISK_ID']}\"\n reference[:value] = key.to_s\n spec_hash[:extraConfig] = [reference]\n @item\n .ReconfigVM_Task(\n :spec => spec_hash\n ).wait_for_completion\n else\n @item\n .ReconfigVM_Task(\n :spec => spec\n ).wait_for_completion\n end\n # Modify extraConfig if disks has a bad key\n sync_extraconfig_disk(spec_hash)\n rescue StandardError => e\n error = \"Cannot attach DISK to VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n end",
"def addDisk(backingFile, sizeInMB, label = nil, summary = nil, options = {})\n # Remove nil keys if any, since the next line may not work\n options.reject! { |_k, v| v.nil? }\n # Merge default values:\n # - persistent is set to true to be backward compatible\n # - thin_provisioned is set to false explicitly since we call to_s on it further, so nil will not work for us\n options = {:persistent => true, :thin_provisioned => false}.merge(options)\n ck, un = available_scsi_units.first\n raise \"addDisk: no SCSI controller found\" unless ck\n\n vmConfigSpec = VimHash.new(\"VirtualMachineConfigSpec\") do |vmcs|\n vmcs.deviceChange = VimArray.new(\"ArrayOfVirtualDeviceConfigSpec\") do |vmcs_vca|\n vmcs_vca << VimHash.new(\"VirtualDeviceConfigSpec\") do |vdcs|\n vdcs.operation = VirtualDeviceConfigSpecOperation::Add\n if sizeInMB < 0\n sizeInMB = -sizeInMB\n else\n vdcs.fileOperation = VirtualDeviceConfigSpecFileOperation::Create\n end\n vdcs.device = VimHash.new(\"VirtualDisk\") do |vDev|\n vDev.key = -100 # temp key for creation\n vDev.capacityInKB = sizeInMB * 1024\n vDev.controllerKey = ck\n vDev.unitNumber = un\n # The following doesn't seem to work.\n vDev.deviceInfo = VimHash.new(\"Description\") do |desc|\n desc.label = label\n desc.summary = summary\n end if label || summary\n vDev.connectable = VimHash.new(\"VirtualDeviceConnectInfo\") do |con|\n con.allowGuestControl = \"false\"\n con.startConnected = \"true\"\n con.connected = \"true\"\n end\n if options[:dependent]\n mode = (options[:persistent] ? VirtualDiskMode::Persistent : VirtualDiskMode::Nonpersistent)\n else\n mode = (options[:persistent] ? VirtualDiskMode::Independent_persistent : VirtualDiskMode::Independent_nonpersistent)\n end\n vDev.backing = VimHash.new(\"VirtualDiskFlatVer2BackingInfo\") do |bck|\n bck.diskMode = mode\n bck.split = \"false\"\n bck.thinProvisioned = options[:thin_provisioned].to_s\n bck.writeThrough = \"false\"\n bck.fileName = backingFile\n begin\n dsn = @invObj.path2dsName(@dsPath)\n bck.datastore = @invObj.dsName2mo_local(dsn)\n rescue\n bck.datastore = nil\n end\n end\n end\n end\n end\n end\n\n logger.info \"MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: calling reconfigVM_Task\"\n taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)\n logger.info \"MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: returned from reconfigVM_Task\"\n waitForTask(taskMor)\n end",
"def attach_disk\n # TODO position? and disk size for volatile?\n\n spec_hash = {}\n disk = nil\n device_change = []\n\n # Extract unmanaged_keys\n unmanaged_keys = get_unmanaged_keys\n vc_disks = get_vcenter_disks\n\n # Extract disk from driver action\n disk = one_item.retrieve_xmlelements(\"TEMPLATE/DISK[ATTACH='YES']\").first\n\n # Check if we're dealing with a StoragePod SYSTEM ds\n storpod = disk[\"VCENTER_DS_REF\"].start_with?('group-')\n\n # Check if disk being attached is already connected to the VM\n raise \"DISK is already connected to VM\" if disk_attached_to_vm(disk, unmanaged_keys, vc_disks)\n\n # Generate vCenter spec and reconfigure VM\n device_change << calculate_add_disk_spec(disk)\n raise \"Could not generate DISK spec\" if device_change.empty?\n\n spec_hash[:deviceChange] = device_change\n spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash)\n\n begin\n if storpod\n #Ask for StorageDRS recommendation to reconfigure VM (AddDisk)\n sm = get_sm\n\n # Disk id is -1 as I don't know what disk id is going to be set\n disk_locator = [ RbVmomi::VIM.PodDiskLocator(diskId: -1) ]\n\n # Disk locator is required for AddDisk\n vmpod_hash = {}\n vmpod_hash[:storagePod] = get_ds\n vmpod_hash[:disk] = disk_locator\n vmpod_config = RbVmomi::VIM::VmPodConfigForPlacement(vmpod_hash)\n\n # The storage pod selection requires initialize\n spod_hash = {}\n spod_hash[:initialVmConfig] = [ vmpod_config ]\n spod_select = RbVmomi::VIM::StorageDrsPodSelectionSpec(spod_hash)\n storage_spec = RbVmomi::VIM.StoragePlacementSpec(\n type: :reconfigure,\n podSelectionSpec: spod_select,\n vm: self['_ref'],\n configSpec: spec\n )\n\n # Query a storage placement recommendation\n result = sm.RecommendDatastores(storageSpec: storage_spec) rescue nil\n\n raise \"Could not get placement specification for StoragePod\" if result.nil?\n\n if !result.respond_to?(:recommendations) || result.recommendations.size == 0\n raise \"Could not get placement specification for StoragePod\"\n end\n\n # Get recommendation key to be applied\n key = result.recommendations.first.key ||= ''\n raise \"Missing Datastore recommendation for StoragePod\" if key.empty?\n\n # Apply recommendation\n sm.ApplyStorageDrsRecommendation_Task(key: [key]).wait_for_completion\n\n # Add the key for the volatile disk to the unmanaged opennebula.disk.id variables\n unit_number = spec_hash[:deviceChange][0][:device].unitNumber\n controller_key = spec_hash[:deviceChange][0][:device].controllerKey\n key = get_vcenter_disk_key(unit_number, controller_key)\n spec_hash = {}\n reference = {}\n reference[:key] = \"opennebula.disk.#{disk[\"DISK_ID\"]}\"\n reference[:value] = key.to_s\n spec_hash[:extraConfig] = [ reference ]\n @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion\n else\n @item.ReconfigVM_Task(:spec => spec).wait_for_completion\n end\n rescue Exception => e\n raise \"Cannot attach DISK to VM: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n end\n end",
"def add_vm_disks(vm_service, disk_specs)\n storage_spec = disk_specs[:storage]\n attachments_service = vm_service.disk_attachments_service\n disk_specs[:disks].each do |disk_spec|\n attachment = prepare_vm_disk_attachment(disk_spec, storage_spec)\n attachments_service.add(attachment)\n end\n end",
"def add_vm_disks(vm_service, disk_specs)\n storage_spec = disk_specs[:storage]\n default_disk_spec = disk_specs[:default] || {}\n attachments_service = vm_service.disk_attachments_service\n disk_specs[:disks].each do |disk_spec|\n attachment = prepare_vm_disk_attachment(default_disk_spec.merge(disk_spec), storage_spec)\n attachments_service.add(attachment)\n end\n end",
"def add_hdd_to_vm(host_name,disk_type,disk_name)\n command = \"VBoxManage storageattach \\\"#{host_name}\\\" --storagectl \\\"#{disk_type}\\\" --port 0 --device 0 --type hdd --medium \\\"#{disk_name}\\\"\"\n if $verbose == 1\n puts \"Executing: #{command}\"\n end\n system(\"#{command}\")\n return\nend",
"def add_hdd_to_vbox_vm(options)\n message = \"Information:\\tAttaching storage \\\"#{options['disk']}\\\" of type \\\"#{defaults['controller']}\\\" to VM \"+options['name']\n command = \"#{options['vboxmanage']} storageattach \\\"#{options['name']}\\\" --storagectl \\\"#{defaults['controller']}\\\" --port 0 --device 0 --type hdd --medium \\\"#{options['disk']}\\\"\"\n execute_command(options,message,command)\n return\nend",
"def configure_disks(vb, server, hostname, name)\n vminfo = vm_info(name)\n disks = server['disks'] || {}\n unless vminfo =~ /Storage Controller Name \\(1\\): *SATA Controller/\n # puts \"Attaching SATA Controller\"\n vb.customize [\n 'storagectl', :id,\n '--name', 'SATA Controller',\n '--add', 'sata',\n '--portcount', disks.size\n ]\n # else\n # puts 'SATA Controller already attached'\n end\n\n disks.each_with_index do |disk, i|\n disk_name = disk.first\n disk_size = disk.last['size']\n disk_uuid = disk.last['uuid']\n real_uuid = \"00000000-0000-0000-0000-#{disk_uuid.rjust(12,'0')}\"\n if server['cluster']\n disk_filename = File.join(VAGRANT_ROOT, \"#{disk_name}_#{server['cluster']}.vdi\")\n else\n disk_filename = File.join(VAGRANT_ROOT, \"#{disk_name}.vdi\")\n end\n\n if File.file?(disk_filename)\n # puts \"Disk #{disk_filename} already created\"\n disk_hash = `VBoxManage showmediuminfo \"#{disk_filename}\"`.scan(/(.*): *(.*)/).to_h\n current_uuid = disk_hash['UUID']\n else\n # puts \"Creating disk #{disk_filename}\"\n current_uuid = '0'\n if server['cluster']\n vb.customize [\n 'createhd',\n '--filename', disk_filename,\n '--size', disk_size.to_s,\n '--variant', 'Fixed'\n ]\n vb.customize [\n 'modifyhd', disk_filename,\n '--type', 'shareable'\n ]\n else\n vb.customize [\n 'createhd',\n '--filename', disk_filename,\n '--size', disk_size.to_s,\n '--variant', 'Standard'\n ]\n end\n end\n\n # Conditional for adding disk_uuid\n if server['cluster'] && current_uuid == real_uuid\n # puts \"Attaching shareable disk #{disk_filename}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename,\n '--mtype', 'shareable'\n ]\n elsif server['cluster']\n # puts \"Attaching shareable disk #{disk_filename}, adding UUID #{real_uuid}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename,\n '--mtype', 'shareable',\n '--setuuid', real_uuid\n ]\n elsif current_uuid == real_uuid\n # puts \"Attaching normal disk #{disk_filename}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename\n ]\n else\n # puts \"Attaching normal disk #{disk_filename}, adding UUID #{real_uuid}\"\n vb.customize [\n 'storageattach', :id,\n '--storagectl', 'SATA Controller',\n '--port', (i + 1).to_s,\n '--device', 0,\n '--type', 'hdd',\n '--medium', disk_filename,\n '--setuuid', real_uuid\n ]\n end\n end\nend",
"def provision_and_mount_volume(server, disk_size, device)\n unless provider.find_server_device(server, device)\n say \"Provisioning #{disk_size}Gb persistent disk for inception VM...\"\n provider.create_and_attach_volume(\"Inception Disk\", disk_size, server, device)\n end\n\n # Format and mount the volume\n if aws?\n say \"Skipping volume mounting on AWS 12.10 inception VM until its fixed\", [:yellow, :bold]\n run_ssh_command_until_successful server, \"sudo mkdir -p /var/vcap/store\"\n else\n say \"Mounting persistent disk as volume on inception VM...\"\n run_ssh_command_until_successful server, \"sudo mkfs.ext4 #{device} -F\"\n run_ssh_command_until_successful server, \"sudo mkdir -p /var/vcap/store\"\n run_ssh_command_until_successful server, \"sudo mount #{device} /var/vcap/store\"\n end\n end",
"def create_vbox_hdd(client_name,vbox_disk_name)\n message = \"Creating:\\tVM hard disk for \"+client_name\n command = \"VBoxManage createhd --filename \\\"#{vbox_disk_name}\\\" --size \\\"#{$default_vm_size}\\\"\"\n execute_command(message,command)\n return\nend",
"def add_data_disk(vm_name, cloud_service_name, options = {})\n options[:import] ||= false\n vm = get_virtual_machine(vm_name, cloud_service_name)\n if vm\n path = \"/services/hostedservices/#{cloud_service_name}/deployments/#{vm.deployment_name}/roles/#{vm_name}/DataDisks\"\n body = Serialization.add_data_disk_to_xml(vm, options)\n Azure::Loggerx.info \"Adding data disk to virtual machine #{vm_name} ...\"\n request = client.management_request(:post, path, body: body)\n request.call\n else\n Azure::Loggerx.error \"Cannot find virtual machine \\\"#{vm_name}\\\" under cloud service \\\"#{cloud_service_name}\\\".\"\n end\n end",
"def attach_disk_to_vm(vm)\n begin\n start_time = Time.now.to_i\n OOLog.info(\"Attaching Storage disk ....\")\n vm_promise = @compute_client.virtual_machines.create_or_update(@rg_name, @instance_name, vm)\n my_vm = vm_promise.value!\n end_time = Time.now.to_i\n duration = end_time - start_time\n OOLog.info(\"Storage Disk attached #{duration} seconds\")\n OOLog.info(\"VM: #{my_vm.body.name} UPDATED!!!\")\n return true\n rescue MsRestAzure::AzureOperationError =>e\n OOLog.debug( e.body.inspect)\n if e.body.to_s =~ /InvalidParameter/ && e.body.to_s =~ /already exists/\n OOLog.debug(\"The disk is already attached\")\n else\n OOLog.fatal(e.body)\n end\n rescue MsRestAzure::CloudErrorData =>e\n OOLog.fatal(e.body.message)\n rescue Exception => ex\n OOLog.fatal(ex.message)\n end\n end",
"def attach_volumes!(server, volumes, size)\n #create a new blockstorage connection obj\n block_storage = Fog::Rackspace::BlockStorage.new(\n {\n :rackspace_username => @rackspace_username,\n :rackspace_api_key => @rackspace_api_key\n }\n )\n base = 'sdd'\n volumes.times do |i|\n base = base.next!\n #create a new volume\n vol = block_storage.volumes.new(:size => size, :display_name => \"#{server.name}#{i}\")\n vol.save\n #wait for the volume to get created\n vol.wait_for { ready? }\n #attach the volume to the instance provided\n server.attach_volume(vol, \"/dev/#{base}\")\n #wait until the attaching process is complete\n vol.wait_for { attached? }\n end\n end",
"def attach_disk(opts, disk_name, instance_id)\n Djinn.log_debug('Calling attach_disk with parameters ' \\\n \"#{opts.inspect}, with disk name #{disk_name} and instance id \" +\n instance_id.to_s)\n\n # Make a copy (the options are a simple hash so shallow copy does the\n # trick) to not modify the original.\n options = opts.clone\n options['instance_id'] = instance_id\n options['disk_name'] = disk_name\n\n uri = URI(\"http://#{@ip}:#{SERVER_PORT}/instance\")\n headers = {'Content-Type' => 'application/json',\n 'AppScale-Secret' => @secret}\n request = Net::HTTP::Post.new(uri.path, headers)\n\n request.body = JSON.dump(options)\n\n return JSON.parse(make_call(request, uri))['location']\n end",
"def attach_volumes!(server, volumes_count, size)\n #create a new block storage connection obj\n volume_service = Fog::Volume::OpenStack.new(\n :openstack_api_key => @os_password,\n :openstack_username => @os_username,\n :openstack_auth_url => @os_auth_url,\n :openstack_tenant => @os_tenant,\n )\n base = 'sdd'\n volumes_count.times do |i|\n base = base.next!\n #create a new volume\n vol = volume_service.volumes.create(\n :size => size,\n :display_name => \"#{server.name}-#{i}\",\n :description => \"Volume attached to #{server.name} - managed by ankus\"\n )\n vol.reload\n vol.wait_for { status == 'available' }\n server.attach_volume(vol.id, \"/dev/#{base}\")\n vol.wait_for { status == 'in-use' }\n end\n end",
"def attach_to_server server, device, mount\n account.post '/component_ec2_ebs_volumes', :body => {\n :component_ec2_ebs_volume => {\n :ec2_ebs_volume_href => uri,\n :component_href => server.href,\n :device => device,\n :mount => mount\n }\n }\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /membership_contributions GET /membership_contributions.json | def index
@membership_contributions = MembershipContribution.all
end | [
"def contributions_made\n render json: @user.contributions\n end",
"def get_contributions(repository)\n Git.contributions GithubAPI.name(@username), repository\n end",
"def index\r\n @contributions = @person.contributions\r\n end",
"def month_contributions\r\n # Query contributions only if not already done\r\n @contribs ||= @leaderboard.member_contributions(@username)\r\n end",
"def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contributions }\n end\n end",
"def fetch_memberships(token, params)\n params.to_options!\n \n # Setup params.\n setup_params_logic = lambda do |last_request, params|\n # Do nothing.\n end\n \n # Parse the response.\n response_parse_logic = lambda do |response| \n content_keys = {}\n doc = Nokogiri::XML(response.body)\n \n doc.xpath(\"/memberships/membership\").each do |mem|\n id = mem.search('id').first.inner_html\n content_keys[id] = mem.to_s\n end\n content_keys\n end\n \n url = format_project_url(get_api_url('memberships'), params[:project_id])\n fetch(::PivotalTracker::Membership, token, url, \n response_parse_logic, setup_params_logic, false)\n end",
"def GetMemberships params = {}\n\n params = params.merge(path: 'group_memberships.json')\n APICall(params)\n\n end",
"def contribution(project)\n \tcontributions.find_by(participation: participation(project))\n end",
"def shared_contributions\n Contribution.find(:all,\n :select => \"contributions.*\",\n :joins => \"JOIN policies p on (contributions.policy_id = p.id) JOIN permissions e on (p.id = e.policy_id)\",\n :conditions => [ \"e.contributor_id=? AND e.contributor_type = 'Network'\", id ])\n end",
"def index\n @memberships = Membership.where(user_id: current_user_id)\n users_projects = User.find(current_user_id).projects\n users_projects.each do |project|\n @memberships = (@memberships + Membership.where(project_id: project.id))\n end\n\n json_response(@memberships.uniq)\n end",
"def display_contributions(repo_full_name)\n repo = Commitchamp::Repo.find_by(full_name: repo_full_name)\n contributors = repo.contributions.order('additions + deletions + commits DESC').limit(10)\n puts \"\\n##Contributions for '#{repo.full_name}'\"\n puts \"\\nUsername | Additions | Deletions | Commits\"\n contributors.each do |x|\n puts \"#{x.user.login} | #{x.additions} | #{x.deletions} | #{x.commits}\"\n end\n puts\n end",
"def index\n @monetary_contributions = MonetaryContribution.all\n end",
"def contributions\n respond_to do |format|\n format.html { redirect_to contributions_path }\n format.xml {\n # TODO : make an xml export : a finder +\n # render :xml => @issues.to_xml should be enough)\n }\n format.ods { compute_contributions(:ods) }\n end\n end",
"def contributions_as_hash\n load_contributions unless @contributions\n @contributions\n end",
"def index\n @contributions = Contribution.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contributions }\n end\n end",
"def index\n @memberships = current_user.memberships.order('memberships.created_at DESC').limit(10)\n @memberships = @memberships.project_prefix(params[:query]) if params[:query].present?\n # as much as i'd love to add includes(:project), it breaks the join in project_prefix.\n # go ahead, try it and see.\n\n render json: decorate(@memberships)\n end",
"def update\n respond_to do |format|\n if @membership_contribution.update(membership_contribution_params)\n format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @membership_contribution }\n else\n format.html { render :edit }\n format.json { render json: @membership_contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contributions }\n end\n end",
"def shared_contributions\n list = []\n self.permissions.each do |p|\n p.policy.contributions.each do |c|\n list << c unless c.nil? || c.contributable.nil?\n end\n end\n list\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /membership_contributions POST /membership_contributions.json | def create
# byebug
@membership_contribution = MembershipContribution.new(membership_contribution_params)
@membership = MembershipBalance.find_by(params[:membership_id])
respond_to do |format|
if @membership_contribution.save
@a = MembershipContribution.all.last
# @balance = MembershipBalance.find(params)
@amount1 = @membership.balance + @a.amount
@b = MembershipBalance.where(membership_id: @a.membership_id).update_all(balance: @amount1)
format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully created.' }
format.json { render :show, status: :created, location: @membership_contribution }
else
format.html { render :new }
format.json { render json: @membership_contribution.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @contribution = current_user.contributions.build(contribution_params)\n respond_to do |format|\n \n if @contribution.save\n format.html { redirect_to contributions_path, notice: '新規投稿が完了しました。' }\n format.json { render :show, status: :created, location: @contribution }\n else\n format.html { render :new }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contributions_made\n render json: @user.contributions\n end",
"def index\n @membership_contributions = MembershipContribution.all\n end",
"def create\n @user_contribution = UserContribution.new(user_contribution_params)\n\n respond_to do |format|\n if @user_contribution.save\n format.html { redirect_to @user_contribution, notice: 'User contribution was successfully created.' }\n format.json { render :show, status: :created, location: @user_contribution }\n else\n format.html { render :new }\n format.json { render json: @user_contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render json: @contribution, status: :created, location: @contribution }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @membership = Adhocracy::Membership.new(membership_params)\n\n if @membership.save\n render json: @membership, status: :created, location: api_v1_membership_path(@membership)\n else\n render_validation_errors @membership.errors\n end\n end",
"def create\n logger.info \"Post parameters memberships: #{params}\"\n @membership = @group.memberships.create(user: @user, admin: params[:membership][:admin] )\n if @membership.save\n render json: @membership, status: :created, location: [@group, @membership]\n else\n render json: @membership.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @membership_contribution.update(membership_contribution_params)\n format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @membership_contribution }\n else\n format.html { render :edit }\n format.json { render json: @membership_contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def month_contributions\r\n # Query contributions only if not already done\r\n @contribs ||= @leaderboard.member_contributions(@username)\r\n end",
"def create_contribution\n\n @initiative = Initiative.find(contribution_params[:initiative_id])\n @gateways = @initiative.gateways.without_state(:draft).ordered\n @contribution = @initiative.contributions.new(contribution_params)\n @contribution.gateway_state = @contribution.gateway.state\n current_user.update module_name: @contribution.gateway.module_name\n authorize @contribution\n\n if @contribution.save\n true\n else\n render '/initiatives/contributions/new'\n false\n end\n\n end",
"def createContributions(eventContributions)\n eventContributions.each do |contribution|\n contributor = User.find_by_email(contribution[1][\"email\"])\n contributor.setContribution!(self, contribution[1][\"amount\"], contribution[1][\"paid\"])\n end\n end",
"def create\r\n @contribution = Contribution.new(contribution_params)\r\n @contribution.contributable_type = \"Book\"\r\n @contribution.person = @person\r\n\r\n respond_to do |format|\r\n if @contribution.save\r\n format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: person_contributions_path(@contribution) }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @project = Project.find_by_permalink(params[:project_id])\n @project_membership = @project.project_memberships.build(params[:project_membership])\n\n respond_to do |format|\n if @project_membership.save\n format.html { redirect_to @project, notice: 'Project membership was successfully created.' }\n format.json { render json: @project, status: :created, location: @project_membership }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project_membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_contribution(expense, amount)\n contribution = ExpenseContribution.new(:amount => amount)\n contribution.user = self\n contribution.expense = expense\n contribution.save!\n contribution\n end",
"def create\n @contributo = Contributo.new(params[:contributo])\n\n respond_to do |format|\n if @richiedente.contributi << @contributo\n format.html { redirect_to richiedente_url(@richiedente), notice: 'Contributo was successfully created.' }\n format.json { render json: @contributo, status: :created, location: @contributo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contributo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.find(params[:course_id])\n @assignment = Assignment.find(params[:assignment_id])\n # Every upload is a complete team designations\n @assignment.memberships(true).each do |membership|\n if !membership.destroy\n puts \"Not destroyed: \" + membership.inspect\n end\n end\n params[:response][:teams].split(\"\\r\\n\" ).each{ |line|\n add_teammate(line.split(',').map{|s| clean_csv_item(s)})\n }\n\n @course.get_real_students.each do |student|\n if !@assignment.memberships(true).any?{|membership| membership.user_id == student.id }\n multi_flash(:notice, 'Student(s) without a team: ', student.email)\n end\n end\n\n\n respond_to do |format|\n format.html { redirect_to course_assignment_memberships_path(@course,@assignment) }\n format.json { render json: @membership, status: :created, location: @membership }\n end\n end",
"def add_contribution(expense, amount)\n contribution = ExpenseContribution.new(amount: amount)\n contribution.user = self\n contribution.expense = expense\n contribution.save!\n contribution\n end",
"def create\n if params[:membership][:user_username]\n params[:membership][:user_id] = User.find_by_username(params[:membership].delete('user_username')).try!(:id)\n end\n\n @membership = @project.memberships.create(membership_params)\n respond_with @project, @membership\n end",
"def create\n @membership = Membership.new(membership_params.merge(board_id: @board.id))\n authorize @membership\n @membership.save!\n json_response(@membership, :created)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /membership_contributions/1 PATCH/PUT /membership_contributions/1.json | def update
respond_to do |format|
if @membership_contribution.update(membership_contribution_params)
format.html { redirect_to @membership_contribution, notice: 'Membership contribution was successfully updated.' }
format.json { render :show, status: :ok, location: @membership_contribution }
else
format.html { render :edit }
format.json { render json: @membership_contribution.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @membership.update_attributes membership_params\n respond_with @membership, location: edit_project_my_membership_url(@project)\n end",
"def update\n logger.info('PATCH Contribution JSON: ')\n logger.info(request_body)\n\n params = hashed_request\n if params[:cap_profile_id].blank? && params[:sul_author_id].blank?\n log_and_error! \"The request is missing 'sul_author_id' and 'cap_profile_id'.\", :bad_request\n return\n end\n author = params[:cap_profile_id] ? get_cap_author!(params[:cap_profile_id]) : get_sul_author!(params[:sul_author_id])\n return unless author # can't find the author\n return unless author_id_consistent?(author, params[:cap_profile_id]) # ids aren't consistent\n\n if params[:sul_pub_id].blank?\n render json: { error: 'You have not supplied the publication identifier sul_pub_id' }, status: :bad_request,\n format: :json\n return\n end\n\n # Find an existing contribution by author/publication\n contributions = Contribution.where(\n author_id: author.id,\n publication_id: params[:sul_pub_id]\n )\n if contributions.empty?\n log_and_error!(\"SULCAP has no contributions by the author:#{author.id} for the publication:#{params[:sul_pub_id]}\")\n return\n elsif contributions.length > 1\n # Hitting this block of code should be a cause for concern, bad internal data\n log_and_error!(\n \"SULCAP has multiple contributions by the author:#{author.id} for the publication:#{params[:sul_pub_id]}\", :internal_server_error\n )\n return\n end\n pub = contributions.first.publication\n\n unless pub\n # Also a cause for concern, bad internal data\n log_and_error!('No publication found', :internal_server_error)\n return\n end\n\n # We've now got the contribution, gather the new attributes. In a PATCH\n # request, it's OK if some of them are missing; validate only the\n # fields provided. When check for 'featured', use .nil? because it\n # is allowed to have a `false` value.\n unless !contrib_attr[:featured].nil? || contrib_attr[:status].present? || contrib_attr[:visibility].present?\n render json: { error: \"At least one authorship attribute is required: 'featured', 'status', 'visibility'.\" },\n status: :not_acceptable, format: :json\n return\n end\n\n pub_hash = create_or_update_and_return_pub_hash(pub, author, contrib_attr)\n return unless pub_hash\n\n render json: pub_hash.to_json, format: :json, status: :accepted\n end",
"def update\n if @membership.update(membership_params)\n render json: @membership, status: :ok\n else\n render json: @membership.errors, status: :unprocessable_entity\n end\n end",
"def update\n @membership = @group.memberships.find(params[:id])\n if @membership.update_attributes(params[:membership])\n head :no_content\n else\n render json: @membership.errors, status: :unprocessable_entity\n end\n end",
"def update\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n if @contribution.update_attributes(params[:contribution])\n format.html { redirect_to @contribution, notice: 'Contribution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contribution.update(params[:contribution])\n format.html { redirect_to @contribution, notice: 'Contribution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contribution.update(contribution_params)\n format.html { redirect_to contributions_url}\n format.json { render :show, status: :ok, location: @contribution }\n else\n format.html { render :edit }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contribution.update(contribution_params)\n format.html { redirect_to @contribution, notice: 'Contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @contribution }\n else\n format.html { render :edit }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_contributo = TipoContributo.find(params[:id])\n\n respond_to do |format|\n if @tipo_contributo.update_attributes(params[:tipo_contributo])\n format.html { redirect_to @tipo_contributo, notice: 'Tipo contributo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_contributo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contributo = @richiedente.contributi.find(params[:id])\n\n respond_to do |format|\n if @contributo.update_attributes(params[:contributo])\n format.html { redirect_to @richiedente, notice: 'Contributo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contributo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @membership ||= Membership.find(params[:id])\n\n respond_to do |format|\n if @membership.update_attributes(params[:membership])\n format.html { redirect_to @membership, notice: 'Membership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_contribution.update(user_contribution_params)\n format.html { redirect_to @user_contribution, notice: 'User contribution was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_contribution }\n else\n format.html { render :edit }\n format.json { render json: @user_contribution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n if @contribution.update_attributes(params[:contribution])\n flash[:notice] = 'Contribution was successfully updated.'\n format.html { redirect_to contribution_url(@contribution) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contribution.errors.to_xml }\n end\n end\n end",
"def update\n @contribution = Contribution.find(params[:id])\n\n respond_to do |format|\n if @contribution.update_attributes(params[:contribution])\n flash[:notice] = 'Contribution was successfully updated.'\n format.html { redirect_to(@contribution) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contribution.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @research_group_membership.update(research_group_membership_params)\n format.html { redirect_to @research_group_membership, notice: 'Research group membership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @research_group_membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contribute.update(contribute_params)\n format.html { redirect_to @contribute, notice: 'Contribute was successfully updated.' }\n format.json { render :show, status: :ok, location: @contribute }\n else\n format.html { render :edit }\n format.json { render json: @contribute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stato_contributo = StatoContributo.find(params[:id])\n\n respond_to do |format|\n if @stato_contributo.update_attributes(params[:stato_contributo])\n format.html { redirect_to @stato_contributo, notice: 'Stato contributo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stato_contributo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tribal_membership.update(tribal_membership_params)\n format.html { redirect_to @tribal_membership, notice: 'Tribal membership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tribal_membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contribution_group = ContributionGroup.find(params[:id])\n\n respond_to do |format|\n if @contribution_group.update_attributes(params[:contribution_group])\n format.html { redirect_to @contribution_group, notice: 'Contribution group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contribution_group.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /membership_contributions/1 DELETE /membership_contributions/1.json | def destroy
@membership_contribution.destroy
respond_to do |format|
format.html { redirect_to membership_contributions_url, notice: 'Membership contribution was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @api_v1_contribution.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_contributions_url, notice: 'Contribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contribution.destroy\n respond_to do |format|\n format.html { redirect_to project_contributions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contribution = Contribution.find(params[:id])\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to contributions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n head :no_content\n end",
"def destroy\n @membership.destroy\n\n head :no_content\n end",
"def destroy\n @mat_membership.destroy\n respond_to do |format|\n format.html { redirect_to mat_memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to(contributions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contribution = Contribution.find(params[:id])\n @contribution.destroy\n\n respond_to do |format|\n format.html { redirect_to(contributions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @research_group_membership.destroy\n respond_to do |format|\n format.html { redirect_to research_group_memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oa_membership = OA_Membership.find(params[:id])\n @oa_membership.destroy\n\n respond_to do |format|\n format.html { redirect_to oa_memberships_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to @user }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mission_membership.destroy\n respond_to do |format|\n format.html { redirect_to mission_memberships_url, notice: 'Mission membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contributo = Contributo.find(params[:id])\n @contributo.destroy\n\n respond_to do |format|\n format.html { redirect_to contributi_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_contribution.destroy\n respond_to do |format|\n format.html { redirect_to user_contributions_url, notice: 'User contribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tribal_membership.destroy\n respond_to do |format|\n format.html { redirect_to tribal_memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @students_project_membership.destroy\n respond_to do |format|\n format.html { redirect_to students_project_memberships_url, notice: 'Students project membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stato_contributo = StatoContributo.find(params[:id])\n @stato_contributo.destroy\n\n respond_to do |format|\n format.html { redirect_to stati_contributo_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course_membership = CourseMembership.find(params[:id])\n @course_membership.destroy\n\n respond_to do |format|\n format.html { redirect_to course_memberships_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return booking request list where your user ID is equal to the client ID on the booking = Requests you've made on spaces. | def my_booking_requests
my_booking_requests = CONNECTION.exec("SELECT id FROM bookings WHERE client_id='#{@user_id}'")
return my_booking_requests
end | [
"def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend",
"def make_bookings\n remove_bad_booking_requests.map do |data|\n request = data, row = data[1], seats = data[2]..data[4] \n seats.select do |seat| \n invalid_seat_request(row,seat,request) \n book_seat(row,seat)\n end \n end \n end",
"def index\n @booking_requests = BookingRequest.all\n end",
"def recieved_requests\n FriendshipRequest.where(\"requested_user_id = ?\", id)\n end",
"def manage_bookings\n @userId = UserService.find_user session[:user]\n @util = Util.new\n @RoomList = []\n @BookingList = {}\n @ListOfBuildings = BuildingService.find_all()\n @ListOfBuildings.each { |b|\n rooms = RoomService.find_all_in_building(b)\n @RoomList << [b, rooms]\n }\n @num_users = UserService.all_library_users.length\n # Create a booking list, which is a hash. The key has booking time and the value is booking\n @RoomList.each {|item|\n item[1].each {|room|\n bookings = BookingService.all_bookings_for_room(room)\n bookings.each {|booking|\n @BookingList[\"#{room.id}:#{booking.day}:#{booking.start_time}\"] = booking\n }\n }\n }\n end",
"def book\n outbound_itineraries = booking_request_params\n\n # Keep track if anything failed and then cancel all the itineraries ####\n failed = false\n itins = []\n #########################################################################\n\n responses = booking_request_params.map do |booking_request|\n # Find the itinerary identified in the booking request\n itin = Itinerary.find_by(id: booking_request.delete(:itinerary_id))\n itin.try(:select) # Select the itinerary so that the return trip can be built properly\n booking_request[:itinerary] = itin\n next booking_request unless itin\n \n # If a return_time param was passed, build a return itinerary\n return_time = booking_request.delete(:return_time).try(:to_datetime)\n if return_time\n return_itin = ReturnTripPlanner.new(itin.trip, {trip_time: return_time})\n .plan.try(:selected_itinerary)\n return_booking_request = booking_request.clone.merge({itinerary: return_itin, return: true})\n next [booking_request, return_booking_request]\n else\n next booking_request\n end\n end.flatten.compact # flatten into an array of booking requests\n .map do |booking_request|\n # Pull the itinerary out of the booking_request hash and set up a\n # default (failure) booking response\n itin = booking_request.delete(:itinerary) \n itins << itin \n\n response = booking_response_base(itin).merge({booked: false})\n \n # BOOK THE ITINERARY, selecting it and storing the response in a booking object\n if itin.booked?\n # This itinerary has already been booked. Don't book it again.\n next response.merge(booking_response_hash(itin.booking))\n end\n\n booking = itin.try(:book, booking_options: booking_request)\n unless booking.is_a?(Booking)\n failed = true\n next response \n end\n\n # Ensure that the confirmation is not blank\n if booking.confirmation.blank?\n failed = true\n next response \n end\n #next response unless booking.is_a?(Booking) # Return failure response unless book was successful\n\n # Update Trip Disposition Status to ecolane succeeded\n itin.trip.update(disposition_status: Trip::DISPOSITION_STATUSES[:ecolane_booked])\n # Package it in a response hash as per API V1 docs\n next response.merge(booking_response_hash(booking))\n end\n \n # If any of the itineraries failed, cancel them all and return failures\n if failed \n responses = []\n itins.each do |itin|\n itin.booked? ? itin.cancel : itin.unselect\n\n # Update Trip Disposition Status with ecolane denied if it failed\n itin.trip.update(disposition_status: Trip::DISPOSITION_STATUSES[:ecolane_denied])\n responses << booking_response_base(itin).merge({booked: false})\n end\n render status: 500, json: {booking_results: responses}\n else\n render status: 200, json: {booking_results: responses}\n end\n\n end",
"def owner_request_ids\n Request.by_owner.pluck(:id).sort\n end",
"def list\n @bookings = Booking.all.find(:hotel_id == params[:bookings_for_hotel])\n @bookings = Booking.all.find(:conditions => [\"hotel_id = ? \", params[:bookings_for_hotel]])\n @bookings = Booking.find_by_hotel_id_and_bookings_for_hotel(hotel_id, params[:bookings_for_hotel])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def bookings_open_for_user(user)\n bookings_open = []\n # All Attendees for User where User has accepted:\n attendees_user_accepted = Attendee.where(user: user, accepted: true)\n\n if attendees_user_accepted.count != 0\n # Create array of Bookings if Booking for that restaurant and Booking open\n attendees_user_accepted.each do |attendee|\n if attendee.booking.open == true\n bookings_open << attendee.booking\n end\n end\n end\n return bookings_open\n end",
"def deletependingbooking(user)\n body = JSON.parse(HTTParty.get('https://firestore.googleapis.com/v1beta1/projects/'+ENV[\"FIREBASE\"]+'/databases/(default)/documents/bookings').body)\n list = body[\"documents\"]\n\n for el in list\n # pending booking\n if el[\"fields\"][\"user\"][\"stringValue\"] == user.email and el[\"fields\"][\"active\"][\"booleanValue\"]\n name = el[\"name\"]\n city = el[\"fields\"][\"city\"][\"stringValue\"]\n park = el[\"fields\"][\"park\"][\"stringValue\"]\n lockHash = el[\"fields\"][\"lockHash\"][\"stringValue\"]\n\n # free locker\n new_body = JSON.parse(HTTParty.get('https://firestore.googleapis.com/v1beta1/projects/'+ENV[\"FIREBASE\"]+'/databases/(default)/documents/cities/'+hash_code(city).to_s+'/parks/'+hash_code(city+park).to_s+'/lockers/'+lockHash).body)\n \n new_body.delete(\"createTime\") #useless field\n new_body.delete(\"updateTime\") #useless field\n new_body[\"fields\"][\"user\"][\"stringValue\"] = '\"\"'\n new_body[\"fields\"][\"available\"][\"booleanValue\"] = true\n new_body[\"fields\"][\"open\"][\"booleanValue\"] = false\n \n HTTParty.patch('https://firestore.googleapis.com/v1beta1/projects/'+ENV[\"FIREBASE\"]+'/databases/(default)/documents/cities/'+hash_code(city).to_s+'/parks/'+hash_code(city+park).to_s+'/lockers/'+lockHash, \n body: JSON.generate(new_body), headers: {\"Content-Type\": \"application/json\"} )\n\n # delete booking\n HTTParty.delete('https://firestore.googleapis.com/v1beta1/'+name)\n end\n end\n end",
"def create_booking\n @userId = UserService.find_user session[:user]\n @BookingList = {}\n @room = Room.find(params[:id])\n bookings = BookingService.current_bookings_for_room(@room)\n bookings.each {|booking|\n @BookingList[\"#{@room.id}:#{booking.day}:#{booking.start_time}\"] = booking\n }\n @util = Util.new\n end",
"def request_reservation\n result = PrioTicket::API.call(request_body, identifier)\n parse_result(result)\n end",
"def requestBook(usrID, params)\n completed = false\n \n requestID = 1\n date = Time.now.strftime(\"%Y%m%d\").to_i\n \n @req.execute(\"\n SELECT requestID FROM bookRequests ORDER BY requestID DESC LIMIT 1\n \") do |x|\n requestID += x[0]\n end\n \n @req.execute(\"\n INSERT INTO bookRequests\n VALUES (?, ?, ?, ?, ?)\",\n requestID,\n usrID,\n params[\"title\"],\n params[\"author\"],\n date\n )\n \n completed = true\n completed\n end",
"def friend_requests\n FriendRequest.all.select do |req|\n req.to_user_id == self.id && req.pending\n end\n end",
"def requests\n Request.where(:app.in => apps.pluck(:id)) if apps\n end",
"def get_users_on_flight_reject_requester\n\n\t\t# Then query saved journeys using the 'purchased_flight' identifier\n\t\t# for a list of the the other user id's who are on the flight\n\t\t# \n\t\t# Remove the queryer from the list and remove sensetive information\n\t\t# \n\t\t# Done. Return our model list\n\n\t\tjourney_id = params[\"journeyId\"]\n\t\tuser_id = params[\"userId\"]\n\n\t\tuser_list = User.on_journey(journey_id).reject{ |s| s.id == user_id }\n\n\t\trender json: user_list.as_json(only: [:id, :first_name, :last_name, :email]), status: 200\n\n\tend",
"def overlapping_pending_requests\n # calls overlapping requests; add a `where`\n overlapping_requests.select do |request|\n request.status == \"PENDING\" unless request.id == self.id\n end\n end",
"def my_request_objects\n RequestList.list_requests(creator: current_staff_profile,\n request_filters: request_params[:filters],\n search_query: request_params[:query],\n order: request_params[\"sort\"],\n page: request_params[:page])\n end",
"def showRequests\n \t\t# Ensure user is logged in to view this page\n\t\tif(session.has_key?(\"logged_in\"))\n\t\t\n\t\t\t# If the user is not logged in redirect to homepage\n\t\t\tif(session['logged_in'] != 1) \n\t\t\t\tredirect_to url_for(:controller => :home, :action => :showHome)\n\t\t\tend\n\n\t\t\t# Get user id.\n\t\t\t@userID = session['user_id']\n\n\n\t\t\t# ids of people requesting collaboration.\n\t\t\t@co_ids = Collaboration.where(second_id:@userID)\n\n\t\t\t@num = @co_ids.count\n\n\t\t\t# Arrays to store ids other requesters.\n\t\t\t@requester_ids = Array.new(@num)\n\t\t\t@names = Array.new(@num)\n\t\t\t@messages = Array.new(@num)\n\n\t\t\tfor i in 0..@num-1\n\t\t\t\t@requester_ids[i] = @co_ids[i].first_id\n\t\t\t\t@messages[i] = Collaboration.find_by(first_id:@requester_ids[i], second_id:@userID).message\n\t\t\t\t@names[i] = User.find(@co_ids[i].first_id).username\n\t\t\tend\n\n\t\telse\n\t\t\tredirect_to url_for(:controller => :home, :action => :showHome)\n\t\tend\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /game_ratings GET /game_ratings.json | def index
@game_ratings = GameRating.all
end | [
"def ratings\n Birdman::Requester.get(\"shows/#{id}/seasons/#{season}/episodes/#{episode}/ratings\")\n end",
"def ratings(args = {})\n begin\n do_get(AppFigures::API::RATINGS, args)\n rescue Exception => e\n puts e.message\n puts e.backtrace\n end\n end",
"def index\n @ratings = Rating.all\n respond_to do |format|\n format.json { render json: {ratings: @ratings}, status: :ok }\n end\n end",
"def ratings\n user = User.find_by( slug: params[:user_slug] )\n rating = RATINGS[ ratings_params[ :rating ] ]\n ratings = Rating.preload(:resource).where( user_id: user.id, rating_type: rating )\n resourcesJson = []\n ratings.each do |rating|\n resourcesJson.append( JSON.parse(ResourceCardSerializer.new( rating.resource ).to_json) )\n end\n\n render json: resourcesJson\n end",
"def index\n @ratings = Rating.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ratings }\n end\n end",
"def index\n @apparel_ratings = ApparelRating.all\n\n render json: @apparel_ratings\n end",
"def show\n @rating = Rating.find(params[:id])\n\n render json: @rating\n end",
"def rating\n response[\"rating\"]\n end",
"def ratings\n entries = Client.load('viewratingdetail.php', :nick => self.nick)\n entries.map { |entry| Rating.new(entry) }\n end",
"def show\n render json: @apparel_rating\n end",
"def rate\n puts film_rating_params\n\n film = Film.find(film_rating_params[:film_id])\n user = User.find(film_rating_params[:user_id])\n\n rating = UserRating.create!(user: user, film: film, star_rating: film_rating_params[:star_rating])\n\n render json: { films: [film.as_json_api] }\n rescue [ActiveRecord::RecordInvalid, ActiveRecord::RecordNotFound] => e\n head 403\n end",
"def index\n @session_ratings = SessionRating.all\n end",
"def show\n @dev = User.find(params[:id])\n @ratings = RatingService::get_ratings(@dev)\n end",
"def index\n user = User.find_by(id: params[:user_id])\n return :ratings => [], :status => :not_found if user.nil?\n\n result = []\n # generate pending ratings\n if params.has_key?(:pending)\n user.rides_as_passenger.each do |ride|\n if Rating.find_by(from_user_id: user.id, to_user_id: ride.driver.id, ride_id: ride.id).nil?\n pending_rating = {}\n pending_rating[:from_user_id] = user.id\n pending_rating[:to_user_id] = ride.driver.id\n pending_rating[:ride_id] = ride.id\n result.append(pending_rating)\n end\n end\n respond_with ratings: result, status: :ok\n else\n #generate ratings given\n ratings = user.ratings_given + user.ratings_received\n result = []\n ratings.each do |r|\n rating = {}\n rating[:from_user_id] = r[:from_user_id]\n rating[:to_user_id] = r[:to_user_id]\n rating[:ride_id] = r[:ride_id]\n result.append(rating)\n end\n respond_with ratings: result, status: :ok\n end\n end",
"def show\n @rating_alt = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rating_alt }\n end\n end",
"def index\n @participant_ratings = ParticipantRating.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participant_ratings }\n end\n end",
"def index\n @api_v1_mentorship_ratings = Api::V1::MentorshipRating.all\n end",
"def show\n @team_rating = TeamRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_rating }\n end\n end",
"def show\n respond_to do |format|\n format.json { render json: {request_rating: @request_rating}, status: :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /game_ratings POST /game_ratings.json | def create
@game_rating = GameRating.new(game_rating_params)
respond_to do |format|
if @game_rating.save
format.html { redirect_to @game_rating, notice: 'Game rating was successfully created.' }
format.json { render :show, status: :created, location: @game_rating }
else
format.html { render :new }
format.json { render json: @game_rating.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @rating = Rating.new(rating_params)\n if @rating.save\n render json: @rating, status: 201\n else\n render json: @rating.errors, status: :unprocessable_entity\n end\n end",
"def rate\n puts film_rating_params\n\n film = Film.find(film_rating_params[:film_id])\n user = User.find(film_rating_params[:user_id])\n\n rating = UserRating.create!(user: user, film: film, star_rating: film_rating_params[:star_rating])\n\n render json: { films: [film.as_json_api] }\n rescue [ActiveRecord::RecordInvalid, ActiveRecord::RecordNotFound] => e\n head 403\n end",
"def create\n @rating = @rateable.ratings.build(params[:rating])\n @rating.user = current_user\n\n if @rating.save\n respond_to do |format|\n format.html { render :nothing => true }\n format.json { render :json => @rating }\n end\n else\n respond_to do |format|\n format.html { render :nothing => true, :status => :bad_request }\n format.json { render :json => @rating, :status => :bad_request }\n end\n end\n end",
"def rate_post(rating)\n mock_request = Rack::MockRequest.new(APP)\n mock_request.put(rate_post_endpoint, { 'router.params' => { rating: rating }, format: :json })\n end",
"def create\n @player_rating = PlayerRating.new(player_rating_params)\n\n respond_to do |format|\n if @player_rating.save\n format.html { redirect_to @player_rating, notice: 'Player rating was successfully created.' }\n format.json { render :show, status: :created, location: @player_rating }\n else\n format.html { render :new }\n format.json { render json: @player_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ratings\n Birdman::Requester.get(\"shows/#{id}/seasons/#{season}/episodes/#{episode}/ratings\")\n end",
"def index\n @game_ratings = GameRating.all\n end",
"def add_rating\n if current_user.type == 'Committee'\n @idea=Idea.find(params[:id])\n @idea.approve (current_user)\n @rating = params[:rating]\n @rating.each do |rate|\n r = @idea.ratings.build\n r.name=rate\n r.value=0\n r.idea_id=@idea.id\n r.save\n end\n respond_to do |format|\n format.js {render \"add_rating\"}\n end\n else\n respond_to do |format|\n format.html { redirect_to '/' , notice: 'You cant add rating prespectives' }\n format.json { head :no_content }\n end\n end\n end",
"def create\n # Let's check if there is already the game in Games db table\n game = Game.find_by_game_id(star_rating_params[:game_id])\n\n # If there wasn't game in db, let's add one and its game rating ( 2 ^ (star rating - 1) also\n if game.nil?\n game = Game.new(:game_id => star_rating_params[:game_id], :game_rating => 2**(star_rating_params[:stars]-1))\n game.save\n @star_rating = StarRating.new(star_rating_params)\n @star_rating.user_id = current_user.id\n else\n\n # Is there a previous star rating made by current user?\n star_rating = StarRating.find_by(:game_id => star_rating_params[:game_id], :user_id => current_user.id)\n\n # IF: There is NO previous star rating, let's add one and fix game's game rating\n #\n # ELSE: There is a previous star rating, let's update it and fix game's game rating\n if star_rating.nil?\n game.fix_game_rating(nil, star_rating_params[:stars])\n @star_rating = StarRating.new(star_rating_params)\n @star_rating.user_id = current_user\n else\n game.fix_game_rating(star_rating.stars, star_rating_params[:stars])\n @star_rating = star_rating\n @star_rating.stars = star_rating_params[:stars]\n end\n end\n\n if @star_rating.save\n render :nothing => true, :status => :ok\n else\n render :nothing => true, :status => :unprocessable_entity\n end\n\n end",
"def create\n\t\trating = Rating.new(ActiveSupport::JSON.decode(params[:rating]))\n\t\tif rating.save\n\t\t\trender_json({:message => \"record inserted\", :status => 200}.to_json)\n\t\telse\n\t\t\trender_json({:errors => \"record not inserted\", :status => 404}.to_json)\t\n\t\tend\n\tend",
"def create\n @fragrance = Fragrance.find(params[:fragrance_id])\n @rating = Rating.new(rating_params)\n @rating.user = @current_user\n @rating.fragrance = @fragrance\n\n if @rating.save\n render json: @rating, status: :created\n else\n render json: @rating.errors, status: :unprocessable_entity\n end\n end",
"def create\n idea = Idea.find_by_id(params[:idea_id])\n user_rating = UserRating.new(params[:rating])\n user_rating.rating_id = params[:rating_id]\n user_rating.user_id = current_user.id\n\n if user_rating.save\n saved_rating = UserRating.where('rating_id' => params[:rating_id])\n\n if saved_rating.size != 0\n rating = Rating.find_by_id(params[:rating_id])\n average_rating = 0\n\n saved_rating.each do |sr|\n average_rating = average_rating.to_i + sr.value.to_i\n end\n\n if current_user.provider == 'twitter' && current_user.facebook_share\n current_user.twitter.update(\"I've rated an idea on #Idearator ! available on: \" + root_url + \"ideas/\" + idea.id.to_s) rescue Twitter::Error\n end\n\n rating.value = average_rating.to_f / saved_rating.size.to_f\n rating.save\n end\n\n respond_to do |format|\n format.html { redirect_to idea, :notice => 'Your rating has been saved successfully!' }\n format.js\n end\n else\n respond_to do |format|\n format.html { redirect_to idea, :alert => 'Your rating has not been saved, please retry!' }\n format.js\n end\n end\n end",
"def create\n @team_rating = TeamRating.new(params[:team_rating])\n\n respond_to do |format|\n if @team_rating.save\n format.html { redirect_to @team_rating, notice: 'Team rating was successfully created.' }\n format.json { render json: @team_rating, status: :created, location: @team_rating }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rating_params\n\t\tparams.require(:rating).permit(:ratable, :score, :user)\n\tend",
"def create\n @session_rating = SessionRating.new(session_rating_params)\n\n respond_to do |format|\n if @session_rating.save\n format.html { redirect_to @session_rating, notice: 'Session rating was successfully created.' }\n format.json { render :show, status: :created, location: @session_rating }\n else\n format.html { render :new }\n format.json { render json: @session_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rate\n logger.info(\"HTML\")\n rating = current_user.sound_ratings.new(sound_id: params[:id], value: params[:rating])\n if rating.save\n redirect_to '/sounds', notice: \"Thank you for voting.\"\n else\n redirect_to '/sounds', alert: \"Unable to vote, perhaps you already did.\"\n end\n end",
"def rate_post\n render nothing: true\n\n post = Post.find(params[:id])\n\n assert(@post.kind_of?(Post))\n\n if not post.user_ratings.include? current_user.id\n post.user_ratings.push(current_user.id)\n post.save\n else\n redirect_to_back(root_path)\n end\n end",
"def create\n @effort_rating = @opportunity.effort_ratings.new(effort_rating_params)\n\n respond_to do |format|\n if @effort_rating.save\n @opportunity.effort_rating = @opportunity.effort_ratings.average(:rating)\n @opportunity.save\n format.html { redirect_to @opportunity, notice: 'Effort rating was successfully created.' }\n format.json { render :show, status: :created, location: @effort_rating }\n else\n format.html { render :new }\n format.json { render json: @opportunity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rating_alt = Rating.new(params[:rating_alt])\n\n respond_to do |format|\n if @rating_alt.save\n format.html { redirect_to @rating_alt, notice: 'Rating was successfully created.' }\n format.json { render json: @rating_alt, status: :created, location: @rating_alt }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rating_alt.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /game_ratings/1 PATCH/PUT /game_ratings/1.json | def update
respond_to do |format|
if @game_rating.update(game_rating_params)
format.html { redirect_to @game_rating, notice: 'Game rating was successfully updated.' }
format.json { render :show, status: :ok, location: @game_rating }
else
format.html { render :edit }
format.json { render json: @game_rating.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @rating = Rating.find(params[:id])\n\n respond_to do |format|\n if @rating.update_attributes(params[:rating])\n format.json { render json: @rating, status: :ok, location: nil }\n else\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rating.update(rating_params)\n format.json { head :no_content }\n else\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rating = Rating.find(params[:id])\n\n respond_to do |format|\n if @rating.update_attributes(params[:rating])\n format.html { redirect_to @rating, notice: 'Rating was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rating = Rating.find(params[:id])\n\n respond_to do |format|\n if @rating.update_attributes(params[:rating])\n format.html { redirect_to @rating, notice: 'Rating was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @song = Song.find params[:song_id]\n @rating = Rating.find params[:id]\n\n respond_to do |format|\n if @rating.update_attributes(params[:rating])\n format.html { redirect_to @song, notice: 'Ratings were successfully updated.' }\n format.json { render json: @rating }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rating_alt = Rating.find(params[:id])\n\n respond_to do |format|\n if @rating_alt.update_attributes(params[:rating_alt])\n format.html { redirect_to @rating_alt, notice: 'Rating was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rating_alt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team_rating = TeamRating.find(params[:id])\n\n respond_to do |format|\n if @team_rating.update_attributes(params[:team_rating])\n format.html { redirect_to @team_rating, notice: 'Team rating was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @request_rating.update(request_rating_params)\n format.html { redirect_to @request_rating, notice: 'Request rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_rating }\n else\n format.html { render :edit }\n format.json { render json: @request_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @player_rating.update(player_rating_params)\n format.html { redirect_to @player_rating, notice: 'Player rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @player_rating }\n else\n format.html { render :edit }\n format.json { render json: @player_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n user_id = decoded_token[0]['user_id'].to_i\n restaurant_id = Restaurant.find_by(yelp_id: rating_params[:yelp_id]).id\n rating = Rating.find_by(restaurant_id: restaurant_id, user_id: user_id)\n rating.value = rating_params[:value]\n if rating.save\n render json: RatingSerializer.new(rating)\n else\n render json: { error: 'Could not update rating' }\n end\n end",
"def update\n respond_to do |format|\n if @idea_rating.update(idea_rating_params)\n format.html { redirect_to idea_ratings_path(:idea_id => @idea_rating.idea_id), notice: (I18n.t :act_update) }\n format.json { render :show, status: :ok, location: @idea_rating }\n calc_idea_rating\n else\n format.html { render :edit }\n format.json { render json: @idea_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rating = current_user.ratings.find(params[:id])\n\n respond_to do |format|\n if @rating.update_attributes(params[:rating])\n format.html { redirect_to(user_ratings_path(current_user), :notice => 'Rating was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @game_rate.update(game_rate_params)\n format.html { redirect_to @game_rate, notice: 'Game rate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @game_rate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n idea = Idea.find_by_id(params[:idea_id])\n user_rating = current_user.user_ratings.find_by_rating_id(params[:rating_id])\n\n if user_rating.update_attributes(params[:rating])\n saved_rating = UserRating.where('rating_id' => params[:rating_id])\n\n if saved_rating.size != 0\n rating = Rating.find_by_id(params[:rating_id])\n average_rating = 0\n\n saved_rating.each do |sr|\n average_rating = average_rating.to_i + sr.value.to_i\n end\n\n rating.value = average_rating.to_f / saved_rating.size.to_f\n rating.save\n end\n\n respond_to do |format|\n format.html { redirect_to idea_path(idea), :notice => 'Your rating has been updated successfully!' }\n format.js { render text: \"\" }\n end\n else\n respond_to do |format|\n format.html { redirect_to idea_path(idea), :alert => 'Your rating has not been updated, please retry!' }\n format.js { render text: \"\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @owner_rating.update(owner_rating_params)\n format.html { redirect_to @owner_rating, notice: 'Owner rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @owner_rating }\n else\n format.html { render :edit }\n format.json { render json: @owner_rating.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rating_score.update(rating_score_params)\n format.html { redirect_to @rating_score, notice: 'Rating score was successfully updated.' }\n format.json { render :show, status: :ok, location: @rating_score }\n else\n format.html { render :edit }\n format.json { render json: @rating_score.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rate(args = {})\n make_request(\n http_method: :put,\n endpoint: path_for(:rating, ride_id: args.delete(:ride_id)),\n access_token: args.delete(:access_token),\n options: { body: args.to_json }\n )\n end",
"def update\n\t\t@title_rating = TitleRating.find(params[:id])\n\t\t(Title::attributes + Title::genres).each do |name|\n\t\t\tparams['title_rating'][name] = nil if params['title_rating'][name] == '0'\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tif @title_rating.update_attributes(params[:title_rating])\n\t\t\t\tflash_notice 'The Title Rating was successfully updated.'\n\t\t\t\tformat.html { redirect_to(@title_rating) }\n\t\t\t\t#format.xml\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\t#format.xml\t{ render :xml => @title_rating.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @participant_rating = ParticipantRating.find(params[:id])\n\n respond_to do |format|\n if @participant_rating.update_attributes(params[:participant_rating])\n format.html { redirect_to @participant_rating, notice: 'Participant rating was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant_rating.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /game_ratings/1 DELETE /game_ratings/1.json | def destroy
@game_rating.destroy
respond_to do |format|
format.html { redirect_to game_ratings_url, notice: 'Game rating was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @rating.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @rating = Rating.find(params[:id])\n @rating.destroy\n\n respond_to do |format|\n format.html { redirect_to ratings_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @rating_alt = Rating.find(params[:id])\n @rating_alt.destroy\n\n respond_to do |format|\n format.html { redirect_to rating_alts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @make_rating.destroy\n respond_to do |format|\n format.html { redirect_to make_ratings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @idea_rating.destroy\n respond_to do |format|\n format.html { redirect_to idea_ratings_url, notice: (I18n.t :act_delete) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_rate.destroy\n respond_to do |format|\n format.html { redirect_to game_rates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team_rating = TeamRating.find(params[:id])\n @team_rating.destroy\n\n respond_to do |format|\n format.html { redirect_to team_ratings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rating = Rating.find(params[:id])\n @rating.destroy\n\n respond_to do |format|\n format.html { redirect_to(ratings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @request_rating.destroy\n respond_to do |format|\n format.html { redirect_to request_ratings_url, notice: 'Request rating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_mentorship_rating.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_mentorship_ratings_url, notice: 'Mentorship rating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @star_rating.destroy\n respond_to do |format|\n format.html { redirect_to star_ratings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @participant_rating = ParticipantRating.find(params[:id])\n @participant_rating.destroy\n\n respond_to do |format|\n format.html { redirect_to participant_ratings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @player_rating.destroy\n respond_to do |format|\n format.html { redirect_to player_ratings_url, notice: 'Player rating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apparel_rating.destroy\n\n head :no_content\n end",
"def destroy\n @away_rating.destroy\n respond_to do |format|\n format.html { redirect_to away_ratings_url, notice: 'Away rating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @rating_attraction.destroy\r\n respond_to do |format|\r\n format.html { redirect_to rating_attractions_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @article_rating.destroy\n respond_to do |format|\n format.html { redirect_to article_ratings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course_rating = CourseRating.find(params[:id])\n @course_rating.destroy\n\n respond_to do |format|\n format.html { redirect_to course_ratings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @building_energy_rating.destroy\n respond_to do |format|\n format.html { redirect_to building_energy_ratings_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /post316s/1 GET /post316s/1.xml | def show
@post316 = Post316.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @post316 }
end
end | [
"def show\n @post306 = Post306.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post306 }\n end\n end",
"def show\n @post170 = Post170.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post170 }\n end\n end",
"def show\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post154 }\n end\n end",
"def show\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post150 }\n end\n end",
"def show\n @post185 = Post185.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post185 }\n end\n end",
"def show\n @post155 = Post155.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post155 }\n end\n end",
"def show\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post156 }\n end\n end",
"def show\n @post206 = Post206.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post206 }\n end\n end",
"def show\n @post80 = Post80.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post80 }\n end\n end",
"def show\n @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post157 }\n end\n end",
"def show\n @post186 = Post186.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post186 }\n end\n end",
"def show\n @post207 = Post207.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post207 }\n end\n end",
"def show\n @post356 = Post356.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post356 }\n end\n end",
"def show\n @post83 = Post83.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post83 }\n end\n end",
"def show\n @post283 = Post283.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post283 }\n end\n end",
"def show\n @post151 = Post151.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post151 }\n end\n end",
"def show\n @post165 = Post165.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post165 }\n end\n end",
"def show\n @post166 = Post166.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post166 }\n end\n end",
"def show\n @post145 = Post145.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post145 }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /post316s/new GET /post316s/new.xml | def new
@post316 = Post316.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post316 }
end
end | [
"def new\n @post155 = Post155.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post155 }\n end\n end",
"def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end",
"def new\n @post200 = Post200.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post200 }\n end\n end",
"def new\n @post185 = Post185.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post185 }\n end\n end",
"def new\n @post198 = Post198.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post198 }\n end\n end",
"def new\n @post211 = Post211.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post211 }\n end\n end",
"def new\n @post145 = Post145.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post145 }\n end\n end",
"def new\n @post227 = Post227.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post227 }\n end\n end",
"def new\n @post101 = Post101.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post101 }\n end\n end",
"def new\n @post283 = Post283.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post283 }\n end\n end",
"def new\n @post83 = Post83.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post83 }\n end\n end",
"def new\n @post142 = Post142.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post142 }\n end\n end",
"def new\n @post310 = Post310.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post310 }\n end\n end",
"def new\n @post156 = Post156.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post156 }\n end\n end",
"def new\n @post151 = Post151.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post151 }\n end\n end",
"def new\n @post201 = Post201.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post201 }\n end\n end",
"def new\n @post57 = Post57.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post57 }\n end\n end",
"def new\n @post181 = Post181.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post181 }\n end\n end",
"def new\n @post154 = Post154.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post154 }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /post316s POST /post316s.xml | def create
@post316 = Post316.new(params[:post316])
respond_to do |format|
if @post316.save
format.html { redirect_to(@post316, :notice => 'Post316 was successfully created.') }
format.xml { render :xml => @post316, :status => :created, :location => @post316 }
else
format.html { render :action => "new" }
format.xml { render :xml => @post316.errors, :status => :unprocessable_entity }
end
end
end | [
"def post(data, tags_in = {}) ; post_to nil, data, tags_in end",
"def create\n @post415 = Post415.new(params[:post415])\n\n respond_to do |format|\n if @post415.save\n format.html { redirect_to(@post415, :notice => 'Post415 was successfully created.') }\n format.xml { render :xml => @post415, :status => :created, :location => @post415 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post415.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post416 = Post416.new(params[:post416])\n\n respond_to do |format|\n if @post416.save\n format.html { redirect_to(@post416, :notice => 'Post416 was successfully created.') }\n format.xml { render :xml => @post416, :status => :created, :location => @post416 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post416.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post154 = Post154.new(params[:post154])\n\n respond_to do |format|\n if @post154.save\n format.html { redirect_to(@post154, :notice => 'Post154 was successfully created.') }\n format.xml { render :xml => @post154, :status => :created, :location => @post154 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post154.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post168 = Post168.new(params[:post168])\n\n respond_to do |format|\n if @post168.save\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully created.') }\n format.xml { render :xml => @post168, :status => :created, :location => @post168 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post168.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post164 = Post164.new(params[:post164])\n\n respond_to do |format|\n if @post164.save\n format.html { redirect_to(@post164, :notice => 'Post164 was successfully created.') }\n format.xml { render :xml => @post164, :status => :created, :location => @post164 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post164.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post170 = Post170.new(params[:post170])\n\n respond_to do |format|\n if @post170.save\n format.html { redirect_to(@post170, :notice => 'Post170 was successfully created.') }\n format.xml { render :xml => @post170, :status => :created, :location => @post170 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post170.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post166 = Post166.new(params[:post166])\n\n respond_to do |format|\n if @post166.save\n format.html { redirect_to(@post166, :notice => 'Post166 was successfully created.') }\n format.xml { render :xml => @post166, :status => :created, :location => @post166 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post166.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post160 = Post160.new(params[:post160])\n\n respond_to do |format|\n if @post160.save\n format.html { redirect_to(@post160, :notice => 'Post160 was successfully created.') }\n format.xml { render :xml => @post160, :status => :created, :location => @post160 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post160.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post156 = Post156.new(params[:post156])\n\n respond_to do |format|\n if @post156.save\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully created.') }\n format.xml { render :xml => @post156, :status => :created, :location => @post156 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post156.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post155 = Post155.new(params[:post155])\n\n respond_to do |format|\n if @post155.save\n format.html { redirect_to(@post155, :notice => 'Post155 was successfully created.') }\n format.xml { render :xml => @post155, :status => :created, :location => @post155 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post155.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post157 = Post157.new(params[:post157])\n\n respond_to do |format|\n if @post157.save\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully created.') }\n format.xml { render :xml => @post157, :status => :created, :location => @post157 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post317 = Post317.new(params[:post317])\n\n respond_to do |format|\n if @post317.save\n format.html { redirect_to(@post317, :notice => 'Post317 was successfully created.') }\n format.xml { render :xml => @post317, :status => :created, :location => @post317 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post317.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post165 = Post165.new(params[:post165])\n\n respond_to do |format|\n if @post165.save\n format.html { redirect_to(@post165, :notice => 'Post165 was successfully created.') }\n format.xml { render :xml => @post165, :status => :created, :location => @post165 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post165.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post167 = Post167.new(params[:post167])\n\n respond_to do |format|\n if @post167.save\n format.html { redirect_to(@post167, :notice => 'Post167 was successfully created.') }\n format.xml { render :xml => @post167, :status => :created, :location => @post167 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post167.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post206 = Post206.new(params[:post206])\n\n respond_to do |format|\n if @post206.save\n format.html { redirect_to(@post206, :notice => 'Post206 was successfully created.') }\n format.xml { render :xml => @post206, :status => :created, :location => @post206 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post206.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post306 = Post306.new(params[:post306])\n\n respond_to do |format|\n if @post306.save\n format.html { redirect_to(@post306, :notice => 'Post306 was successfully created.') }\n format.xml { render :xml => @post306, :status => :created, :location => @post306 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post306.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post16 = Post16.new(params[:post16])\n\n respond_to do |format|\n if @post16.save\n format.html { redirect_to(@post16, :notice => 'Post16 was successfully created.') }\n format.xml { render :xml => @post16, :status => :created, :location => @post16 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post16.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post314 = Post314.new(params[:post314])\n\n respond_to do |format|\n if @post314.save\n format.html { redirect_to(@post314, :notice => 'Post314 was successfully created.') }\n format.xml { render :xml => @post314, :status => :created, :location => @post314 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post314.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Place Order POST /orders Recurring order start from the day you place them Assuming Resturant sent belongs to the user region only | def create
order_params = (place_order_params)
order_params[:customer_id] = current_user.customer_id
@order = Order.new(order_params)
if @order.recurring?
if((Time.now + 1.hour).strftime('%H:%M:%S') <= (Time.parse(@order.place_date + ' ' + @order.timeslot.start)).strftime('%H:%M:%S') && !@order.completed? )
# Add the auto generated entry
@order.category = 'single'
@order.created_by = 'auto'
@order.save!
end
# Improve this
if Order.create!(order_params)
render json: @order, status: 201
else
render json: {'errors': ['Order can no be placed']}, status: :unprocessable_entity
end
else
if (Time.now + 1.hour <= Time.parse(@order.place_date + ' ' + @order.timeslot.start)) && @order.save!
render json: @order, status: 201
else
render json: {'errorrs': ['Order can not be placed']}, status: :unprocessable_entity
end
end
end | [
"def create_order\n post_request \"orders\"\n end",
"def schedule_order(order)\n # No scheduled orders yet.\n end",
"def create_order_with_future_release_date(status = 1)\n order = Order.new\n order.order_status_id = status\n order.pickup_date = '2015-12-31'\n order.order_date = Date.today\n order.user_id = users(:user).id\n order_product = order.order_products.new\n order_product.product_id = products(:future).id\n order_product.quantity = 1\n order.save\n return order\n end",
"def ezp_submit_order\n # the test_mode flag tells us if we should submit \"real\" orders (when false) to ezprints or simulate the order flow internally (when true)\n if self.test_mode\n # kick off loopback mode for order simulation - the EZPSimulator will\n # call back to simulate the order notification flow as if it was coming from EZPrints\n ZZ::Async::EZPSimulator.simulate_order(self)\n else\n # real order placement\n self.ezp_reference_id = ez.submit_order(self)\n save!\n end\n end",
"def create_order(options)\n request :account, :post, 'order', options\n end",
"def place_order(exchange, tradingsymbol, transaction_type, quantity, product,\n order_type, price = nil, trigger_price = nil, tag = nil, variety = nil)\n params = {}\n exchange_type = exchange || \"NSE\"\n params[:symbol] = exchange_type + \":\" + tradingsymbol\n params[:side] = transaction_type\n params[:qty] = quantity.to_i\n params[:productType] = product || \"CNC\"\n params[:type] = order_type\n params[:limitPrice] = price || 0\n params[:validity] = \"DAY\"\n params[:offlineOrder] = \"false\"\n params[:stopPrice] = price || 0\n params[:disclosedQty] = 0\n params[:stopLoss] = 0\n params[:takeProfit] = 0\n \n resp = post(\"order.place\", params)\n\n if resp && order_id = resp[\"order_id\"]\n order_id\n else\n nil\n end\n end",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend",
"def place_order\n current_order.place_order\n current_order.save\n remove_order\n end",
"def new_order symbol, trade_type, price, amount\n path = '/v1/order/orders/place'\n request_method = 'POST'\n params = {\n 'account-id' => @account_id,\n 'amount' => amount,\n 'price' => price,\n 'source' => 'api',\n 'symbol' => symbol,\n 'type' => trade_type\n }\n perform(path, params, request_method)\n end",
"def create_order(order)\n @queue.enqueue(order)\n end",
"def create_order(order)\n # response = post(\n # 'peatio/market/orders',\n # {\n # market: order.market.downcase,\n # side: order.side.to_s,\n # volume: order.amount,\n # price: order.price\n # }\n # )\n\n return if order.amount < 1e-8\n od = build_order(order)\n return if od.nil?\n\n# Arke::Log.debug \"Skip order creation #{od.to_json}\\n#{order.inspect}\"\n Ordering.new(od).submit\n @open_orders.add_order(order, od.id) if od.id\n Arke::Log.debug \"Order created #{od.to_json}\"\n\n # @open_orders.add_order(order, response.env.body['id']) if response.env.status == 201 && response.env.body['id']\n\n # response\n end",
"def place_order!()\n order_template = firewall_order_template\n order_template = yield order_template if block_given?\n\n server.softlayer_client[:Product_Order].placeOrder(order_template)\n end",
"def request_booking(sponsors, trip_purpose_raw, is_depart, scheduled_time, from_trip_place, to_trip_place, note_to_driver, assistant, companions, children, other_passengers, customer_number, funding_xml, funding_array, system, token)\n url_options = \"/api/order/\" + system + \"?overlaps=reject\"\n url = BASE_URL + url_options\n order = build_order(sponsors, trip_purpose_raw, is_depart, scheduled_time, from_trip_place, to_trip_place, note_to_driver, assistant, companions, children, other_passengers, customer_number, system, token, funding_xml, funding_array)\n order = Nokogiri::XML(order)\n order.children.first.set_attribute('version', '2')\n order = order.to_s\n result = send_request(url, token, 'POST', order)\n Rails.logger.info('Order Request Sent to Ecolane:')\n Rails.logger.info(order)\n result\n end",
"def create_autodelivery_order\n if @order.completed?\n\n #@order.create_subscriptions\n\n\n #if og_autoship.to_i==1\n if Spree::Promotion::Rules::Autodelivery.new.eligible?(@order) && !!@order.user # if this order is ready to signup\n merchant_id= Spree::OrdergrooveConfiguration.account[\"#{@order.store.code}\"][\"og_merchant_id\"]\n hashkey= Spree::OrdergrooveConfiguration.account[\"#{@order.store.code}\"][\"og_hashkey\"]\n og_subscription_url= Spree::OrdergrooveConfiguration.account[\"#{@order.store.code}\"][\"og_subscription_url_#{ENV[\"RAILS_ENV\"]}\"]\n og_offer_id= Spree::OrdergrooveConfiguration.account[\"#{@order.store.code}\"][\"og_offer_id\"]\n\n rc4=RC4.new(hashkey)\n Rails.logger.error(\"*\" * 50)\n Rails.logger.error(\"Order: \" + @order.number + \" subscribed to auto delivery, post to order groove now\")\n Rails.logger.error(\"*\" * 50)\n #encode the subscription\n subscription={:offer_id =>og_offer_id, :session_id=>cookies[:og_session_id]||\"\", :order_number =>@order.number}\n billing_address=@order.bill_address\n customer={:id=> @order.user_id.to_s, :first_name=>(billing_address.firstname), :last_name=>(billing_address.lastname), :email=>@order.email}\n customer[:billing_address]={:first_name=>(billing_address.firstname), :last_name=>(billing_address.lastname),:company_name=>\"\",:address=>(billing_address.address1),\n :address2=>(billing_address.address2||''),:city=>(billing_address.city),:state=>(billing_address.state_id==nil ? (!!billing_address.state_name ? billing_address.state_name : '') : Spree::State.find(billing_address.state_id).abbr),:zip_code=>billing_address.zipcode,:phone=>billing_address.phone,\n :fax=>\"\",:country_code=>Spree::Country.find(billing_address.country_id).iso}\n billing_address=@order.ship_address\n customer[:shipping_address]={:first_name=>(billing_address.firstname), :last_name=>(billing_address.lastname),:company_name=>\"\",:address=>(billing_address.address1),\n :address2=>(billing_address.address2||''),:city=>(billing_address.city),:state=>(billing_address.state_id==nil ? (!!billing_address.state_name ? billing_address.state_name : '') : Spree::State.find(billing_address.state_id).abbr),:zip_code=>billing_address.zipcode,:phone=>billing_address.phone,\n :fax=>\"\",:country_code=>Spree::Country.find(billing_address.country_id).iso}\n\n payment={:cc_holder=>Base64.encode64(rc4.encrypt(billing_address.firstname + ' ' + billing_address.lastname)).chomp, :cc_type=>'visa',:cc_number=> session[:cc].chomp(),:cc_exp_date=>Base64.encode64(rc4.encrypt(((@order.payments.last.source[:month].to_i<10 ? '0' : '') + @order.payments.last.source[:month].to_s + '/' + @order.payments.last.source[:year].to_s))).chomp }\n\n customer[:payment] =payment\n subscription[:customer] =customer\n\n subscriptions=[]\n @order.line_items.select{|l| l.auto_delivery}.each do |line_item|\n subscriptions << {:product_id => line_item.variant_id,\n :qty =>line_item.quantity,\n :frequency => line_item.frequency.gsub('_2',''),\n :period=>\"week\" }\n\n # post only one product one time\n #byebug\n begin\n subscription[:offer_id] =line_item.adjustments.eligible.select{|a| a.label.include? 'Auto'}.first.source.promotion.description\n subscription[:subscriptions] =subscriptions\n post_subscription subscription\n rescue\n subscriptions=[]\n end\n subscriptions=[]\n\n end\n\n #subscription[:subscriptions] =subscriptions\n\n session[:cc] = ''\n\n\n #post_subscription subscription\n end\n end\n end",
"def order_submit(order)\n execute 'api/submit',\n build_json({\n order: order\n })\n end",
"def start_recurring_payment\n return unless recurring_period.present?\n run_at = nil\n if recurring_period.to_s.is_i? # each custom days\n run_at = recurring_period.to_i.days.from_now\n # run_at = recurring_period.to_i.minutes.from_now\n else\n case recurring_period\n when 'daily'\n run_at = 1.day.from_now\n when 'weekly'\n run_at = 7.days.from_now\n when 'monthly'\n run_at = 1.month.from_now\n when 'quarterly'\n run_at = 3.months.from_now\n when 'biannually'\n run_at = 6.months.from_now\n when 'yearly'\n run_at = 1.year.from_now\n end\n end\n Delayed::Job.enqueue(LongTasks::RecurringPaymentNotification.new(id), run_at: run_at - 1.day) if run_at && ['tithe', 'partnership'].include?(goal)\n Delayed::Job.enqueue(LongTasks::RecurringPayment.new(id), run_at: run_at) if run_at\n end",
"def generate_order\n @persona = Persona.where( :screen_name => params[:persona_id]).first\n\n\t\t@carts = @persona.carts.where(:order_id => nil)\n\n\t\t@order = @persona.orders.new(:status => 0)\n\n\t\trespond_to do |format|\n\t\t\tif @order.save! then\n\t\t\t\t@carts.each do |cart_item|\n\t\t\t\t\tcart_item.update_attribute(:order_id, @order.id)\n\t\t\t\tend\n #after the order is created, await for payment\n @order.update_attribute(:status, 1)\n\t\t\t\tformat.js\n\t\t\telse\n\t\t\t\tflash[:error] = 'Unable to place order'\n\t\t\t\tformat.js :status => 500\n\t\t\tend \n\t\tend\n end",
"def place_order\n @browser.div(:id, \"checkout-step-review\").button(:text, \"Place Order\").click\n seconds = 0.10\n until @browser.text.include?(\"Your order has been received\") do\n sleep 0.10\n seconds += 0.5\n end\n puts \"[INFO] I waited #{seconds} seconds\"\n #final code dependant assertion\n assert(@browser.button(:title,'Continue Shopping').enabled?)\n assert_section 'success'\n end",
"def create_order\n cart = Cart.last # you would remove this since you're passing cart on the call\n products = cart.products\n price = []\n\n # iterate over each product and get the price to sum for total\n products.each do |item|\n price << item[1]['price'] * item[1]['quantity']\n end\n total = price.inject(0, &:+)\n\n # before you do the final Order.create, you would at this point want to\n # run whatever 3rd party transactios you have, such as posting a\n # transaction to the OrderWise system. Then, pending the success,\n # you can then create the order record.\n\n Order.create(venue_id: cart.venue_id, total: total, products: cart.products)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update order || Category can not be changed || Placed date || Time slot can not be changed |All ids are replaced| PATCH/PUT /orders/1 Assuming Resturant sent belongs to the user region only | def update
if @order.single?
if( (Time.now + 1.hour <= Time.parse(@order.place_date + ' ' + @order.timeslot.start)) && (!@order.completed? ) && @order.update(update_order_params) )
render json: @order, status: 200
else
render json: {'errorrs': ['Order can not be updated']}, status: :unprocessable_entity
end
else
if(@order.update(update_order_params))
render json: @order, status: 200
else
render json: {'errorrs': ['Order can not be updated']}, status: :unprocessable_entity
end
end
end | [
"def update\n json_response(@order.update!(order_params))\n end",
"def update_order(order_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/orders/{order_id}',\n 'default')\n .template_param(new_parameter(order_id, key: 'order_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def update\n @place_order.update(place_order_params)\n render json: @place_order\n end",
"def update_order(id, data)\r\n @client.raw('put', \"/ecommerce/orders/#{id}\", nil, data_transform(data), @contact_v1_url)\r\n end",
"def update\n @place_order = PlaceOrder.find(params[:id])\n\n respond_to do |format|\n if @place_order.update_attributes(params[:place_order])\n format.html { redirect_to @place_order, notice: 'Place order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @place_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_content\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def update\n # if params[:state] == \"address\" && @order.quantity % 6 != 0 && @order.instore != true\n # flash[:info] = Spree.t(:sorry_you_must_order_multiples_of_six_to_to_have_them_shipped)\n # redirect_to products_path and return\n # end\n\n if params[:order][:payments_attributes].present? && Spree::PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id]).description == \"credit card\"\n aioall(@order) and return\n elsif params[:order][:time_of_day].present? && params[:order][:delivery_date].present?\n @order.time_of_day = params[:order][:time_of_day]\n @order.delivery_date = params[:order][:delivery_date]\n end\n if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)\n @order.temporary_address = !params[:save_user_address]\n unless @order.next\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to(checkout_state_path(@order.state)) && return\n end\n\n if @order.completed?\n @current_order = nil\n flash.notice = Spree.t(:order_processed_successfully)\n flash['order_completed'] = true\n redirect_to completion_route\n else\n redirect_to checkout_state_path(@order.state)\n end\n else\n render :edit\n end\n end",
"def editOrder()\n if(!User.find_by(id: params[:user_id]).authenticate(params[:password]))\n render json: {status: false, reason: \"Authentication failed!\", data: \"\"}\n return\n end\n o = Order.find_by(id: params[:order_id])\n if(o == nil)\n render json: {status: false, reason: \"Order not found!\", data: \"\"}\n return\n end\n if(o.order_status != 0)\n render json: {status: false, reason: \"Order has started processing\", data: \"\"}\n return\n end\n status = o.update(quantity: params[:quantity])\n error = \"\"\n if(o.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(order_params)\n format.html { redirect_to admin_order_path(@order), notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n \n respond_to do |format|\n if @truck_order.update(truck_order_params)\n @truck_order.truck_truck_orders.where(truck_id: nil).delete_all\n format.html { redirect_to @truck_order, notice: 'Truck order was successfully updated.' }\n format.json { render :show, status: :ok, location: @truck_order }\n else\n format.html { render :edit }\n format.json { render json: @truck_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to admin_client_path(@client), notice: 'Заказ сохренен.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_update(order)\n HTTParty.put(\"http://localhost:8082/items/order\", :body => order)\n end",
"def update\n respond_to do |format|\n if @custom_cake_order.update(custom_cake_order_params)\n format.html { redirect_to @custom_cake_order, notice: 'Custom cake order was successfully updated.' }\n format.json { render :show, status: :ok, location: @custom_cake_order }\n else\n format.html { render :edit }\n format.json { render json: @custom_cake_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:order_id].present?\n @v1_order = V1::Order.find(params[:order_id])\n else\n @v1_status_transition = V1::StatusTransition.find(params[:id])\n @v1_order = @v1_status_transition.order\n end\n case params[:v1_status_transition][:event]\n when \"place\"\n @v1_order.place\n render json: {message: \"Order placed\"}, status: 200\n when \"pay\"\n @v1_order.pay\n render json: {message: \"Order payed\"}, status: 200\n when \"cancel\"\n @v1_order.cancel\n render json: {message: \"Order Canceled\"}, status: 200\n end\n end",
"def update\n #authorize(@production_order)\n respond_to do |format|\n if @production_order.update(production_order_params)\n format.html { redirect_to @production_order, notice: 'Production order was successfully updated.' }\n format.json { render :show, status: :ok, location: @production_order }\n else\n format.html { render :edit }\n format.json { render json: @production_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_order_item\n \n end",
"def update_order_for_original_order_id(original_order_id, order: {})\n raise ArgumentError.new('original_order_id is required') if original_order_id.nil?\n\n [:order_date, :order_status, :order_items].each do |f|\n raise ArgumentError.new(\"order[:#{f}] is required\") unless order.has_key?(f)\n end\n order[:order_items].each do |oi|\n raise TypeError.new('each order item should be a type of ' << OrderItem.class.to_s) unless oi.kind_of? OrderItem\n end\n order[:order_items].map! {|i| i.to_hash }\n\n full_path = full_resource_path(\"/#{original_order_id}\")\n form_body = {order: order}\n\n MaropostApi.put_result(full_path, form_body)\n end",
"def update\n respond_to do |format|\n if @route_order.update(route_order_params)\n format.html { redirect_to @route_order, notice: 'Route order was successfully updated.' }\n format.json { render :show, status: :ok, location: @route_order }\n else\n format.html { render :edit }\n format.json { render json: @route_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@admin_order = Admin::Order.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @admin_order.update_attributes(order_params)\n\t\t\t\tif params[:order_update].present?\n\t\t\t\t\tformat.html { redirect_to edit_admin_order_path(@admin_order), notice: 'Pedido atualizado com sucesso.'}\n\t\t\t\telse\n\t\t\t\t\tformat.html { redirect_to @admin_order, notice: 'Pedido atualizado com sucesso.' }\n\t\t\t\t\tformat.json { head :no_content }\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @admin_order.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get/order/customer_recurring_orders Gets All recurring order that are used to generate auto orders for a customer || Check status | def customer_recurring_orders
# 1 represents
@orders = Order.where(customer_id: current_user.customer_id, category: :recurring)
render json: @orders, status: 200
end | [
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def fetch_customer_orders options={}\n url_options = \"/api/customer/#{system_id}/\"\n url_options += @customer_id.to_s\n url_options += \"/orders\"\n url_options += (\"/?\" + options.map{|k,v| \"#{k}=#{v}\"}.join(\"&\"))\n resp = send_request(@url + url_options)\n begin\n Hash.from_xml(resp.body)\n rescue REXML::ParseException => e\n pp e\n {}\n end\n end",
"def list_orders()\n get_request('listOrders?'+get_url_parameters({})).body\n end",
"def get_all_wr_for_customer_order\n token_ok, token_error = helpers.API_validate_token(request)\n if not token_ok\n render json: {message: token_error }, status: 401\n else\n \n if params['customer_order_id'] == 0 then\n @wr_orders = []\n\n else\n begin\n @wr_orders = WarehouseReceipt.where(customer_order_id: params['customer_order_id']).map do |o|\n {\n id: o.id,\n orderNo: o.order_no\n }\n end\n rescue ActiveRecord::RecordNotFound\n @wr_orders = []\n end\n \n end\n\n respond_to do |format|\n format.json { render json: @wr_orders }\n end\n end\n end",
"def list_orders(code)\n PsegRecurring::Order.new(@credentials).fetch_orders(code)\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def fetch_orders(code)\n begin\n response = RestClient.get(\n \"#{@environment}/pre-approvals/#{code}/payment-orders?email=#{@email}&token=#{@token}\", \n {\n content_type: \"application/json;charset=ISO-8859-1\",\n accept: \"application/vnd.pagseguro.com.br.v3+xml;charset=ISO-8859-1\"\n }\n )\n xml = Nokogiri::XML(response)\n data = Order::Serializer.new(xml).orders\n return { :error => false, :orders => data[:orders] }\n \n rescue RestClient::ExceptionWithResponse => e\n error = PsegRecurring::Error.new(e.response).process\n return { :error => true, :detail => error[:errors] }\n \n rescue StandardError => e\n Rails.logger.error { \"STD ERROR -- MSG: #{e.response}\" }\n return { :error => true, :detail => e.response }\n end\n end",
"def get_all_orders\n orders = []\n page = 0\n loop do\n orders_page = self.get_orders_page page\n page += 1\n orders.push *orders_page.orders\n break if (page * orders_page.results_per_page >= orders_page.total_count)\n end\n orders\n end",
"def all_orders(symbol:, order_id: nil, start_time: nil, end_time: nil, limit: nil, recv_window: nil)\n params = {\n symbol: symbol,\n }\n params[:orderId] = order_id if order_id\n params[:startTime] = start_time if start_time\n params[:endTime] = end_time if end_time\n params[:limit] = limit if limit\n params[:recvWindow] = recv_window if recv_window\n\n SignedRequest.perform({\n request_method: :get,\n path: '/api/v3/allOrders',\n params: params,\n })\n end",
"def query_order(options)\n request :account, :get, 'order', options\n end",
"def get_order_list(criteria = {})\n order_criteria = {}\n order_criteria[\"ins1:OrderCreationFilterBeginTimeGMT\"] = criteria[:created_from]\n order_criteria[\"ins1:OrderCreationFilterEndTimeGMT\"] = criteria[:created_to]\n order_criteria[\"ins1:StatusUpdateFilterBeginTimeGMT\"] = criteria[:updated_from]\n order_criteria[\"ins1:StatusUpdateFilterEndTimeGMT\"] = criteria[:updated_to]\n order_criteria[\"ins1:JoinDateFiltersWithOr\"] = criteria[:join_dates]\n\n if order_ids = criteria[:order_ids]\n order_criteria[\"ins1:OrderIDList\"] = {\"ins1:int\" => order_ids}\n end\n\n if client_order_ids = criteria[:client_order_ids]\n order_criteria[\"ins1:ClientOrderIdentifierList\"] = {\"ins1:string\" => client_order_ids}\n end\n\n order_criteria[\"ins1:DetailLevel\"] = criteria[:detail_level] if criteria[:detail_level]\n order_criteria[\"ins1:ExportState\"] = criteria[:export_state] if criteria[:export_state]\n order_criteria[\"ins1:OrderStateFilter\"] = criteria[:state] if criteria[:state]\n order_criteria[\"ins1:PaymentStatusFilter\"] = criteria[:payment_status] if criteria[:payment_status]\n order_criteria[\"ins1:CheckoutStatusFilter\"] = criteria[:checkout_status] if criteria[:checkout_status]\n order_criteria[\"ins1:ShippingStatusFilter\"] = criteria[:shipping_status] if criteria[:shipping_status]\n order_criteria[\"ins1:RefundStatusFilter\"] = criteria[:refund_status] if criteria[:refund_status]\n order_criteria[\"ins1:DistributionCenterCode\"] = criteria[:distribution_center] if criteria[:distribution_center]\n order_criteria[\"ins1:PageNumberFilter\"] = criteria[:page_number]\n order_criteria[\"ins1:PageSize\"] = criteria[:page_size]\n\n soap_response = client.request :get_order_list do\n soap.header = soap_header\n soap.body = {\n \"ins0:accountID\" => creds(:account_id),\n \"ins0:orderCriteria\" => order_criteria\n }\n end\n\n @last_request = client.http\n @last_response = soap_response\n end",
"def orders_including_customer\n Spree::Order\n .joins(:order_cycle)\n .includes(:customer)\n .for_order_cycle(order_cycle)\n .completed\n .order('customers.name ASC')\n end",
"def list_orders(response)\n group = get_group(response.user.name)\n response.reply(\"Current orders for #{group}:-\\n--\")\n get_orders(group).each do |order|\n response.reply(\"#{order}: #{get_coffee(order)}\")\n end\n end",
"def list_recurring_details(shopper_reference)\n RecurringService.new(:shopper => { :reference => shopper_reference }).list\n end",
"def all_charges(customer_id)\n get(\"#{customer_id}/charges\")\n end",
"def driver_recurring_orders\n @orders = Timeslot.joins(:orders).where(orders: { category: :recurring}, timeslots: {region_id: current_user.driver.region_id})\n render json: @orders, status: 200\n end",
"def all(params = {})\n @client.make_request(:get, 'referral_customers', MODEL_CLASS, params)\n end",
"def get_orders\n orders\n end",
"def get_all_orders\n @orders = Order.all\n\n @show_detail = true\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get/order/customer_single_orders Get all single order regardless they are manual or auto for a customer | def customer_single_orders
@orders = Order.where(customer_id: current_user.customer_id, category: :single)
render json: @orders, status: 200
end | [
"def fetch_customer_orders options={}\n url_options = \"/api/customer/#{system_id}/\"\n url_options += @customer_id.to_s\n url_options += \"/orders\"\n url_options += (\"/?\" + options.map{|k,v| \"#{k}=#{v}\"}.join(\"&\"))\n resp = send_request(@url + url_options)\n begin\n Hash.from_xml(resp.body)\n rescue REXML::ParseException => e\n pp e\n {}\n end\n end",
"def get_all_wr_for_customer_order\n token_ok, token_error = helpers.API_validate_token(request)\n if not token_ok\n render json: {message: token_error }, status: 401\n else\n \n if params['customer_order_id'] == 0 then\n @wr_orders = []\n\n else\n begin\n @wr_orders = WarehouseReceipt.where(customer_order_id: params['customer_order_id']).map do |o|\n {\n id: o.id,\n orderNo: o.order_no\n }\n end\n rescue ActiveRecord::RecordNotFound\n @wr_orders = []\n end\n \n end\n\n respond_to do |format|\n format.json { render json: @wr_orders }\n end\n end\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def get_auto_orders(opts = {})\n data, _status_code, _headers = get_auto_orders_with_http_info(opts)\n data\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def get_all_orders\n @orders = Order.all\n\n @show_detail = true\n end",
"def retrieveByCust\n @id = params[:customerId]\n @email = params[:email]\n \n if params[:email].present?\n @code, @customer = Customer.getByEmail(@email)\n if @code == 200\n @id = @customer[:id]\n end\n end\n @orders = Order.where(customerId: @id)\n render json: @orders, status:200\n end",
"def customer_order\n @customer_order\n end",
"def get_customer_order\n begin\n db = SQLite3::Database.open(ENV[\"BANGAZON\"])\n array_of_orders = db.execute(\"SELECT customers.id 'Customer Number', customers.last_name 'Last Name', customers.first_name 'First Name', orders.id 'Order Number', products.product_title 'Product', products.product_price 'Price'\n FROM orders, customers, order_products, products\n\n WHERE orders.customer_id = ?\n AND orders.id = ?\n AND order_products.product_id = products.id\", [@customer_id, @id])\n db.close\n end\n array_of_orders\n end",
"def retrieve_customer_orders(customer_id)\n @all_customer_orders = @db.execute(\"SELECT * FROM Orders WHERE customer_id = #{customer_id}\")\n return @all_customer_orders\n end",
"def getOrder\n if request.query_string.present? \n if params[:id].present?\n @order=Order.find_by(id: params[:id])\n if @order.nil?\n render(json: {messages: 'Order for the order Id not found'}, status: 404)\n\n else\n render \"order.json.jbuilder\"\n end\n elsif params[:customerId].present?\n @order = Order.where(:customerId => params[:customerId])\n #@order is an ActiveRecord::Relation @order.where returns an ActiveRecord::Relation\n #converting @order to an array of Order objects\n\n if @order.empty?\n render(json: {messages: 'Order for customer Id not found'}, status: 404)\n else\n @order=@order.to_a\n render \"abc.json.jbuilder\"\n end \n elsif params[:email].present?\n #retrieving the customer information from the customer app\n code, @customer = Customer.getCustomerByEmail(params[:email]) #customer is the response from the method\n # in customer helper class\n if code != 200 #the item doesn't exist\n render(json: {messages: 'Customer email does not exist'}, status: 400)\n return\n end \n id=@customer[\"id\"]\n p id, \"This is the customer ID\"\n #find the order using the customer Id\n @order = Order.where(:customerId => id)\n @order.to_a\n if @order.empty?\n #head 404 #error - not found\n render(json: {messages: 'Order for customer email not found'}, status: 404)\n else\n render \"abc.json.jbuilder\"\n end \n else\n render(json: {messages: 'Order not found'}, status: 404)\n end \n end\n end",
"def orders_including_customer\n Spree::Order\n .joins(:order_cycle)\n .includes(:customer)\n .for_order_cycle(order_cycle)\n .completed\n .order('customers.name ASC')\n end",
"def get_auto_orders_batch(auto_order_batch, opts = {})\n data, _status_code, _headers = get_auto_orders_batch_with_http_info(auto_order_batch, opts)\n data\n end",
"def get_all_orders\n orders = []\n page = 0\n loop do\n orders_page = self.get_orders_page page\n page += 1\n orders.push *orders_page.orders\n break if (page * orders_page.results_per_page >= orders_page.total_count)\n end\n orders\n end",
"def list_orders()\n get_request('listOrders?'+get_url_parameters({})).body\n end",
"def get_orders(product_id='', status='')\n timestamp = Time.now.utc.to_i\n method = 'GET'\n request_path = \"/orders?product_id=#{product_id}\" if product_id\n request_path = \"/orders\" unless request_path\n body = ''\n signature = signature(request_path, body, timestamp, method)\n headers = headers(@key, signature, timestamp, @passphrase)\n return RestClient.get(@api+request_path, headers)\n end",
"def get_orders\n orders\n end",
"def orders\n @title = \"Your Orders\"\n @orders = @customer.orders.paginate(\n :page => params[:page],\n :per_page => 10\n )\n end",
"def get(event_id, order_id)\n @client.request \"events/#{event_id}/orders/#{order_id}\"\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get/order/driver_recurring_orders Gets recurring order that are used to generate auto orders for a driver | def driver_recurring_orders
@orders = Timeslot.joins(:orders).where(orders: { category: :recurring}, timeslots: {region_id: current_user.driver.region_id})
render json: @orders, status: 200
end | [
"def list_orders(code)\n PsegRecurring::Order.new(@credentials).fetch_orders(code)\n end",
"def fetch_orders(code)\n begin\n response = RestClient.get(\n \"#{@environment}/pre-approvals/#{code}/payment-orders?email=#{@email}&token=#{@token}\", \n {\n content_type: \"application/json;charset=ISO-8859-1\",\n accept: \"application/vnd.pagseguro.com.br.v3+xml;charset=ISO-8859-1\"\n }\n )\n xml = Nokogiri::XML(response)\n data = Order::Serializer.new(xml).orders\n return { :error => false, :orders => data[:orders] }\n \n rescue RestClient::ExceptionWithResponse => e\n error = PsegRecurring::Error.new(e.response).process\n return { :error => true, :detail => error[:errors] }\n \n rescue StandardError => e\n Rails.logger.error { \"STD ERROR -- MSG: #{e.response}\" }\n return { :error => true, :detail => e.response }\n end\n end",
"def query_order(options)\n request :account, :get, 'order', options\n end",
"def get_orders\n orders\n end",
"def customer_recurring_orders\n # 1 represents \n @orders = Order.where(customer_id: current_user.customer_id, category: :recurring)\n render json: @orders, status: 200\n \n \n end",
"def last_active_recurring_order\n self.orders.recurring.find(:all, :order => \"orders.id ASC\").select {|o| Date.today >= o.service_period_start_on && Date.today <= o.service_period_end_on}.last\n end",
"def order_trades(order_id)\n get(\"order.trades\", {order_id: order_id})\n end",
"def list_recurring_details(shopper_reference)\n RecurringService.new(:shopper => { :reference => shopper_reference }).list\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def retrieve_order(order_id)\n\n end",
"def list_orders()\n get_request('listOrders?'+get_url_parameters({})).body\n end",
"def get_auto_orders_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AutoOrderApi.get_auto_orders ...'\n end\n # resource path\n local_var_path = '/auto_order/auto_orders'\n\n # query parameters\n query_params = {}\n query_params[:'auto_order_code'] = opts[:'auto_order_code'] if !opts[:'auto_order_code'].nil?\n query_params[:'original_order_id'] = opts[:'original_order_id'] if !opts[:'original_order_id'].nil?\n query_params[:'first_name'] = opts[:'first_name'] if !opts[:'first_name'].nil?\n query_params[:'last_name'] = opts[:'last_name'] if !opts[:'last_name'].nil?\n query_params[:'company'] = opts[:'company'] if !opts[:'company'].nil?\n query_params[:'city'] = opts[:'city'] if !opts[:'city'].nil?\n query_params[:'state'] = opts[:'state'] if !opts[:'state'].nil?\n query_params[:'postal_code'] = opts[:'postal_code'] if !opts[:'postal_code'].nil?\n query_params[:'country_code'] = opts[:'country_code'] if !opts[:'country_code'].nil?\n query_params[:'phone'] = opts[:'phone'] if !opts[:'phone'].nil?\n query_params[:'email'] = opts[:'email'] if !opts[:'email'].nil?\n query_params[:'original_order_date_begin'] = opts[:'original_order_date_begin'] if !opts[:'original_order_date_begin'].nil?\n query_params[:'original_order_date_end'] = opts[:'original_order_date_end'] if !opts[:'original_order_date_end'].nil?\n query_params[:'next_shipment_date_begin'] = opts[:'next_shipment_date_begin'] if !opts[:'next_shipment_date_begin'].nil?\n query_params[:'next_shipment_date_end'] = opts[:'next_shipment_date_end'] if !opts[:'next_shipment_date_end'].nil?\n query_params[:'card_type'] = opts[:'card_type'] if !opts[:'card_type'].nil?\n query_params[:'item_id'] = opts[:'item_id'] if !opts[:'item_id'].nil?\n query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?\n query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?\n query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?\n query_params[:'_since'] = opts[:'_since'] if !opts[:'_since'].nil?\n query_params[:'_sort'] = opts[:'_sort'] if !opts[:'_sort'].nil?\n query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AutoOrdersResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AutoOrderApi#get_auto_orders\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_4_last_success_bid_orders\n @orders = Order.where(status: 2).order(deal_date: :desc).limit(4)\n end",
"def get(event_id, order_id)\n @client.request \"events/#{event_id}/orders/#{order_id}\"\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def get_recurrence(user_id)\n result = @tropo_client.get(\"users/#{user_id}/payment/recurrence\")\n end",
"def get_order()\n\n\nend",
"def get_order(symbol:, order_id: nil, orig_client_order_id: nil, new_client_order_id: nil, recv_window: nil)\n params = {\n symbol: symbol\n }\n params[:orderId] = order_id if order_id\n params[:origClientOrderId] = orig_client_order_id if orig_client_order_id\n params[:newClientOrderId] = new_client_order_id if new_client_order_id\n params[:recvWindow] = recv_window if recv_window\n\n SignedRequest.perform({\n request_method: :get,\n path: '/api/v3/order',\n params: params,\n })\n end",
"def drivers_unique\n driver_order_times.map{|dto| dto.order}.uniq\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get/order/driver_single_orders Get all single order regardless they are manual or auto for a driver | def driver_single_orders
@orders = Timeslot.joins(:orders).where(orders: { category: :single}, timeslots: {region_id: current_user.driver.region_id})
render json: @orders, status: 200
end | [
"def get_orders\n orders\n end",
"def get_all_orders\n @orders = Order.all\n\n @show_detail = true\n end",
"def get_auto_orders(opts = {})\n data, _status_code, _headers = get_auto_orders_with_http_info(opts)\n data\n end",
"def get_orders(product_id='', status='')\n timestamp = Time.now.utc.to_i\n method = 'GET'\n request_path = \"/orders?product_id=#{product_id}\" if product_id\n request_path = \"/orders\" unless request_path\n body = ''\n signature = signature(request_path, body, timestamp, method)\n headers = headers(@key, signature, timestamp, @passphrase)\n return RestClient.get(@api+request_path, headers)\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end",
"def orders_unique\n driver_order_times.map{|dto| dto.order}.uniq\n end",
"def retrieve_order(order_id)\n\n end",
"def find_all_by(opts = {})\n list_all_orders(opts)\n end",
"def query_order(options)\n request :account, :get, 'order', options\n end",
"def drivers_unique\n driver_order_times.map{|dto| dto.order}.uniq\n end",
"def get_all_orders\n orders = []\n page = 0\n loop do\n orders_page = self.get_orders_page page\n page += 1\n orders.push *orders_page.orders\n break if (page * orders_page.results_per_page >= orders_page.total_count)\n end\n orders\n end",
"def get(event_id, order_id)\n @client.request \"events/#{event_id}/orders/#{order_id}\"\n end",
"def get_orders(debtor_handle)\n response = request :get_orders, {\n 'debtorHandle' => { 'Number' => debtor_handle.number }\n }\n if response.empty?\n nil\n else\n entities = []\n [response[:order_handle]].flatten.each do |handle|\n entity = Economic::Order.new(:session => session)\n entity.partial = true\n entity.persisted = true\n entity.handle = handle\n entity.number = handle[:id].to_i\n entities << entity\n end\n entities\n end\n end",
"def getOrderDetail(orderId)\n try_get(\"https://checkout.google.com/sell/multiOrder?order=#{orderId}&ordersTable=1\")\n return @agent.page.body\n end",
"def find_many(options = {})\n client.find_many(Spire::Purchasing::Order, \"/purchasing/orders/\", options)\n end",
"def find_one_by(opts = {})\n list_all_order_line_items(opts)[0]\n end",
"def find_many(options = {})\n client.find_many(Spire::Production::Order, \"/production/orders/\", options)\n end",
"def get_auto_orders_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AutoOrderApi.get_auto_orders ...'\n end\n # resource path\n local_var_path = '/auto_order/auto_orders'\n\n # query parameters\n query_params = {}\n query_params[:'auto_order_code'] = opts[:'auto_order_code'] if !opts[:'auto_order_code'].nil?\n query_params[:'original_order_id'] = opts[:'original_order_id'] if !opts[:'original_order_id'].nil?\n query_params[:'first_name'] = opts[:'first_name'] if !opts[:'first_name'].nil?\n query_params[:'last_name'] = opts[:'last_name'] if !opts[:'last_name'].nil?\n query_params[:'company'] = opts[:'company'] if !opts[:'company'].nil?\n query_params[:'city'] = opts[:'city'] if !opts[:'city'].nil?\n query_params[:'state'] = opts[:'state'] if !opts[:'state'].nil?\n query_params[:'postal_code'] = opts[:'postal_code'] if !opts[:'postal_code'].nil?\n query_params[:'country_code'] = opts[:'country_code'] if !opts[:'country_code'].nil?\n query_params[:'phone'] = opts[:'phone'] if !opts[:'phone'].nil?\n query_params[:'email'] = opts[:'email'] if !opts[:'email'].nil?\n query_params[:'original_order_date_begin'] = opts[:'original_order_date_begin'] if !opts[:'original_order_date_begin'].nil?\n query_params[:'original_order_date_end'] = opts[:'original_order_date_end'] if !opts[:'original_order_date_end'].nil?\n query_params[:'next_shipment_date_begin'] = opts[:'next_shipment_date_begin'] if !opts[:'next_shipment_date_begin'].nil?\n query_params[:'next_shipment_date_end'] = opts[:'next_shipment_date_end'] if !opts[:'next_shipment_date_end'].nil?\n query_params[:'card_type'] = opts[:'card_type'] if !opts[:'card_type'].nil?\n query_params[:'item_id'] = opts[:'item_id'] if !opts[:'item_id'].nil?\n query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?\n query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?\n query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?\n query_params[:'_since'] = opts[:'_since'] if !opts[:'_since'].nil?\n query_params[:'_sort'] = opts[:'_sort'] if !opts[:'_sort'].nil?\n query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AutoOrdersResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AutoOrderApi#get_auto_orders\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
put/order/1 Mark a order as complete by driver | def mark_order_complete
order_params = (driver_order_params)
order_params[:payable_attributes][:driver_id] = current_user.customer_id
if @order.single?
if( (Time.now >= Time.parse(@order.place_date + ' ' + @order.timeslot.start) || true) && (@order.pending? ) && @order.update(order_params) )
render json: @order, status: 200
else
render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity
end
else
if(@order.update(order_params))
render json: @order, status: 200
else
render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity
end
end
end | [
"def order_complete!\n self.state = 'complete'\n self.completed_at = Time.zone.now\n update_inventory\n end",
"def complete_order\n order = self.pending_order\n order.completed = true\n order.amount = @po.sum(:amount)\n order.date = Time.now.to_s\n order.save\n end",
"def end_ordering!\n @io.acquire :write do |io|\n @logger.debug { \"Announcing, everything has been ordered.\" }\n \n io.write RbSync::Protocol::Message::new({\n :type => :order,\n :end => true\n })\n end\n end",
"def complete_order # 3. Run this method to print order and accept/reject\n\t\tdisplay_full_order\n\t\taccept_order\t\n\tend",
"def order_complete\n load_order\n if @order.state == 'canceled'\n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n @order.update_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def finalize_order(order, domain, alt_names)\n require 'acme-client'\n\n # Create and certificate request and finalize order\n csr = Acme::Client::CertificateRequest.new(common_name: domain, names: alt_names)\n order.finalize(csr: csr)\n\n # Wait for order's status to change\n while order.status == 'processing'\n sleep(1)\n order.reload\n end\n end",
"def complete_order\n @queue.dequeue\n end",
"def complete_order_service\n\n order_service = OrderService.find(params[:order_service_id])\n order_service.completed = true\n order_service.save\n\n completed = true\n order_service.order.order_services.each do |order_service|\n if !order_service.completed\n completed = false\n end\n end\n if completed\n order_service.order.status = true\n order_service.order.save\n end\n \n redirect_to order_path(order_service.order.id)\n end",
"def complete!\n self.completed = true\n self.completed_at = Time.now.utc\n save! # TODO: With a bang?\n end",
"def finish\n @order.finish\n render_update @order\n end",
"def set_to_ordered\n self.status = \"ordered\"\n self.save\n end",
"def mark_complete\n\t\t@completed_status = true\n\tend",
"def complete\n @tour_order.complete\n respond_to do |format|\n if @tour_order.save\n format.html { redirect_to @tour_order, notice: 'Tour order was successfully completed.' }\n format.json { render :show, status: :ok, location: @tour_order }\n else\n format.html { redirect_to @tour_order }\n format.json { render json: @tour_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def place_order\n current_order.place_order\n current_order.save\n remove_order\n end",
"def place_and_complete_item_order(ordered_by, facility, account = nil, reviewed = false)\n @facility_account = FactoryBot.create(:facility_account, facility: facility)\n @item = facility.items.create(FactoryBot.attributes_for(:item, facility_account_id: @facility_account.id))\n place_product_order(ordered_by, facility, @item, account)\n\n # act like the parent order is valid\n @order.state = \"validated\"\n\n # purchase it\n @order.purchase!\n\n @order_detail.change_status!(OrderStatus.complete)\n\n od_attrs = {\n actual_cost: 20,\n actual_subsidy: 10,\n price_policy_id: @item_pp.id,\n }\n\n od_attrs[:reviewed_at] = Time.zone.now - 1.day if reviewed\n @order_detail.update(od_attrs)\n @order_detail\nend",
"def complete_item\n \t@completed_status = true\n end",
"def update_totals_and_complete_free_order\n @order.update_totals!\n if @order.in_progress? and @order.item_total > 0 and @order.total == 0 and @order.payments.total == 0\n until @order.checkout.complete?\n @order.checkout.next!\n end\n @order.reload.pay!\n end\n end",
"def pending_order\n order = orders.find_or_create_by(completed: false)\n end",
"def complete\n @supplier_stock_order = SupplierStockOrder.find(params[:id])\n @product = @supplier_stock_order.product\n @stock_location = StockLocation.where(\"previous_location_id is NULL\")\n\n\n #Mark as processed\n #Event-b: act1: orderStatus ≔ orderStatus <+ {product ↦ Completed}\n @supplier_stock_order.update_attribute(:status,\"Completed\")\n @supplier_stock_order.save\n\n #Event-b: productlevels(product) ≔ productlevels(product) <+ {Warehouse ↦ (productlevels(product)(Warehouse) + orders(product))}\n @stock_level = StockLevel.find_by_product_id_and_stock_location_id(@product,@stock_location)\n @stock_level.update_attribute(:quantity, (@stock_level.quantity + @supplier_stock_order.quantity))\n @stock_level.save\n\n \n\n\n respond_to do |format|\n format.html { redirect_to supplier_stock_orders_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
xroad_id may be either ClientId or ServerId. | def verify_xroad_instance(xroad_id)
logger.debug("Instance verification: #{xroad_id}")
unless @xroad_instance.eql?(xroad_id.xroad_instance)
raise t("request.incorrect_instance")
end
end | [
"def verify_xroad_instance(xroad_id)\n logger.debug(\"Instance verification: #{xroad_id}\")\n\n unless @xroad_instance.eql?(xroad_id.xroad_instance)\n raise t(\"request.incorrect_instance\")\n end\n end",
"def set_net_id(x)\n $test_logger.log(\"Serial net Id change. New net Id '#{x}'\")\n begin\n @transport.net_id = x\n rescue Exception => e\n $test_logger.log_e(\"Error while changing serial net Id to '#{x}'\", e)\n end\n end",
"def set_x_ip_addr(x_ip_addr)\n @x_ip_addr = x_ip_addr\n end",
"def osm_id\n @osm_id ||= @attrs[:osm_id].to_i if @attrs[:osm_id]\n end",
"def client_id= id=nil\n self.request_id = Daylight::RequestId.new(id)\n end",
"def server_id\n @server_id\n end",
"def identifier\n\t\t\t@ship.object_id\n\t\tend",
"def server_id=(value)\n @server_id = value\n end",
"def add_ssids_to_guest_access_portal_for_xms_e_only(args = {}) \n body_put(\"/guestaccess.json/gap/ssid/#{args[:gapId]}\", args[:array_of_ids])\nend",
"def midtown_primary_roads\n midtown_north = 40.764104432913086\n midtown_east = -73.97675156593323\n midtown_south = 40.75897668730365\n midtown_west = -73.98523807525635\n OverpassGraph.get_roads(midtown_north, midtown_east, midtown_south, midtown_west, ['primary'], [])\nend",
"def server_object_id\n self.parameters[:server_object_id]\n end",
"def remove_crossroad(v)\n @downtown.remove_vertex(v)\n @num_crossroad = @num_crossroad - 1\n\tend",
"def openid_client_id=(_arg0); end",
"def lygneo_id\n @lygneo_id ||= params['lygneo_id'].strip\n end",
"def midtown_no_primary_roads\n midtown_north = 40.764104432913086\n midtown_east = -73.97675156593323\n midtown_south = 40.75897668730365\n midtown_west = -73.98523807525635\n OverpassGraph.get_roads(midtown_north, midtown_east, midtown_south, midtown_west, [], ['primary'])\nend",
"def add_crossroad(v)\n @downtown.add_crossroad(v)\n @num_crossroad = @num_crossroad + 1\n\tend",
"def is_widower_of( x ) #veuf\n node = @graph.add_nodes( \"#{@node.id}And#{x.node.id}\" )\n node[\"shape\"] = \"point\"\n node[\"color\"] = \"green\"\n @graph.add_edges( @node, node, \"dir\" => \"none\", \"color\" => \"green\" )\n @graph.add_edges( node, x.node, \"dir\" => \"none\", \"color\" => \"green\" )\n @tree.add_couple( self, x, node )\n end",
"def dxfId; end",
"def set_client_id(id)\n @client_id = id.is_a?(Integer) ? [id].pack(\"N\") : id.to_s\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /agenciamadres/1 GET /agenciamadres/1.xml | def show
@agenciamadre = Agenciamadre.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @agenciamadre }
end
end | [
"def show\n @ag = Ag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ag }\n end\n end",
"def show\n @agua = Agua.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @agua }\n end\n end",
"def show\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end",
"def show\n @arrendamientosprorroga = Arrendamientosprorroga.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arrendamientosprorroga }\n end\n end",
"def show\n @retencionganancia = Retencionganancia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @retencionganancia }\n end\n end",
"def show\n @raga = Raga.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @raga }\n end\n end",
"def show\n @resenha = Resenha.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @resenha }\n end\n end",
"def show\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @agendamento }\n end\n end",
"def show\n @imagen_de_legajo = @legajo.imagenes_de_legajos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @imagen_de_legajo }\n end\n end",
"def xml(options = {})\n host = Picasa.host\n path = Picasa.path(options)\n url = URI(\"#{host}#{path}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n req = add_auth_headers(Net::HTTP::Get.new url.path)\n\n response = http.request(req)\n if response.code =~ /20[01]/\n response.body\n end\n end",
"def index\n @acres = Acre.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @acres }\n end\n end",
"def show\n @rege = Rege.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rege }\n end\n end",
"def show\n @scrap_xml = ScrapXml.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scrap_xml }\n end\n end",
"def show\n @registro_alimento = RegistroAlimento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @registro_alimento }\n end\n end",
"def show\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb.erb\n format.xml { render :xml => @frequencia_orgao }\n end\n end",
"def show\n @adresdb = Adresdb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adresdb }\n end\n end",
"def show\n @daily_grr = DailyGrr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @daily_grr }\n end\n end",
"def show\n @gene_ontology = GeneOntology.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end",
"def index\n @retencionganancias = Retencionganancia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retencionganancias }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /agenciamadres/new GET /agenciamadres/new.xml | def new
@agenciamadre = Agenciamadre.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @agenciamadre }
end
end | [
"def new\n @ag = Ag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ag }\n end\n end",
"def new\n @relatestagiario = Relatestagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatestagiario }\n end\n end",
"def new\n @agua = Agua.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @agua }\n end\n end",
"def new\n @generomidia = Generomidia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @generomidia }\n end\n end",
"def new\n @revista = Revista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @revista }\n end\n end",
"def new\n @rel = Rel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rel }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @arrendamientosprorroga = Arrendamientosprorroga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @arrendamientosprorroga }\n end\n end",
"def new\n @agendamento = Agendamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @agendamento }\n end\n end",
"def new\n @agari = Agari.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @agari }\n end\n end",
"def new\n @reged = Reged.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reged }\n end\n end",
"def new\n @resenha = Resenha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resenha }\n end\n end",
"def new\n @gene_ontology = GeneOntology.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end",
"def new\n @registro_alimento = RegistroAlimento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @registro_alimento }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @raga = Raga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @raga }\n end\n end",
"def new\n @apto = Apto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @apto }\n end\n end",
"def new\n @reoccurrence = Reoccurrence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reoccurrence }\n end\n end",
"def new\n @generacion = Generacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @generacion }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /agenciamadres POST /agenciamadres.xml | def create
@agenciamadre = Agenciamadre.new(params[:agenciamadre])
respond_to do |format|
if @agenciamadre.save
format.html { redirect_to(@agenciamadre, :notice => 'Agencia Madre fue creada satisfactoriamente.') }
format.xml { render :xml => @agenciamadre, :status => :created, :location => @agenciamadre }
else
format.html { render :action => "new" }
format.xml { render :xml => @agenciamadre.errors, :status => :unprocessable_entity }
end
end
end | [
"def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params[:desc])\n # no strip\n # post_body << params[:desc]\n post_body << \"</Body></Document>\"\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field(\"Content-Type\",\"text/xml\")\n request.add_field(\"outputFormat\",\"application/json\")\n #request.add_field(\"outputFormat\",\"text/n3\") \n request.add_field(\"x-ag-access-token\",\"fY7WUM3GGCXHm9ATOhtzhrvlWX8oPo5X\")\n request.body = post_body.join\n # request[\"Content-Type\"] = \"multipart/form-data, boundary=#{BOUNDARY}\"\n\n render :json => http.request(request).body\n end",
"def create\n @agua = Agua.new(params[:agua])\n\n respond_to do |format|\n if @agua.save\n flash[:notice] = 'Agua was successfully created.'\n format.html { redirect_to(@agua) }\n format.xml { render :xml => @agua, :status => :created, :location => @agua }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @agua.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n \tif session[:user_type] != \"admin-mx\" && session[:user_type] != \"agent\" # basic security trap\n\t return\n \tend\n \t\n @agcommision = Agcommision.new(params[:agcommision])\n\n respond_to do |format|\n if @agcommision.save\n format.xml { render :xml => @agcommision, :status => :created, :location => @agcommision }\n else\n format.xml { render :xml => @agcommision.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def create\n @agri = Agri.new(agri_params)\n\n respond_to do |format|\n if @agri.save\n format.html { redirect_to @agri, notice: \"Agri was successfully created.\" }\n format.json { render :show, status: :created, location: @agri }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @agri.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agendamento = Agendamento.new(params[:agendamento])\n\n respond_to do |format|\n if @agendamento.save\n format.html { redirect_to(@agendamento, :notice => 'Agendamento was successfully created.') }\n format.xml { render :xml => @agendamento, :status => :created, :location => @agendamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @agendamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @agronomiagalera = Agronomiagalera.new(params[:agronomiagalera])\n\n respond_to do |format|\n if @agronomiagalera.save\n format.html { redirect_to @agronomiagalera, notice: 'Agronomiagalera was successfully created.' }\n format.json { render json: @agronomiagalera, status: :created, location: @agronomiagalera }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiagalera.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @agenciamadre = Agenciamadre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @agenciamadre }\n end\n end",
"def post_expense_xml(xml)\n #request header bekommt Content-type = xml\n header \"Content-Type\", \"text/xml\" \n #expense daten werden alsl xml per Post request an den Server gesendet\n post '/expenses', xml\n #es wird erwartet das dies erfolgreich war\n expect(last_response.status).to eq(200)\n\n parsed = Ox.load(last_response.body, mode: :hash)\n expect(parsed).to include('expense_id' => a_kind_of(Integer))\n #adds an id key to the expense hash, containing the id from the database, after an expense is succesfully stored\n expense.merge('id' => parsed['expense_id'])\nend",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def create\n @ag_resident = Ag::Resident.new(ag_resident_params)\n\n respond_to do |format|\n if @ag_resident.save\n format.html { redirect_to @ag_resident, notice: 'Resident was successfully created.' }\n format.json { render :show, status: :created, location: @ag_resident }\n else\n format.html { render :new }\n format.json { render json: @ag_resident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @raga = Raga.new(params[:raga])\n\n respond_to do |format|\n if @raga.save\n flash[:notice] = 'Raga was successfully created.'\n format.html { redirect_to(@raga) }\n format.xml { render :xml => @raga, :status => :created, :location => @raga }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @raga.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @causa_egreso = CausaEgreso.new(params[:causa_egreso])\n\n respond_to do |format|\n if @causa_egreso.save\n format.html { redirect_to(@causa_egreso, :notice => 'Causa egreso was successfully created.') }\n format.xml { render :xml => @causa_egreso, :status => :created, :location => @causa_egreso }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @causa_egreso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @agendashorario = Agendashorario.new(params[:agendashorario])\n\n respond_to do |format|\n if @agendashorario.save\n format.html { redirect_to(@agendashorario, :notice => 'Agendashorario was successfully created.') }\n format.xml { render :xml => @agendashorario, :status => :created, :location => @agendashorario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @agendashorario.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @annonce = Annonce.new(params[:annonce])\n\n respond_to do |format|\n if @annonce.save\n flash[:notice] = \"Annonce enregistrée avec succès.\"\n format.html { redirect_to(@annonce) }\n format.xml { render :xml => @annonce, :status => :created, :location => @annonce }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @annonce.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @arrendamientosprorroga = Arrendamientosprorroga.new(params[:arrendamientosprorroga])\n\n respond_to do |format|\n if @arrendamientosprorroga.save\n format.html { redirect_to(@arrendamientosprorroga, :notice => 'Arrendamientosprorroga was successfully created.') }\n format.xml { render :xml => @arrendamientosprorroga, :status => :created, :location => @arrendamientosprorroga }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @arrendamientosprorroga.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @acre = Acre.new(params[:acre])\n\n respond_to do |format|\n if @acre.save\n format.html { redirect_to(acres_path, :notice => 'Acre was successfully created.') }\n format.xml { render :xml => @acre, :status => :created, :location => @acre }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @acre.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @agronomiaquimica = Agronomiaquimica.new(params[:agronomiaquimica])\n\n respond_to do |format|\n if @agronomiaquimica.save\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully created.' }\n format.json { render json: @agronomiaquimica, status: :created, location: @agronomiaquimica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get next yahrzeit date on or after "from" date | def next_yahrzeit_date(from=Date.today)
return unless death_date
# TODO: use Marlena rules
h_from = Hebruby::HebrewDate.new(from)
h_death = Hebruby::HebrewDate.new(death_date)
# yahrzeit date from year
h_yahrzeit = Hebruby::HebrewDate.new(h_death.day, h_death.month, h_from.year)
date = Date.jd(h_yahrzeit.jd)
if date < from
h_yahrzeit = Hebruby::HebrewDate.new(h_death.day, h_death.month, h_from.year+1)
date = Date.jd(h_yahrzeit.jd)
end
date
end | [
"def next_date(from_date = nil)\n return nil if blank?\n from_date ||= if Date.respond_to?(:current)\n Date.current\n else\n Date.today\n end\n from_date = from_date.to_date\n until self[from_date.wday]\n from_date = from_date.succ\n end\n from_date.dup\n end",
"def next_yahrzeit_date(from=Date.today)\n return unless death_hebrew_date_day && death_hebrew_date_month\n @next_yahrzeit_date ||= begin\n # TODO: use Marlena rules\n h_from = Hebruby::HebrewDate.new(from)\n # yahrzeit date from year\n h_yahrzeit = Hebruby::HebrewDate.new(death_hebrew_date_day, death_hebrew_date_month, h_from.year)\n date = Date.jd(h_yahrzeit.jd)\n if date < from\n h_yahrzeit = Hebruby::HebrewDate.new(death_hebrew_date_day, death_hebrew_date_month, h_from.year+1)\n date = Date.jd(h_yahrzeit.jd)\n end\n date\n end\n end",
"def next_date\n next_observance.try(:start_on) || 100.years.from_now.to_date\n end",
"def next_date\n return @refdate.advance(@navigator => +1)\n end",
"def next\n calendar.starts_after_or_eql(at: end_at)\n end",
"def next_show_date\n interval = SATURDAY - Date.today().wday\n interval = SATURDAY if (interval < 0)\n\n Date.today + interval\n end",
"def next_active_date\n\t\tget_active_date\n\tend",
"def next_scheduled_use_date\n next_date = nil\n\n open_orders.each do |o|\n if o.access_date_start\n next_date ||= o.access_date_start\n if o.access_date_start < next_date\n next_date = o.access_date_start\n end\n end\n end\n next_date\n end",
"def date_of_next(day)\n date = Date.parse(day)\n delta = date > Date.today ? 0 : 7\n date + delta\nend",
"def next_date!\n Kernel.loop do\n @date += 1.day\n return if possible?\n end\n end",
"def next_date\n if course.is_training?\n self.start_date\n else\n # See http://stackoverflow.com/a/7621385/900301\n today = Date.today\n if week_day > today.wday\n today + (week_day - today.wday)\n else\n (today + (7 - today.wday)).next_day(week_day)\n end\n end\n end",
"def find_next_day\n day = @date.to_date + ((@schedule.start_date - @date.to_date) % @schedule.period_num)\n return day\n end",
"def next_date\n d = date\n Kernel.loop do\n d += 1.day\n sd = self.class.new(d, date_checker)\n return sd if sd.possible?\n end\n end",
"def next_business_day(date)\n date = date.next\n date = date.next while closed?(date)\n date\n end",
"def next_schedule_day\n date = self\n while date.weekend? or date.ca_holiday?\n date = date.next\n end\n return date\n end",
"def next(from, sec, fin)\n from ||= Time.at(0)\n sec ||= 0\n fin ||= Time.now\n #after is after or equal\n nxt = self.reports.next(from, sec).first\n # or it's the fist from the next second\n nxt ||= self.first(from+1, fin) \n end",
"def next_row_date(date)\n return date.advance(:weeks => +1)\n end",
"def set_paystack_next_charge_date\n if @member.account_detail.created_at.to_date < Date.today - 1.day\n date = DateTime.now\n else\n date = @member.account_detail.subscribe_date\n end\n if @member.subscription_plan.duration == \"weekly\"\n start_date = date.next_week.strftime('%FT%T%:z').to_s\n elsif @member.subscription_plan.duration == \"monthly\"\n start_date = date.next_month.strftime('%FT%T%:z').to_s\n elsif @member.subscription_plan.duration == \"quarterly\"\n start_date = (date + 90.days).strftime('%FT%T%:z').to_s\n elsif @member.subscription_plan.duration == \"annually\"\n start_date = date.next_year.strftime('%FT%T%:z').to_s\n end\n return start_date\n end",
"def next_day\r\n if @next_day.nil?\r\n @next_day = convert_day_to_date(current_day).tomorrow.strftime('%Y%m%d')\r\n end\r\n @next_day\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets attributes of the load balancer The following attributes can be set: CrossZoneLoadBalancing (enable/disable) ConnectionDraining (enable/disable and timeout) Idle Connection Timeouts Still requires: AccessLog configuration ==== Parameters lb_name Name of the ELB options 'ConnectionDraining': 'Enabled' whether to enable connection draining 'Timeout' max time to keep existing conns open before deregistering instances 'CrossZoneLoadBalancing': 'Enabled' whether to enable cross zone load balancing 'ConnectionSettings': 'IdleTimeout' time (in seconds) the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer. ==== Returns response: body: 'ResponseMetadata': 'RequestId' Id of request | def modify_load_balancer_attributes(lb_name, options)
attributes = Fog::AWS.serialize_keys 'LoadBalancerAttributes', options
request(attributes.merge(
'Action' => 'ModifyLoadBalancerAttributes',
'LoadBalancerName' => lb_name,
:parser => Fog::Parsers::AWS::ELB::Empty.new
))
end | [
"def modify_load_balancer_attributes(lb_id, attributes)\n attributes = Fog::AWS.serialize_keys 'Attributes', attributes.map{ |property, value| { :Key => property, :Value => value } }\n request(attributes.merge(\n 'Action' => 'ModifyLoadBalancerAttributes',\n 'LoadBalancerArn' => lb_id,\n :parser => Fog::Parsers::AWS::ELBV2::ModifyLoadBalancerAttributes.new\n ))\n end",
"def describe_load_balancer_attributes(lb_name)\n request({\n 'Action' => 'DescribeLoadBalancerAttributes',\n 'LoadBalancerName' => lb_name,\n :parser => Fog::Parsers::AWS::ELB::DescribeLoadBalancerAttributes.new\n })\n end",
"def init_elb_attributes(elb_name)\n @@client.describe_load_balancer_attributes({\n load_balancer_name: elb_name\n }).load_balancer_attributes\n end",
"def update_attributes(local_config)\n @elb.modify_load_balancer_attributes({\n load_balancer_name: local_config.name,\n load_balancer_attributes: {\n cross_zone_load_balancing: {\n enabled: local_config.cross_zone\n },\n access_log: if local_config.access_log then local_config.access_log.to_aws end,\n connection_draining: {\n enabled: local_config.connection_draining != false,\n timeout: if local_config.connection_draining != false then local_config.connection_draining end\n },\n connection_settings: {\n idle_timeout: local_config.idle_timeout\n }\n }\n })\n end",
"def create_load_balancer(lb_name, options = {})\n params = {}\n params.merge!(Fog::AWS.serialize_keys('Subnets', options[:subnet_ids])) if options[:subnet_ids]\n params.merge!(Fog::AWS.serialize_keys('SecurityGroups', options[:security_group_ids])) if options[:security_group_ids]\n\n if options[:tags]\n tags = options[:tags]\n params.merge!(Fog::AWS.serialize_keys('Tags', tags.map { |k, v| { 'Key' => k, 'Value' => v } }))\n end\n\n request({\n 'Action' => 'CreateLoadBalancer',\n 'Name' => lb_name,\n 'Scheme' => options[:scheme] || 'internet-facing',\n 'IpAddressType' => options[:ip_address_type] || 'ipv4',\n :parser => Fog::Parsers::AWS::ELBV2::CreateLoadBalancer.new\n }.merge(params))\n end",
"def describe_load_balancer_attributes(lb_id)\n request({\n 'Action' => 'DescribeLoadBalancerAttributes',\n 'LoadBalancerArn' => lb_id,\n :parser => Fog::Parsers::AWS::ELBV2::DescribeLoadBalancerAttributes.new\n })\n end",
"def create_load_balancer(name, options = {})\n params = {}\n params.merge!(Fog::AWS.indexed_param('Subnets.member.%d', options[:subnets]))\n params.merge!(Fog::AWS.indexed_param('SecurityGroups.member.%d', options[:security_groups]))\n params.merge!(Fog::AWS.serialize_keys('Scheme', options[:scheme]))\n params.merge!(Fog::AWS.serialize_keys('Type', options[:type]))\n params.merge!(Fog::AWS.serialize_keys('IpAddressType', options[:ip_address_type]))\n\n\n unless options[:tags].nil?\n tag_keys = options[:tags].keys.sort\n tag_values = tag_keys.map { |key| options[:tags][key] }\n params.merge!(Fog::AWS.indexed_param('Tags.member.%d.Key', tag_keys))\n params.merge!(Fog::AWS.indexed_param('Tags.member.%d.Value', tag_values))\n end\n\n unless options[:subnet_mappings].nil?\n subnet_ids = []\n allocation_ids = []\n private_ipv4_address = []\n options[:subnet_mappings].each do |subnet_mapping|\n subnet_ids.push(subnet_mapping[:subnet_id])\n allocation_ids.push(subnet_mapping[:allocation_id])\n private_ipv4_address.push(subnet_mapping[:private_ipv4_address])\n end\n params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.SubnetId', subnet_ids))\n params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.AllocationId', allocation_ids))\n params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.PrivateIPv4Address', private_ipv4_address))\n end\n\n\n request({\n 'Action' => 'CreateLoadBalancer',\n 'Name' => name,\n :parser => Fog::Parsers::AWS::ELBV2::CreateLoadBalancer.new\n }.merge!(params))\n end",
"def load_balancer_attribute(&block)\n attribute = ResourceProperty::ELBV2LoadBalancerAttribute.new(self)\n attribute.instance_exec(&block) if block\n load_balancer_attributes << attribute\n end",
"def name=(new_name=\"\")\n (raise CloudLB::Exception::Syntax, \"Load balancer name must be 128 characters or less\") if new_name.size > 128\n (raise CloudLB::Exception::MissingArgument, \"Must provide a new name\") if new_name.to_s.empty?\n body = {\"name\" => new_name}\n update(body)\n end",
"def configure_health_check(lb_name, health_check)\n params = {'LoadBalancerName' => lb_name}\n health_check.each {|key, value| params[\"HealthCheck.#{key}\"] = value }\n\n request({\n 'Action' => 'ConfigureHealthCheck',\n :parser => Fog::Parsers::AWS::ELB::ConfigureHealthCheck.new\n }.merge!(params))\n end",
"def add_http_load_balancer(name, ip_address=nil)\n\n add_load_balancer name, 80, ip_address\n\n end",
"def create_load_balancer_policy(lb_name, name, type_name, attributes = {})\n params = {}\n\n attribute_name = []\n attribute_value = []\n attributes.each do |name, value|\n attribute_name.push(name)\n attribute_value.push(value)\n end\n\n params.merge!(Fog::AWS.indexed_param('PolicyAttributes.member.%d.AttributeName', attribute_name))\n params.merge!(Fog::AWS.indexed_param('PolicyAttributes.member.%d.AttributeValue', attribute_value))\n\n request({\n 'Action' => 'CreateLoadBalancerPolicy',\n 'LoadBalancerName' => lb_name,\n 'PolicyName' => name,\n 'PolicyTypeName' => type_name,\n :parser => Fog::Parsers::AWS::ELB::Empty.new\n }.merge!(params))\n end",
"def remove_load_balancer_properties\n properties = []\n properties << :AccessLoggingPolicy\n properties << :AppCookieStickinessPolicy\n properties << :ConnectionDrainingPolicy\n properties << :CrossZone\n properties << :LBCookieStickinessPolicy\n properties << :LoadBalancerName\n properties << 'Listeners.PolicyNames'\n properties << 'Listeners.SSLCertificateId '\n properties << :Policies\n properties << :Scheme\n properties << :SecurityGroups\n properties << :Subnets\n add_patch Patches::RemoveProperty.new 'AWS::ElasticLoadBalancing::LoadBalancer', properties\n end",
"def load_balancer(elb_connection = Fog::AWS[:elb])\n if resources.nil?\n elb_connection.load_balancers.get(live_resources['LoadBalancers'].first['Name'])\n else\n elb_connection.load_balancers.get(resources['LoadBalancer']['LoadBalancerName'])\n end\n end",
"def attach_elb(elb_name)\n puts \"Attaching #{elb_name} to #{nice_name}\" if @verbose\n @client.attach_elastic_load_balancer({\n :elastic_load_balancer_name => elb_name,\n :layer_id => layer_id\n })\n end",
"def init_elb_policies(elb_name)\n @@client.describe_load_balancer_policies({\n load_balancer_name: elb_name\n }).policy_descriptions\n end",
"def lbs\n lb = client.get(:loadbalancers)\n msg = \"Status: #{lb.status}\"\n raise Idcf::Cli::CliError, msg if !lb.success? || lb.status != 200\n\n lb.body\n end",
"def create_elb(config)\n lb_placeholder = @opsworks.elb_client.load_balancers[config['name']]\n if not lb_placeholder.exists?\n puts \"creating new elb #{config['name']}\" if @verbose\n new_config = {:listeners => config['listeners']}\n new_config[:availability_zones] = config['availability_zones'] if config['availability_zones']\n new_config[:subnets] = config['subnets'] if config['subnets']\n new_config[:security_groups] = config['security_groups'] if config['security_groups']\n new_config[:scheme] = config['scheme'] if config['scheme']\n puts new_config\n @opsworks.elb_client.load_balancers.create(config['name'], new_config)\n lb_placeholder = @opsworks.elb_client.load_balancers[config['name']]\n if not lb_placeholder.exists?\n raise \"could not find elb #{config['name']} after creation\"\n end\n else\n puts \"skipping existing elb #{config['name']}\" if @verbose\n end\n\n lb_placeholder.configure_health_check(config['health_check'])\n end",
"def create_elb(elb)\n resp = aws_api_connect(\"ELB_Client\")\n begin\n pants = resp.create_load_balancer({\n load_balancer_name: elb[:name],\n listeners: [\n {\n protocol: elb[:protocol],\n load_balancer_port: elb[:port],\n instance_protocol: elb[:instnace_protocol],\n instance_port: elb[:instance_port],\n ssl_certificate_id: elb[:ssl_cert],\n },\n ],\n subnets: elb[:subnets],\n security_groups: elb[:security_groups],\n })\n rescue Aws::ElasticLoadBalancing::Errors::DuplicateLoadBalancerName\n puts \"Load Balancer #{elb[:name]} already exists, bypassing\"\n rescue Aws::ElasticLoadBalancing::Errors::Throttling\n puts \"api throttled, retrying\"\n # TODO: Add exponential backoff\n sleep(5)\n retry\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
repair the list this item belongs to | def repair_list
self.class.repair_list(list_scope)
end | [
"def repair_list\n model.repair_list(list_scope)\n end",
"def remove_from_reorder_list\n\t\tItem.where(id: params[:i_id]).first\n\t\t@reorder_items = Item.all.need_reorder.alphabetical.to_a\n\tend",
"def fix_dropped_items\n bad_path = nil\n @model.each do |model, path, iter|\n item = iter[ItemColumn]\n if !item.menu? and iter.has_child?\n bad_path = iter.path\n end\n end\n return unless bad_path\n iter = @model.get_iter(bad_path)\n item = iter[ItemColumn]\n child = iter.first_child or return\n target = child[ItemColumn]\n @model.remove(child)\n nxt = @model.insert_after(iter.parent, iter)\n nxt[ItemColumn] = target\n sel = @view.selection\n sel.unselect_all\n sel.select_iter(nxt)\n @view.scroll_to_cell(nxt.path, nil, false, 0, 0)\n return false\n end",
"def eliminate\n @list.each do |candidate|\n candidate.ballots.list.clear\n end\n end",
"def reject_items!\n self.items.each do |i|\n i.update_attribute(:rejected_at, Time.zone.now)\n self.create_listing_from_item(i)\n end\n end",
"def reprocess_child_items!\n self.child_items.delete_all\n create_child_items\n end",
"def move_sub_items\n self.items.each do |sub_item|\n if self.case != sub_item.case\n sub_item.case = self.case\n sub_item.location = nil\n sub_item.save!\n end\n end\n end",
"def remove_inapproprate_items_from(items)\n idata = items['data']\n #Remove things we said are not ok\n item_info_dict['Excluded IDs'].each{|id| idata.delete id}\n\n #Things that can't be baught are things we aren't interested in\n idata.reject!{|id, info| not info.dig('gold', 'purchasable') }\n\n #take snapshot of keys to iterate while we muck with the poor thing.\n ids = idata.keys.dup\n\n #Drop items that have groups or tags I think are stupid.\n ids.each do |id|\n item_info_dict['Rejected Properties'].each do |rejected_property, rejected_info|\n item_property = idata.dig(id, rejected_property)\n case item_property\n when Array\n idata.delete id unless (item_property & rejected_info).empty?\n when nil\n #pass\n else\n idata.delete id if rejected_info.include? item_property\n end\n end\n end\n\n #clean up the \"into\" category with only things that exist\n idata.each do |key, info|\n info['into'].keep_if {|id| idata.has_key? id}\n end\n\n #remove items from certain maps\n item_info_dict['Remove from Map'].each do |itemID, maps|\n maps.each do |mapID|\n idata[itemID]['maps'][mapID] = false\n end\n end\n\n ids = idata.keys.dup\n\n #handle things that build into themselves?\n ids.each do |id|\n info = idata.dig(id)\n\n #doesn't have an into, so doesn't build into anything\n next if info['into'].empty?\n\n info['into'].each do |possible_id|\n possible_info = idata.dig(possible_id)\n\n #Move along if we've deleted this item already\n unless possible_info\n idata.delete id\n next\n end\n\n #it's a sidegrade, so valid\n next if idata.dig(possible_id, 'into').include? id\n\n #Anything that builds into stuff that we don't like is also\n #something we're not interested in?\n unless items['data'].has_key? possible_id\n idata.delete id\n next\n end\n\n #This item is a result of transformation.\n if idata.dig(possible_id, 'gold', 'purchasable')\n idata.delete id\n next\n end\n\n idata.delete id\n end\n end\n items['data'] = idata\n items\n end",
"def destroy_invalid_list_items(hpricot_dom)\n (hpricot_dom/\"li\").each do |list_item|\n list_item.swap(\"\") unless list_item.parent.name.downcase.eql?(\"ul\") or list_item.parent.name.downcase.eql?(\"ol\")\n end\n end",
"def clean!\n list = clean?\n GeographicItem.connection.execute('delete from geographic_items where id in (select id from t20140306)')\n GeographicItem.connection.execute('drop table t20140306')\n list\n end",
"def destroy\n @inventory.items.dup.each do |item|\n item.destroy\n end\n super\n return\n end",
"def remove_item (item, list)\n list.delete(item)\n return list\nend",
"def free item\n item.order_book.remove item if item.order_book\n end",
"def remove_old_items(recipes)\n @grocery.items.delete(recipes.flat_map(&:items))\n end",
"def refresh_item_list\n @index = nil\n prepare_item(0)\n end",
"def remove_item(new_list, item_name)\r\n new_list.delete(item_name)\r\nend",
"def remove_item(final_list, item_name)\n final_list.delete(item_name)\n p final_list\nend",
"def purge!\n unless self.ordered?\n self.line_items.each do |line_item|\n remove_line_item(line_item) if line_item.invalid?\n end\n end\n end",
"def disperse_items\n @items.each {|item| \n room = @rooms[rand(2...@rooms.size)]\n room.items << item\n }\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
reorder the list this item belongs to | def reorder_list(order)
self.class.repair_list(list_scope.merge(:order => order))
end | [
"def reorder_list(order)\n model.repair_list(list_scope.merge(:order => order))\n end",
"def reorder\n end",
"def remove_from_reorder_list\n\t\tItem.where(id: params[:i_id]).first\n\t\t@reorder_items = Item.all.need_reorder.alphabetical.to_a\n\tend",
"def reorder_items(playlist)\n # we have to do a sort_by, not order, because the updated attributes have not been saved.\n changed_playlist, new, changed_position, unchanged = playlist.items.\n sort_by(&:position).\n group_by do |item|\n\tif item.playlist_id_was != item.playlist_id\n\t :changed_playlist\n\telsif item.position_was.nil?\n\t :new\n\telsif item.position_was != item.position\n\t :changed_position\n\telse\n\t :unchanged\n\tend\n end.values_at(:changed_playlist, :new, :changed_position, :unchanged).map(&:to_a)\n # items that will be in this playlist\n unmoved_items = unchanged\n # place items whose positions were specified\n changed_position.map {|item| unmoved_items.insert(item.position - 1, item)}\n # add new items at the end\n unmoved_items = unmoved_items + new\n # calculate positions\n unmoved_items.compact.\n select {|item| item.playlist_id_was == item.playlist_id}.\n each_with_index do |item, position|\n\titem.position = position + 1\n end\n\n # items that have moved to another playlist\n changed_playlist.select {|item| item.playlist_id_was != item.playlist_id}.each do |item|\n item.position = nil\n end\n end",
"def reorder_listings_position\n listings = Listing.find_with_reputation(:item_votes, :all, { :conditions => [\"list_id = ?\", self.id], :order => 'item_votes DESC' })\n listings.each_with_index do |listing, index|\n listing.update_attribute(:position, index + 1)\n end\n self.listings\n end",
"def update_list_order(model, order)\n order.to_a.each_with_index do |item, pos|\n model.update(item, position:(pos + 1))\n end\n end",
"def original_order\n end",
"def reorder_items(folder)\n # we have to do a sort_by, not order, because the updated attributes have not been saved.\n changed_folder, new, changed_position, unchanged = folder.items.\n sort_by(&:position).\n group_by do |item|\n if item.folder_id_was != item.folder_id\n :changed_folder\n elsif item.position_was.nil?\n :new\n elsif item.position_was != item.position\n :changed_position\n else\n :unchanged\n end\n end.values_at(:changed_folder, :new, :changed_position, :unchanged).map(&:to_a)\n\n # items that will be in this folder\n unmoved_items = unchanged\n # place items whose positions were specified\n changed_position.map {|item| unmoved_items.insert(item.position - 1, item)}\n # add new items at the end\n unmoved_items = unmoved_items + new\n # calculate positions\n unmoved_items.compact.\n select {|item| item.folder_id_was == item.folder_id}.\n each_with_index do |item, position|\n item.position = position + 1\n end\n\n # items that have moved to another folder\n changed_folder.select {|item| item.folder_id_was != item.folder_id}.each do |item|\n item.position = nil\n end\n end",
"def reorder_entries\n i = 1\n self.entries.each do | e |\n if (e.position != i)\n e.position = i\n e.save\n end\n i += 1\n end\n end",
"def order\n @data.values.each do |info|\n info[:list].sort!\n info[:idx] = -1\n info[:shuffled] = false\n end\n end",
"def sort_my_list\n @tracks.clear\n @artists.clear\n @genres.clear\n @user_list.each do |item|\n @tracks << item['id'] if item['type'] == 'track'\n @artists << item['id'] if item['type'] == 'artist'\n @genres << item['name'].downcase if item['type'] == 'genre'\n end\n end",
"def move_sub_items\n self.items.each do |sub_item|\n if self.case != sub_item.case\n sub_item.case = self.case\n sub_item.location = nil\n sub_item.save!\n end\n end\n end",
"def reorder_positions\n if position\n position = self.position\n update_attribute(:position, nil)\n self.class.update_all('position = (position - 1)', ['message_id = ? AND kind = ? AND position > ?', message_id, kind, position])\n end\n end",
"def reorder\n @issue = @project.backlog_items.find(params[:issue_id])\n @issue.becomes(SprintItem).remove_from_list if @issue.sprint\n\n @issue.remove_from_list\n\n @issue.sprint_id = nil\n @issue.save\n\n if @issue.insert_at(params[:position].to_i)\n render :json => @issue\n else\n render :json => { :errors => @issue.errors }, :status => :entity_unprocessable\n end\n end",
"def reorder_list(field)\n index = 1\n list_scope(field).order_by(field => 'asc').each do |document|\n next if document.id == id\n\n index += 1 if index == self[field] && persisted?\n document.set(field => index)\n index += 1\n end\n\n if list_scope_changed?(field)\n list_scope_was(field).order_by(field => 'asc').each_with_index do |document, index|\n document.set(field => index + 1)\n end\n end\n end",
"def move_line_items_to_order basket ,order\n basket.line_items.each do |item|\n item.basket_id = nil #prevent cascade delete\n order.line_items << item\n end\n end",
"def reorder!(order)\n @order = order\n\n @attributes = order!(@attributes, order)\n @name = name!(@attributes)\n\n if @name[-2, 2] == \".,\" # Fix this.\n @name = @name[0..-3]\n end\n\n self\n end",
"def order( items )\n self.parser.order(items) \n end",
"def reorder(collection, cursor, pk, pk_direction)\n x = []\n collection.order_values.each do |v|\n if cursor == :after || cursor.nil?\n x << v\n elsif cursor == :before\n x << v.reverse\n end\n end\n\n # also add our primary key, if it's not yet included in the existing order directives\n unless order_includes_pk?(collection, pk)\n if cursor == :after || cursor.nil?\n x << pk.send(pk_direction)\n elsif cursor == :before\n x << pk.send(pk_direction).reverse\n end\n end\n\n collection.reorder(x)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find best matching competition race for category. Iterate through traits (weight, equipment, ages, gender, abilities) until there is a single match (or none). | def best_match_in(event)
logger.debug "Category#best_match_in #{name} in #{event.name}: #{event.categories.map(&:name).join(', ')}"
candidate_categories = event.categories
equivalent_match = candidate_categories.detect { |category| equivalent?(category) }
logger.debug "equivalent: #{equivalent_match&.name}"
return equivalent_match if equivalent_match
candidate_categories = candidate_categories.select { |category| weight == category.weight }
logger.debug "weight: #{candidate_categories.map(&:name).join(', ')}"
candidate_categories = candidate_categories.select { |category| equipment == category.equipment }
logger.debug "equipment: #{candidate_categories.map(&:name).join(', ')}"
candidate_categories = candidate_categories.select { |category| ages_begin.in?(category.ages) }
logger.debug "ages: #{candidate_categories.map(&:name).join(', ')}"
candidate_categories = candidate_categories.reject { |category| gender == "M" && category.gender == "F" }
logger.debug "gender: #{candidate_categories.map(&:name).join(', ')}"
candidate_categories = candidate_categories.select { |category| ability_begin.in?(category.abilities) }
logger.debug "ability: #{candidate_categories.map(&:name).join(', ')}"
return candidate_categories.first if candidate_categories.one?
return nil if candidate_categories.empty?
if junior?
junior_categories = candidate_categories.select { |category| category.junior? }
logger.debug "junior: #{junior_categories.map(&:name).join(', ')}"
return junior_categories.first if junior_categories.one?
if junior_categories.present?
candidate_categories = junior_categories
end
end
if masters?
masters_categories = candidate_categories.select { |category| category.masters? }
logger.debug "masters?: #{masters_categories.map(&:name).join(', ')}"
return masters_categories.first if masters_categories.one?
if masters_categories.present?
candidate_categories = masters_categories
end
end
# E.g., if Cat 3 matches Senior Men and Cat 3, use Cat 3
# Could check size of range and use narrowest if there is a single one more narrow than the others
candidate_categories = candidate_categories.reject { |category| category.all_abilities? }
logger.debug "reject wildcards: #{candidate_categories.map(&:name).join(', ')}"
return candidate_categories.first if candidate_categories.one?
return nil if candidate_categories.empty?
# "Highest" is lowest ability number
highest_ability = candidate_categories.map(&:ability_begin).min
if candidate_categories.one? { |category| category.ability_begin == highest_ability }
highest_ability_category = candidate_categories.detect { |category| category.ability_begin == highest_ability }
logger.debug "highest ability: #{highest_ability_category.name}"
return highest_ability_category
end
candidate_categories = candidate_categories.reject { |category| gender == "F" && category.gender == "M" }
logger.debug "exact gender: #{candidate_categories.map(&:name).join(', ')}"
return candidate_categories.first if candidate_categories.one?
return nil if candidate_categories.empty?
logger.debug "no wild cards: #{candidate_categories.map(&:name).join(', ')}"
return candidate_categories.first if candidate_categories.one?
return nil if candidate_categories.empty?
raise "Multiple matches #{candidate_categories.map(&:name)} for #{name} in #{event.categories.map(&:name).join(', ')}"
end | [
"def find_by_category\n if @abv && @ibu\n find_by_abv_and_ibu(category: @category)\n elsif @abv\n find_by_abv(category: @category)\n elsif @ibu\n find_by_ibu(category: @category)\n else\n found_beer = Beer.where(category: @category).sample until found_beer\n found_beer\n end\n end",
"def find_by_style_and_category\n if @abv && @ibu\n find_by_abv_and_ibu(category: @category, beer_style: @beer_style)\n elsif @abv\n find_by_abv(category: @category, beer_style: @beer_style)\n elsif @ibu\n find_by_ibu(category: @category, beer_style: @beer_style)\n else\n found_beer = Beer.where(category: @category, beer_style: @beer_style).sample until found_beer\n found_beer\n end\n end",
"def best_match_in(event_categories, result_age = nil)\n debug \"Category#best_match_in for #{name} in #{event_categories.map(&:name).join(', ')}\"\n\n candidate_categories = event_categories.dup\n\n equivalent_matches = candidate_categories.select { |category| equivalent?(category) }\n debug \"equivalent: #{equivalent_matches.map(&:name).join(', ')}\"\n return equivalent_matches.first if one_match?(equivalent_matches)\n\n # Sometimes categories like Beginner and Cat 4 are equivalent but need to\n # be separated if both categories exist\n exact_equivalent = equivalent_matches.detect { |category| category.name == name }\n debug \"exact equivalent: #{exact_equivalent}\"\n return exact_equivalent if exact_equivalent\n\n # If no weight match, ignore weight and match on age and gender\n if candidate_categories.any? { |category| weight == category.weight }\n candidate_categories = candidate_categories.select { |category| weight == category.weight }\n end\n debug \"weight: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n\n # Eddy is essentially senior men/women for BAR\n if equipment == \"Eddy\"\n highest_senior_category = candidate_categories.detect do |category|\n category.ability_begin == 0 &&\n category.gender == gender &&\n !category.age_group? &&\n (category.equipment == \"Eddy\" || category.equipment.blank?)\n end\n debug \"eddy: #{highest_senior_category&.name}\"\n return highest_senior_category if highest_senior_category\n end\n\n # Equipment matches are fuzzier\n candidate_categories = candidate_categories.select { |category| equipment == category.equipment }\n debug \"equipment: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return candidate_categories.first if candidate_categories.one? && equipment?\n return nil if candidate_categories.empty?\n\n if equipment?\n equipment_categories = candidate_categories.select do |category|\n equipment == category.equipment && gender == category.gender\n end\n debug \"equipment and gender: #{equipment_categories.map(&:name).join(', ')}\"\n return equipment_categories.first if equipment_categories.one?\n end\n\n candidate_categories = candidate_categories.reject { |category| gender == \"M\" && category.gender == \"F\" }\n debug \"gender: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n\n candidate_categories = if result_age && !senior? && candidate_categories.none? { |category| ages_begin.in?(category.ages) }\n candidate_categories.select { |category| category.ages.include?(result_age) }\n elsif junior? && ages_begin == 0\n candidate_categories.select { |category| ages_end.in?(category.ages) }\n else\n candidate_categories.select { |category| ages_begin.in?(category.ages) }\n end\n debug \"ages: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n\n unless all_abilities?\n candidate_categories = candidate_categories.select { |category| ability_begin.in?(category.abilities) }\n debug \"ability: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n end\n\n # Edge case for unusual age ranges that span juniors and seniors like 15-24\n if !senior? && ages_begin <= Ages::JUNIORS.end && ages_end > Ages::JUNIORS.end\n candidate_categories = candidate_categories.reject(&:junior?)\n debug \"overlapping ages: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n end\n\n if junior?\n junior_categories = candidate_categories.select(&:junior?)\n debug \"junior: #{junior_categories.map(&:name).join(', ')}\"\n return junior_categories.first if junior_categories.one?\n\n candidate_categories = junior_categories if junior_categories.present?\n end\n\n if masters?\n masters_categories = candidate_categories.select(&:masters?)\n debug \"masters?: #{masters_categories.map(&:name).join(', ')}\"\n return masters_categories.first if masters_categories.one?\n\n candidate_categories = masters_categories if masters_categories.present?\n end\n\n # E.g., if Cat 3 matches Senior Men and Cat 3, use Cat 3\n # Could check size of range and use narrowest if there is a single one more narrow than the others\n unless candidate_categories.all?(&:all_abilities?) || all_abilities?\n candidate_categories = candidate_categories.reject(&:all_abilities?)\n end\n debug \"reject wildcards: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n\n # \"Highest\" is lowest ability number\n # Choose exact ability category begin if women\n # Common edge case where the two highest categories are Pro/1/2 and Women 1/2\n if candidate_categories.one? { |category| category.ability_begin == ability_begin && category.women? && women? }\n ability_category = candidate_categories.detect { |category| category.ability_begin == ability_begin && category.women? && women? }\n debug \"ability begin: #{ability_category.name}\"\n return ability_category if ability_category.include?(self)\n end\n\n # Edge case for next two matchers: don't choose Junior Open 1/2/3 over Junior Open 3/4/5 9-12 for Junior Open 3/4/5 11-12,\n # but still match Junior Women with Category 1\n\n # Choose highest ability category\n highest_ability = candidate_categories.map(&:ability_begin).min\n if candidate_categories.one? { |category| category.ability_begin == highest_ability && (!category.junior? || category.ages.size <= ages.size) }\n highest_ability_category = candidate_categories.detect { |category| category.ability_begin == highest_ability && (!category.junior? || category.ages.size <= ages.size) }\n debug \"highest ability: #{highest_ability_category.name}\"\n return highest_ability_category if highest_ability_category.include?(self)\n end\n\n # Choose highest ability by gender\n if candidate_categories.one? { |category| category.ability_begin == highest_ability && category.gender == gender && (!category.junior? || category.ages.size <= ages.size) }\n highest_ability_category = candidate_categories.detect { |category| category.ability_begin == highest_ability && category.gender == gender && (!category.junior? || category.ages.size <= ages.size) }\n debug \"highest ability for gender: #{highest_ability_category.name}\"\n return highest_ability_category if highest_ability_category.include?(self)\n end\n\n # Choose highest minimum age if multiple Masters 'and over' categories\n if masters? && candidate_categories.all?(&:and_over?)\n if result_age\n candidate_categories = candidate_categories.reject { |category| category.ages_begin > result_age }\n end\n highest_age = candidate_categories.map(&:ages_begin).max\n highest_age_category = candidate_categories.detect { |category| category.ages_begin == highest_age }\n debug \"highest age: #{highest_age_category&.name}\"\n return highest_age_category if highest_age_category&.include?(self)\n end\n\n # Choose narrowest age if multiple Masters categories\n if masters?\n ranges = candidate_categories.select(&:masters?).map do |category|\n category.ages_end - category.ages_begin\n end\n\n minimum_range = ranges.min\n candidate_categories = candidate_categories.select do |category|\n (category.ages_end - category.ages_begin) == minimum_range\n end\n\n return candidate_categories.first if one_match?(candidate_categories)\n end\n\n # Choose narrowest age if multiple Juniors categories\n if junior?\n ranges = candidate_categories.select(&:junior?).map do |category|\n category.ages_end - category.ages_begin\n end\n\n minimum_range = ranges.min\n candidate_categories = candidate_categories.select do |category|\n (category.ages_end - category.ages_begin) == minimum_range\n end\n\n debug \"narrow junior ages: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n end\n\n candidate_categories = candidate_categories.reject { |category| gender == \"F\" && category.gender == \"M\" }\n debug \"exact gender: #{candidate_categories.map(&:name).join(', ')}\"\n return candidate_categories.first if one_match?(candidate_categories)\n return nil if candidate_categories.empty?\n\n if wildcard? && candidate_categories.none?(&:wildcard?)\n debug \"no wild cards: #{candidate_categories.map(&:name).join(', ')}\"\n return nil\n end\n\n if candidate_categories.size > 1\n raise \"Multiple matches #{candidate_categories.map(&:name)} for #{name}, result age: #{result_age} in #{event_categories.map(&:name).join(', ')}\"\n end\n end",
"def candidates_for_category(category)\n candidate_set = @candidate_generator.category_candidates(category)\n row = [category.name,candidate_set.full_name]\n report(category.name.hl(:blue))\n if candidate_set.size > 1\n report(candidate_set.all_candidates.to_s.hl(:purple))\n candidates = @multiplier.multiply(candidate_set)\n report(candidates.to_s.hl(:purple))\n else\n candidates = candidate_set.candidates\n end\n if candidates && !candidates.empty?\n # related candidate sets\n context = @context_provider.context(category)\n parent_candidate_sets = related_category_candidates(context.parents.values.flatten(1).uniq)\n child_candidate_sets = related_category_candidates(context.children.values.flatten(1).uniq)\n articles = context.articles.values.flatten(1).uniq\n instance_candidate_sets = related_article_candidates(articles)\n type_candidate_sets = related_type_candidates(articles)\n infobox_candidate_sets = related_infobox_candidates(articles)\n # matched relations computation\n candidates.each do |term|\n counts = []\n counts.concat(number_of_matched_candidates(parent_candidate_sets,term,candidate_set.full_name,[:genls?]))\n counts.concat(number_of_matched_candidates(child_candidate_sets,term,candidate_set.full_name,[:spec?]))\n counts.concat(number_of_matched_candidates(instance_candidate_sets,term,candidate_set.full_name,[:type?]))\n counts.concat(number_of_matched_candidates(type_candidate_sets,term,\"DBPEDIA_TYPE\",[:genls?,:spec?,:isa?,:type?]))\n counts.concat(number_of_matched_candidates(infobox_candidate_sets,term,\"INFOBOX\",[:genls?,:spec?,:isa?,:type?]))\n positive,negative = sum_counts(term,counts,%w{p c i t x})\n row.concat([term.id,term.to_ruby,positive,positive+negative])\n end\n end\n row\n end",
"def compute_results_category\n # todo: handle what happens if votes are in non-compatable categories\n first_category = votes.first.category\n complementary_category = first_category.complementary_category\n nbr_votes_in_first_category = number_of_votes(first_category)\n nbr_votes_in_complementary_category = number_of_votes(complementary_category)\n points_in_first_category = points_by_category(first_category)\n points_in_complementary_category = points_by_category(complementary_category)\n if points_in_first_category > points_in_complementary_category\n return first_category\n elsif points_in_complementary_category > points_in_first_category\n return complementary_category\n else # both categories have equal points - shouldn't happen very often\n if nbr_votes_in_first_category > nbr_votes_in_complementary_category\n return first_category\n elsif nbr_votes_in_complementary_category > nbr_votes_in_first_category\n return complementary_category\n else # number of votes in both categories are equal - return Actor or Actress\n return first_category.tiebreaker_category\n end\n end\n end",
"def best_by_type_and_category(type, category = nil)\n conditions = [\"debates.is_live = ? AND debates.priv = ? AND arguments.argument_type = ? AND debates.category_id != ?\",\n true, false, type, Category.practice_debate]\n if category\n conditions[0] += \" AND debates.category_id = ?\"\n conditions << category\n end\n \n Argument.first :joins => :debate, :conditions => conditions, :order => 'arguments.score desc'\n end",
"def find_by_abv_and_ibu(category: nil, beer_style: nil)\n beer = nil\n until beer\n ibu = change_for_ibu + @ibu\n abv = change_for_abv + @abv\n beer = Beer.where(ibu: ibu, abv: abv, category: category, beer_style: beer_style).sample\n end\n beer\n end",
"def get_team_best_individual_result(gender_type, pool_type, event_type, category_code)\n if has_individual_result?(gender_type, pool_type, event_type, category_code)\n # team.meeting_individual_results\n # .is_not_disqualified\n # .for_gender_type(gender_type)\n # .for_pool_type(pool_type)\n # .for_event_type(event_type)\n # .for_category_code(category_code)\n # .sort_by_timing.first\n team.meeting_individual_results\n .is_not_disqualified\n .for_team_best(pool_type, gender_type, category_code, event_type)\n .sort_by_timing.first\n end\n end",
"def support_for_category_candidate_set(category, candidate_set)\n row = [category.name, candidate_set.full_name]\n report(category.name.hl(:blue))\n if candidate_set.size > 1\n report(candidate_set.all_candidates.to_s.hl(:purple))\n candidates = @multiplier.multiply(candidate_set)\n report(candidates.to_s.hl(:purple))\n else\n candidates = candidate_set.candidates\n end\n\n if candidates && !candidates.empty?\n # related candidate sets\n context = @context_provider.get_context(category)\n\n parents_context = context.get_parents\n children_context = context.get_children\n articles_context = context.get_articles\n\n # matched relations computation\n candidates.each do |term|\n counts = []\n\n parents_context.each do |distance, entities|\n candidate_sets = related_category_candidates(entities.uniq)\n counts.concat(number_of_matched_candidates(candidate_sets, term, candidate_set.full_name) { |t, c| @cyc.genls?(t, c) })\n end\n\n children_context.each do |distance, entities|\n candidate_sets = related_category_candidates(entities.uniq)\n counts.concat(number_of_matched_candidates(candidate_sets, term, candidate_set.full_name) { |t, c| @cyc.genls?(c, t) })\n end\n\n articles_context.each do |distance, entities|\n instance_candidate_sets = related_article_candidates(entities.uniq)\n type_candidate_sets = related_type_candidates(entities.uniq)\n counts.concat(number_of_matched_candidates(instance_candidate_sets, term, candidate_set.full_name) { |t, c| @cyc.with_any_mt { |cyc| cyc.cor { |cyc| cyc.isa?(c, t); cyc.genls?(c, t) } } })\n counts.concat(number_of_matched_candidates(type_candidate_sets, term, \"DBPEDIA_TYPE\") { |t, c| @cyc.genls?(t, c) || @cyc.genls?(c, t) ||\n @cyc.isa?(t, c) || @cyc.isa?(c, t) })\n end\n\n\n positive, negative = sum_counts(counts)\n row.concat([term.id, term.to_ruby.to_s, positive, positive+negative])\n end\n end\n row\n end",
"def find_by_abv(category: nil, beer_style: nil)\n beer = nil\n until beer\n abv = change_for_abv + @abv\n beer = Beer.where(abv: abv, category: category, beer_style: beer_style).sample\n end\n beer\n end",
"def mutual_compatibility_score_per_category(category, match)\n user_to_match_percentage = self.compatibility_percentage_per_category(category, match)\n match_to_user_percentage = match.compatibility_percentage_per_category(category, self)\n\n if user_to_match_percentage == -1 || match_to_user_percentage == -1\n # -1 is a flag that the category has not been filled out at all\n return -1\n else\n compatibility = Math.sqrt(user_to_match_percentage * match_to_user_percentage).to_i\n end\n end",
"def coolest_ability\n coolest_ability = nil\n abilities.each do | current_ability | \n if coolest_ability == nil || current_ability[:coolness] > coolest_ability[:coolness]\n coolest_ability = current_ability\n end\n end\n coolest_ability\n end",
"def get_best_for_gender_category_and_event(gender_type, category_type, event_type)\n @event_bests.select do |element|\n (element.gender_type == gender_type) && (element.category_type == category_type) &&\n (element.event_type == event_type)\n end.first\n end",
"def category_candidates(category)\n return @category_cache[category] unless @category_cache[category].nil?\n # from whole name singularized\n candidates = []\n decorated_category = Cyclopedio::Syntax::NameDecorator.new(category, parse_tree_factory: @parse_tree_factory)\n @nouns.singularize_name(category.name, decorated_category.category_head).each do |name_singularized|\n candidates.concat(candidates_for_name(name_singularized,@category_filters))\n end\n candidate_set = create_candidate_set(category.name,candidates)\n return @category_cache[category] = candidate_set if !candidate_set.empty? || @category_exact_match\n # from simplified name\n candidate_set = candidate_set_for_syntax_trees(decorated_category.category_head_trees,@category_filters)\n return @category_cache[category] = candidate_set unless candidate_set.empty?\n # from original whole name\n candidate_set = candidate_set_for_name(category.name, @category_filters)\n @category_cache[category] = candidate_set\n end",
"def scan_for_gender_category_and_event\n # Scan genders, than Category, than events, than pool types\n # An element occurs if at least one meeting individual result is present\n GenderType.individual_only.each do |gender_type|\n PoolType.only_for_meetings.each do |pool_type|\n @event_types.each do |event_type|\n @categories.each do |category_code|\n # If at least on meeting individual result add an element\n next unless MeetingIndividualResult\n .for_season_type(@season.season_type)\n .for_gender_type(gender_type)\n .for_category_code(category_code)\n .for_pool_type(pool_type)\n .for_event_type(event_type)\n .exists?\n\n @single_events << SeasonPonderatedBestsDAO::EventPonderatedBestDAO.new(\n @season,\n gender_type,\n CategoryType.for_season(@season).find_by(code: category_code),\n event_type,\n pool_type,\n @max_results,\n @bests_to_be_ignored\n )\n end\n end\n end\n end\n end",
"def first_matched_restriction(category)\n request_ip = remote_ip\n country = Barong::GeoIP.info(ip: request_ip, key: :country)\n continent = Barong::GeoIP.info(ip: request_ip, key: :continent)\n if restriction = @restrictions[category]['all']&.find { |r| r.present? } then return restriction end\n if restriction = @restrictions[category]['ip']&.find { |r| r.include?(request_ip) } then return restriction end\n if restriction = @restrictions[category]['ip_subnet']&.find { |r| IPAddr.new(r[0])&.include?(request_ip) } then return restriction end\n if restriction = @restrictions[category]['continent']&.find { |r| r[0]&.casecmp?(continent) } then return restriction end\n if restriction = @restrictions[category]['country']&.find { |r| r[0]&.casecmp?(country) } then return restriction end\n end",
"def find_occasion_to_plan_for(food_thing, occasions)\n # Map occasion names to number of available courses\n occasions_to_course_counts = {}\n occasions.each do |occasion|\n course_count = available_food_for_occasion(food_thing, occasion).size\n occasions_to_course_counts[occasion] = course_count\n end\n\n # Extract the occasion names with the lowest number of courses\n lowest = occasions_to_course_counts.values.min\n candidates = []\n occasions_to_course_counts.each do |occasion, count|\n candidates << occasion if count == lowest\n end\n\n # Pick one occasion with the lowest count\n return candidates.sample\nend",
"def talents\n talents = {}\n unless self.character_talents.empty?\n self.character_talents.each do |talent_tree|\n talent_tree.attributes.each do |key, value|\n if key.match(/talent_[\\d]_[\\d]$/) and !value.nil?\n if talents.has_key?(value) && !talent_tree[\"#{key}_options\"].nil?\n talents[value]['count'] = talents[value]['count'] + 1\n talent_tree[\"#{key}_options\"].each do |opt|\n opt_test = opt.to_i\n if opt_test.is_a? Integer and opt_test > 0\n talents[value]['options'] << Skill.find_by_id(opt).name\n else\n talents[value]['options'] << opt.capitalize\n end\n end\n else\n talents[value] = {}\n talents[value]['count'] = 1\n talents[value]['options'] = Array.new\n unless talent_tree[\"#{key}_options\"].nil?\n unless talent_tree[\"#{key}_options\"].empty?\n talent_tree[\"#{key}_options\"].each do |opt|\n opt_test = opt.to_i\n if opt_test.is_a? Integer and opt_test > 0\n talents[value]['options'] << Skill.find_by_id(opt).name\n else\n talents[value]['options'] << opt.capitalize\n end\n end\n end\n end\n end\n end\n end\n end\n talents\n end\n\n # Build the character cybernetics selection.\n def cybernetics\n cybernetics = Array.new\n items = Array.new\n bonus_arms = {\n :agility => nil,\n :brawn => nil\n }\n bonus_legs = {\n :agility => nil,\n :brawn => nil\n }\n bonus_head = {\n :intellect => nil\n }\n left_leg_active = false\n right_leg_active = false\n arms_active = false\n head_active = false\n bonus_soak = 0\n\n if self.character_cybernetics\n self.character_cybernetics.each do |cyb|\n bonus = nil\n unless cyb.gear_id.nil?\n if cyb.respond_to?(\"#{cyb.gear.name.gsub(/[^0-9a-z\\\\s]/i, '').downcase}\")\n bonus = cyb.send(\"#{cyb.gear.name.gsub(/[^0-9a-z\\\\s]/i, '').downcase}\")\n if bonus\n if !arms_active && (cyb.location == 'left_arm' || cyb.location == 'right_arm')\n bonus_arms = bonus\n arms_active = true\n end\n if cyb.location == 'left_leg'\n left_leg_active = cyb.gear.id\n end\n if cyb.location == 'right_leg'\n right_leg_active = cyb.gear.id\n end\n if left_leg_active == right_leg_active\n bonus_legs = bonus\n end\n if !head_active && cyb.location == 'head'\n bonus_head = bonus\n head_active = true\n end\n if bonus[:soak]\n bonus_soak = bonus[:soak]\n end\n end\n end\n\n items << {\n :name => cyb.gear.name,\n :location => cyb.location,\n :bonus => bonus\n }\n end\n end\n end\n\n cybernetics = {\n :items => items,\n :bonuses => {\n :agility => (bonus_arms[:agility] ? bonus_arms[:agility] : 0) + (bonus_legs[:agility] ? bonus_legs[:agility] : 0),\n :brawn => (bonus_arms[:brawn] ? bonus_arms[:brawn] : 0) + (bonus_legs[:brawn] ? bonus_legs[:brawn] : 0),\n :intellect => (bonus_head[:intellect] ? bonus_head[:intellect] : 0),\n :soak => bonus_soak,\n },\n :legs => left_leg_active == right_leg_active\n }\n\n cybernetics\n end\n\n character_bonus_talents = CharacterBonusTalent.where(:character_id => self.id)\n unless character_bonus_talents.empty?\n character_bonus_talents.each do |bt|\n talent_ranks = RaceTalent.where(:race_id => self.race.id, :talent_id => bt.talent_id).first#.ranks\n unless talent_ranks.nil?\n if talents.has_key?(bt.talent_id)\n talents[bt.talent_id]['count'] = talents[bt.talent_id]['count'] + talent_ranks.ranks\n else\n talents[bt.talent_id] = {}\n talents[bt.talent_id]['count'] = talent_ranks.ranks\n talents[bt.talent_id]['options'] = Array.new\n end\n end\n end\n end\n\n # Include talent alterations from equipped armor.\n if self.armor_modification_bonuses['talents']\n self.armor_modification_bonuses['talents'].each do |armor_talents|\n if talents.has_key?(armor_talents)\n talents[armor_talents]['count'] = talents[armor_talents]['count'] + 1\n else\n talents[armor_talents] = {}\n talents[armor_talents]['count'] = 1\n talents[armor_talents]['options'] = Array.new\n end\n end\n end\n # Include talent alterations from equipped weapons.\n if self.weapon_modification_bonuses['talents']\n self.weapon_modification_bonuses['talents'].each do |weapon_talents|\n if talents.has_key?(weapon_talents)\n talents[weapon_talents]['count'] = talents[weapon_talents]['count'] + 1\n else\n talents[weapon_talents] = {}\n talents[weapon_talents]['count'] = 1\n talents[weapon_talents]['options'] = Array.new\n end\n end\n end\n talents\n end",
"def scan_for_distinct_bests\n team_distinct_best = RecordX4dDAO.new(@team, RecordType.find_by(code: 'TTB'))\n # Cycle between set genders, pools, events and distinct categories\n @gender_types.each do |gender_type|\n @pool_types.each do |pool_type|\n @event_types.each do |event_type|\n @distinct_categories.each do |category_type|\n record = get_team_best_individual_result(gender_type, pool_type, event_type, category_type.code)\n team_distinct_best.add_record(record) if record\n end\n end\n end\n end\n team_distinct_best\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
of sniff Version of the sniffer that uses multiple threads, may be better for bursty but otherwise low traffic environments. | def sniff_queue
queue = Queue.new
# Spin up a thread that just queues packets (a buffer, if you will)
qthread = Thread.new do
@sniffer.each_packet do |pkt|
queue.push pkt unless queue.length > 1000
end
end # of qthread
# Now read each of those packets
loop do
pkt = queue.pop
@event_collector.pkt_count += 1
@event_collector.bytes += pkt.caplen
case pkt
when @tcp_traffic
@tcp_handler.packet(pkt) if @tcp_handler
when @udp_traffic
@udp_handler.packet(pkt) if @udp_handler and pkt.udp? # INVESTIGATE!
end
end # of each_packet
end | [
"def sock\n\tself.scanner_socks ||= {}\n\tself.scanner_socks[Thread.current.to_s]\nend",
"def test_threading_non_keepalive\n d = create_driver(CONFIG_THREADING_NON_KEEPALIVE)\n d.end_if{ @posted.size == 3 }\n d.run(default_tag: 'test.metrics') do\n d.feed({ 'field1' => 50, 'field2' => 20, 'field3' => 10, 'otherfield' => 1 })\n end\n\n assert_equal 3, @posted.size\n v1st = @posted[0]\n v2nd = @posted[1]\n v3rd = @posted[2]\n\n assert_equal 50, v1st[:data][:number]\n assert_equal 'gauge', v1st[:data][:mode]\n assert_nil v1st[:auth]\n assert_equal 'service', v1st[:service]\n assert_equal 'metrics', v1st[:section]\n assert_equal 'test.metrics_field1', v1st[:name]\n\n assert_equal 20, v2nd[:data][:number]\n assert_equal 'test.metrics_field2', v2nd[:name]\n\n assert_equal 1, v3rd[:data][:number]\n assert_equal 'test.metrics_otherfield', v3rd[:name]\n end",
"def sniff!\n update_urls(check_sniff)\n end",
"def run(*args)\r\n server, port = *args\r\n Spi::Base.site = \"http://#{server}:#{port || 8020}/v1\"\r\n @server = Spi::Mo.all(:params=>{:type => :PDMServer}).first\r\n @reporter.add(:global, \"整体报告\") do |rpt|\r\n rpt.add(:start_at, \"验收开始时间\", Time.now)\r\n rpt.add(:server_addr, \"服务器地址\", server)\r\n rpt.add(:server_up_time, \"服务器启动时间\", @server.get_indicator(:UpTime).value)\r\n rpt.add(:server_config, \"服务器配置\", \"2C4G Windows 2008 X86 32\") # I should get this info by inspect, instead of hard-code\r\n end\r\n @reporter.add take_snapshot(:init_snapshot, \"服务器初始快照\")\r\n # how many ApiDelay workers\r\n if ((count = options[:case_api_delay]) && count > 0 )\r\n (count - 1).times do |i|\r\n @threads[\"api_delay_thread_#{i}\".to_sym] = Thread.new do\r\n Accept::ApiDelay.new(i, 1).run\r\n end\r\n end\r\n end\r\n # how many GetIndicator workers\r\n if ((count = options[:case_get_indicator_delay]) && count > 0 )\r\n (count-1).times do |i|\r\n @threads[\"get_indicator_delay_thread_#{i}\".to_sym] = Thread.new do\r\n Accept::GetIndicator.new(i, 1).run\r\n end\r\n end\r\n end\r\n\r\n if (options[:case_probe_tolerance])\r\n @threads[:probe_tolerance_thread] = Thread.start do\r\n Accept::ProbeTolerance.new(@reporter).run\r\n end\r\n end\r\n\r\n if (options[:case_threshold_receive])\r\n @threads[:threshold_receive_thread] = Thread.start do\r\n Accept::ThresholdReceive.new(@reporter).run\r\n end\r\n end\r\n\r\n if (options[:case_record_receive])\r\n @threads[:record_receive_thread] = Thread.start do\r\n Accept::RecordReceive.new(@reporter).run\r\n end\r\n end\r\n\r\n if (options[:case_stability])\r\n @threads[:stability_thread] = Thread.start do\r\n Accept::Stability.new(@reporter).run\r\n end\r\n end\r\n @reporter.output\r\n @threads.each_pair do |name, thread|\r\n thread.join\r\n end\r\n end",
"def start_parser_thread\n BlueHydra.logger.info(\"Parser thread starting\")\n self.parser_thread = Thread.new do\n begin\n\n scan_results = {}\n @rssi_data ||= {} if BlueHydra.signal_spitter\n\n # get the chunks and parse them, track history, update CUI and push\n # to data processing thread\n while chunk = chunk_queue.pop do\n p = BlueHydra::Parser.new(chunk.dup)\n p.parse\n\n attrs = p.attributes.dup\n\n address = (attrs[:address]||[]).uniq.first\n\n if address\n\n if !BlueHydra.daemon_mode || BlueHydra.file_api\n tracker = CliUserInterfaceTracker.new(self, chunk, attrs, address)\n tracker.update_cui_status\n end\n\n if scan_results[address]\n needs_push = false\n\n attrs.each do |k,v|\n\n unless [:last_seen, :le_rssi, :classic_rssi].include? k\n unless attrs[k] == scan_results[address][k]\n scan_results[address][k] = v\n needs_push = true\n end\n else\n case\n when k == :last_seen\n current_time = attrs[k].sort.last\n last_seen = scan_results[address][k].sort.last\n\n # update this value no more than 1 x / minute to avoid\n # flooding pulse with too much noise.\n if (current_time - last_seen) > 60\n attrs[k] = [current_time]\n scan_results[address][k] = attrs[k]\n needs_push = true\n else\n attrs[k] = [last_seen]\n end\n\n when [:le_rssi, :classic_rssi].include?(k)\n current_time = attrs[k][0][:t]\n last_seen_time = (scan_results[address][k][0][:t] rescue 0)\n\n # if log_rssi is set log all values\n if BlueHydra.config[\"rssi_log\"] || BlueHydra.signal_spitter\n attrs[k].each do |x|\n # unix timestamp from btmon\n ts = x[:t]\n\n # '-90 dBm' -> -90\n rssi = x[:rssi].split(' ')[0].to_i\n\n if BlueHydra.config[\"rssi_log\"]\n # LE / CL for classic mode\n type = k.to_s.gsub('_rssi', '').upcase[0,2]\n\n msg = [ts, type, address, rssi].join(' ')\n BlueHydra.rssi_logger.info(msg)\n end\n if BlueHydra.signal_spitter\n @rssi_data_mutex.synchronize {\n @rssi_data[address] ||= []\n @rssi_data[address] << {ts: ts, dbm: rssi}\n }\n end\n end\n end\n\n # if aggressive_rssi is set send all rssis to pulse\n # this should not be set where avoidable\n # signal_spitter *should* make this irrelevant, remove?\n if BlueHydra.config[\"aggressive_rssi\"] && ( BlueHydra.pulse || BlueHydra.pulse_debug )\n attrs[k].each do |x|\n send_data = {\n type: \"bluetooth-aggressive-rssi\",\n source: \"blue-hydra\",\n version: BlueHydra::VERSION,\n data: {}\n }\n send_data[:data][:status] = \"online\"\n send_data[:data][:address] = address\n send_data[:data][:sync_version] = BlueHydra::SYNC_VERSION\n send_data[:data][k] = [x]\n\n # create the json\n json_msg = JSON.generate(send_data)\n #send the json\n BlueHydra::Pulse.do_send(json_msg)\n end\n end\n\n # update this value no more than 1 x / minute to avoid\n # flooding pulse with too much noise.\n if (current_time - last_seen_time) > 60\n scan_results[address][k] = attrs[k]\n needs_push = true\n else\n attrs.delete(k)\n end\n end\n end\n end\n\n if needs_push\n result_queue.push(attrs) unless self.stunned\n end\n else\n scan_results[address] = attrs\n result_queue.push(attrs) unless self.stunned\n end\n\n end\n\n end\n rescue => e\n BlueHydra.logger.error(\"Parser thread #{e.message}\")\n e.backtrace.each do |x|\n BlueHydra.logger.error(\"#{x}\")\n end\n BlueHydra::Pulse.send_event('blue_hydra',\n {key:'blue_hydra_parser_thread_error',\n title:'Blue Hydras Parser Thread Encountered An Error',\n message:\"Parser thread error: #{e.message}\",\n severity:'ERROR'\n })\n end\n end\n end",
"def min_threads\n @min_threads || 1\n end",
"def simple\n\tself.scanner_simples ||= {}\n\tself.scanner_simples[Thread.current.to_s]\nend",
"def blocking_factor\r\n end",
"def start_threads\n \n # generate computers cache model shortcuts\n Main.active.clusters.each do |computers|\n computers.each { |c| Main.active.computers_cache[c.id]=c }\n end\n\n # load user names from yppassed\n # TODO: move to user model class?\n #IO.popen(\"ypcat passwd\").each { |line|\n # Main.active.user_list.add(line.split(\":\").values_at(0, 4)) \n #}\n\n refresh = Thread.new {\n session[:old_timestamp] = 0\n\n while true\n puts \"refresh start\"\n # update prectab data\n if Prectab.changed?\n Main.active.computers_cache.each_value {|computer| computer.prectab = [nil,nil]; computer.color_changed; computer.user_changed }\n Debug.log.debug \"working prectab\"\n scatter_prectab(Prectab.now,0)\n scatter_prectab(Prectab.soon,1)\n end\n\n # update computers_cache\n comps = Computer.updated_after session[:old_timestamp]\n comps.each do |computer| \n cache_computer = Main.active.computers_cache[computer.id]\n if cache_computer\n cache_computer.User = computer.user \n cache_computer.Color = computer.color\n end\n end\n session[:old_timestamp] = Time.now.strftime(\"%j%H%M%S\")\n\n # update printers\n @printers.each { |p| p.update_job_count; p.update_accepts; p.update_snmp }\n puts \"refresh end\"\n sleep 20\n end \n }\n \n # read data from scanner and dispatch\n require 'socket'\n begin\n socket = TCPSocket.new('localhost', 7887)\n rescue Errno::ECONNREFUSED\n Main.active.status = [\"Scanner\", t('scanner.no_connection'), \"important\",-1]\n else\n scanner = Thread.new {\n Debug.log.debug \"starting scanner thread ...\"\n while true\n scan = socket.recvfrom(25)\n type, Main.active.scan_string = check_scanner_string(scan[0])\n Debug.log.debug \"Scanner says #{scan} #{type}, #{Main.active.scan_string}\"\n \n case type\n when :card\n accounts = User.find_accounts_by_barcode(Main.active.scan_string)\n fill_accounts(accounts)\n when :matrikel\n accounts = Account.find_accounts_by_barcode(Main.active.scan_string)\n fill_accounts(accounts)\n when :key\n pc = Main.active.computers_cache[Main.active.scan_string]\n puts pc\n unless Main.active.account_list.empty?\n table_register(pc)\n else\n case pc.user\n when \"\"\n Main.active.status = [\"#{pc.id}\", \"ist schon frei\", \"key\",0] \n else\n Main.active.status = [\"#{pc.user}\", \"von <b>#{pc.id}</b> abgemeldet\", \"trashcan_full\",1]\n end\n key_clear(pc)\n end\n else\n Debug.log.debug \"#{type}, #{Main.active.scan_string}\"\n end\n \n sleep 1 # wait some time for next scan atempt\n end\n }\n end\n end",
"def monitor_system\n @monitor_thread = Thread.new do\n loop do\n was_overloaded = @overloaded\n @overloaded = overloaded?\n check_in if was_overloaded && !@overloaded\n sleep MONITOR_INTERVAL\n end\n end\n end",
"def tracer_thread_runner\n while running?\n # Get a random user assigned to this server.\n user = User.where(:enable_tracer => true, :archived => false).select(:id, :connected_at).all.select do |user|\n server_rhash.hash(user.id) == server_tag && user.connected_at\n end.shuffle.first\n\n # If we found a user, schedule a tracer email.\n if user\n user.reload\n ScheduleTracerEmails.new(user, self.num_tracers).delay.run\n end\n\n light_sleep self.tracer_interval\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping tracer thread.\")\n end",
"def thread_id\n check_connection\n @protocol.thread_id\n end",
"def main\n puts \"Running Netservate #{@version}...\"\n\n # Main loop\n while true do\n begin\n\n # Begin test\n puts \"\\nBeginning network test...\"\n test_time = Time.now.strftime('%c')\n test = Speedtest::Test.new()\n net_results = nil\n\n # Test\n begin\n Timeout.timeout(@config['NETSERVATE']['TEST_TIMEOUT'].to_i || 90) { net_results = test.run }\n rescue\n puts \"Test timed out - assuming failure.\"\n end\n\n # Print/check results\n download_checked = false\n upload_checked = false\n result_text = nil\n if net_results != nil\n download_checked = true if net_results.pretty_download_rate.to_i != 0\n upload_checked = true if net_results.pretty_upload_rate.to_i != 0\n result_text = \"\\nServer: #{net_results.server}\\n\"\\\n \"Download rate: #{download_checked ? net_results.pretty_download_rate : \"n/a\"}\\n\"\\\n \"Upload rate: #{upload_checked ? net_results.pretty_upload_rate : \"n/a\"}\\n\"\\\n \"Latency: #{net_results.latency}\\n\"\\\n \"Time: #{test_time}\\n\"\n puts result_text\n # Store results in array\n if @results.length >= 20\n @results.shift # Remove first result if 20\n end\n @results.push({\n server: net_results.server,\n download: download_checked ? net_results.pretty_download_rate : \"n/a\",\n upload: upload_checked ? net_results.pretty_upload_rate : \"n/a\",\n time: test_time\n })\n else\n result_text = \"\\nServer: Test timed out.\\n\"\\\n \"Download rate: n/a\\n\"\\\n \"Upload rate: n/a\\n\"\\\n \"Latency: n/a\\n\"\\\n \"Time: #{test_time}\\n\"\n puts result_text\n # Store results in array\n if @results.length >= 20\n @results.shift # Remove first result if 20\n end\n @results.push({\n server: \"Test timed out.\",\n download: \"n/a\",\n upload: \"n/a\",\n time: test_time\n })\n end\n\n # Log results\n begin\n logger = Logger.new(\"#{@root_path}/log/netservate.log\", 10, 1024000)\n logger.info result_text\n rescue => error\n puts \"ERROR: \" + error\n end\n\n # Check criteria\n if (net_results == nil) ||\n (net_results.pretty_download_rate.to_f < @config['NETSERVATE']['MIN_DOWNLOAD_SPEED'].to_f && download_checked) ||\n (net_results.pretty_upload_rate.to_f < @config['NETSERVATE']['MIN_UPLOAD_SPEED'].to_f && upload_checked)\n @failed_test_count += 1\n puts \"Test does not meet criteria. (#{@failed_test_count})\"\n\n # If too many fails in a row - send an alert.\n if (@failed_test_count % @config['NETSERVATE']['FAILS_IN_A_ROW'].to_i == 0)\n send_alert(\n subject: \"Netservate Alert\",\n message: \"There have been #{@failed_test_count.to_s} failed network speed tests in a row.\"\n )\n end\n\n # Wait before next loop - Reset if max fail count reached.\n if @failed_test_count < @config['NETSERVATE']['MAX_FAILS_IN_A_ROW'].to_i\n puts \"\\nNext test in #{@fail_wait_time} seconds...\"\n sleep(@fail_wait_time)\n else\n puts \"\\nMax fails in a row reached...\"\n puts \"Next test in #{@wait_time} seconds...\"\n @failed_test_count = 0\n sleep(@wait_time)\n end\n\n else\n @failed_test_count = 0\n puts \"Test meets criteria.\"\n puts \"\\nNext test in #{@wait_time} seconds...\"\n # Wait before next loop\n sleep(@wait_time)\n end\n\n rescue => error\n puts \"ERROR: \" + error\n end\n\n end\n end",
"def silence_single_worker_warning; end",
"def initialize\n @threads = []\n end",
"def server_timing; end",
"def run_it\n# @thread = Thread.new { \n files = {}\n def_logf = LogFile.new('default', nil)\n File.open($options['rt_socket'], 'r') { |logs|\n begin\n#puts \"getting data\\n\";\n while logs.gets\n#\t all, utime, time, hn, record = $_.match(Host::LOG_HEAD).to_a\n hn = $log_store.extract_rt_host($_)\n#puts hn\n hn.sub!(/\\.#{$options['hostdomain']}$/o, '') if $options['hostdomain']\n#\t pp rec if $options['debug.split']\n\n#\t hn = h.sub(/\\.#{$options['hostdomain']}$/o, '') if $options['hostdomain']\n\n next if $options['one_host'] && $options['one_host'] != hn\n\n unless host = @hosts[hn] then\n @host_patterns.each { |name, h|\n if hn.match(h.pattern) then\n host = @hosts[hn] = h.dup\n host.name = hn\n\n break\n end\n }\n end\n next unless host\n\n unless files[hn]\n if f = (host.file['all']) then\n files[hn] = f.class != Regexp ? f : LogFile.new(@file['all'])\n end\n end\n\n rec = files[hn]['logtype'].gets(nil, $_)\n# rec.split\n\n pp rec if $options['debug.split']\n# host.scanner( '', time, proc, facility, level, record, orec )\n puts rec.orec\n host.send host.rule_set, 'TEST', rec\n# pp \">>>>\", host.rule_set \n\n end\n rescue StandardError => e\n puts \"\\n\", e.to_str\n puts e.backtrace.join(\"\\n\")\n end\n }\n\n end",
"def setup_raw\n @thread = Thread.current\n @running = true\n end",
"def start_request_supernodes_thread\n Thread.new do \n # read the request interval\n interval = @driver.config['request_interval'].to_i\n # number of supernodes each time\n number = @driver.config['request_number'].to_i\n \n while true\n sleep(interval)\n # get supernodes sockets from supernode table\n socks = @supernode_table.supernodes\n # Sends +RequestSupernodes+ message. Because the number of socks is not\n # so large, and it doesn't wait for the response after sending, it sends\n # messages one by one here instead of using multiple threads.\n request_msg = Protocol::RequestSupernodes.new(number)\n request_msg.ctime = DateTime.now\n socks.each do |sock|\n request_supernodes(sock,request_msg)\n end\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
of packet() If the sequence number is valid, update the stream attributes. If not, perform the appropriate response but don't update the stream. Return true if valid and should continue parsing, false if it shouldn't, and a pkt if there is a queued next packet that needs to be injected into the stream. | def validate_sequence_numbers(pkt, state, dir)
expected_seq = dir == :up ? state.seq_up : state.seq_down
# If we don't have an expected sequence number yet, set one
expected_seq = pkt.tcp_seq if expected_seq == 0
# If we did not expect this sequence number, handle dissonance
if pkt.tcp_seq != expected_seq
return nil if pkt.tcp_seq < expected_seq # OS would ignore this packet
# The sequence number is high - save it for later?
if pkt.tcp_seq - expected_seq < FORWARD_WINDOW
segments = dir == :up ? state.segments_up : state.segments_down
segments[pkt.tcp_seq] = pkt
else # This packet is too far in advance, we're aborting on this steram
@event_collector.send(:tcp_stream_end) do
{ :syn_seen => !!state.syn_seen,
:src_ip => @protos.str_ip(pkt.src.to_i),
:dst_ip => @protos.str_ip(pkt.dst.to_i), :src_port => pkt.sport,
:dst_port => pkt.dport, :rst => false,
:fin => false, :sync => true, :timeout => false }
end
@protos.conclude(state, :up) # Kill the stream in both directions
@protos.conclude(state, :down)
state.app_state = nil # not parsing anymore
#delete_state(state) # don't delete the state, FIN/RST will do it.
end
return nil # in either case, we don't process the packet right now
# Sequence number was what we expected, this is part of our stream
else
# If this was a SYN packet, increase next expected sequence number by 1
# as specified by the TCP RFC.
expected_seq += 1 if pkt.tcp_syn?
# Adjust our next expected sequence number
if dir == :up
state.seq_up = (expected_seq + pkt.tcp_data_len) % 4294967296
else
state.seq_down = (expected_seq + pkt.tcp_data_len) % 4294967296
end
# Do we have a queued packet that we received out of order?
segments = dir == :up ? state.segments_up : state.segments_down
if segments.length > 0
queued_pkt = segments[expected_seq]
segments.reject! { |k,_| k <= expected_seq } # delete all passed segs
if queued_pkt
return queued_pkt
end
end # of if segments.length > 0
end
true
end | [
"def valid?\n \n #If we have a checksum field, then check it against the computed checksum.\n if respond_to?(:checksum)\n checksum.force_encoding('UTF-8') == computed_checksum.force_encoding('UTF-8')\n #Otherwise, assume the packet is valid.\n else\n true\n end\n\n end",
"def parsed?\n not @sequence.nil?\n end",
"def process_sequence(sequence, parameters)\n\tif parameters[:nth_sequence] != nil\n\t\tif sequence[:num_sequence] != parameters[:nth_sequence]\n\t\t\treturn false\n\t\tend\n\tend\n\n\tif parameters[:from_sequence] != nil\n\t\tif sequence[:num_sequence] < parameters[:from_sequence] ||\n\t\t\tsequence[:num_sequence] > parameters[:to_sequence]\n\t\t\treturn false\n\t\tend\n\tend\n\n\tif parameters[:header_condition] != nil\n\t\tif !sequence[:header].downcase.include?(parameters[:header_condition].downcase)\n\t\t\treturn false\n\t\tend\n\tend\n\n\tif parameters[:content_condition] != nil\n\t\tif !sequence[:content].include?(parameters[:content_condition])\n\t\t\treturn false\n\t\tend\n\tend\n\n\treturn true\nend",
"def parse_bind_response sequence\n\t\t\tsequence.length >= 3 or raise LdapPduError\n\t\t\t@ldap_result = {:resultCode => sequence[0], :matchedDN => sequence[1], :errorMessage => sequence[2]}\n\t\t\t@ldap_result[:serverSaslCreds] = sequence[3] if sequence.length >= 4\n\t\t\t@ldap_result\n\t\tend",
"def gtp_session_complete?(sequence_number) \n (@gtp_session[sequence_number][:REQUEST].key?(:req_res) && @gtp_session[sequence_number][:RESPONSE].key?(:req_res))\n end",
"def valid_packet?(bytes)\n # for the DS10A, the address pattern seems to be as follows:\n # (purely from experimentation)\n # for byte0 and byte1, lower nibbles are identical,\n # while upper nibbles are inverse of eachother\n #\n # byte 2 is used as follows:\n # bit 0 - open (if low) or closed (if high)\n # bit 5 - 1 for min, 0 for max\n # bit 7 - 1 for low battery\n # and bit 1,2,3,4,6 are always zero\n # byte 3 is inverse of byte 2\n (bytes[0] & 0x80 == 0x80) && # bit 7 of byte0 always high\n (bytes[0] & 0x0F == bytes[1] & 0x0F) && # lower nibble of byte0 and byte1 are identical\n ((bytes[0]>>4)^(bytes[1]>>4) == 0x0F) && # upper nibble are inverse of each other\n inverse_of?(bytes[2], bytes[3]) && # byte2 is inverse of byte3\n (0b01011110 & bytes[2] == 0) # bits 0, 5, 7 must not be set on byte 2\n end",
"def allow?(packet); end",
"def valid?\n case packet_smb_version\n when 'SMB1'\n return smb_header.protocol == RubySMB::SMB1::SMB_PROTOCOL_ID &&\n smb_header.command == self.class::COMMAND\n when 'SMB2'\n return smb2_header.protocol == RubySMB::SMB2::SMB2_PROTOCOL_ID &&\n smb2_header.command == self.class::COMMAND\n end\n end",
"def valid_packet?(bytes)\n (bytes[0] & 0x80 == 0x80) && # bit 7 of byte0 always high\n (bytes[0] & 0x0F == bytes[1] & 0x0F) && # lower nibble of byte0 and byte1 are identical\n ((bytes[0]>>4)^(bytes[1]>>4) == 0x0F) && # upper nibble are inverse of each other\n inverse_of?(bytes[2], bytes[3]) && # byte2 is inverse of byte3\n (bytes[2] >> 3 == 0b01100) # bits 3-7 of byte2 is 01100\n end",
"def process(packet)\n raise \"received packet type #{packet.read_byte} and was not expecting any packet\"\n end",
"def streamValidation(stream)\n active = 0\n for char in stream\n if active == 0\n next if char & 128 == 0\n if char & 192 == 192 && char & 32 == 0\n active = 1\n elsif char & 224 == 224 && char & 16 == 0\n active = 2\n elsif char & 240 == 240 && char & 8 == 0\n active = 3\n else\n return false\n end\n else\n return false if char & 128 != 128\n active -= 1\n end\n end\n active.zero?\nend",
"def parse(packet); end",
"def process(packet)\n @init.call(Net::SSH::Packet.new(packet.to_s)) if @init\n type = packet.read_byte\n raise \"expected #{@type}, but got #{type}\" if @type != type\n\n @data.zip(types).each do |expected, _type|\n _type ||= case expected\n when nil then break\n when Numeric then :long\n when String then :string\n when TrueClass, FalseClass then :bool\n end\n\n actual = packet.send(\"read_#{_type}\")\n next if expected.nil?\n raise \"expected #{_type} #{expected.inspect} but got #{actual.inspect}\" unless expected == actual\n end\n end",
"def response?\n (self.type == PACKET_TYPE_RESPONSE || self.type == PACKET_TYPE_PLAIN_RESPONSE)\n end",
"def do_parse(signature)\n packet = nil\n case signature.sigtype\n when Type::BYTE\n packet = get(1).unpack(\"C\")[0]\n when Type::UINT16\n align(2)\n packet = get(2).unpack(@uint16)[0]\n when Type::INT16\n align(4)\n packet = get(4).unpack(@uint16)[0]\n if (packet & 0x8000) != 0\n packet -= 0x10000\n end\n when Type::UINT32\n align(4)\n packet = get(4).unpack(@uint32)[0]\n when Type::INT32\n align(4)\n packet = get(4).unpack(@uint32)[0]\n if (packet & 0x80000000) != 0\n packet -= 0x100000000\n end\n when Type::UINT64\n align(8)\n packet_l = get(4).unpack(@uint32)[0]\n packet_h = get(4).unpack(@uint32)[0]\n if @endianness == LIL_END\n packet = packet_l + packet_h * 2**32\n else\n packet = packet_l * 2**32 + packet_h\n end\n when Type::INT64\n align(8)\n packet_l = get(4).unpack(@uint32)[0]\n packet_h = get(4).unpack(@uint32)[0]\n if @endianness == LIL_END\n packet = packet_l + packet_h * 2**32\n else\n packet = packet_l * 2**32 + packet_h\n end\n if (packet & 0x8000000000000000) != 0\n packet -= 0x10000000000000000\n end\n when Type::BOOLEAN\n align(4)\n v = get(4).unpack(@uint32)[0]\n raise InvalidPacketException if not [0, 1].member?(v)\n packet = (v == 1)\n when Type::ARRAY\n align(4)\n # checks please\n array_sz = get(4).unpack(@uint32)[0]\n raise InvalidPacketException if array_sz > 67108864\n\n align(signature.child.alignment)\n raise IncompleteBufferException if @idx + array_sz > @buffy.size\n\n packet = Array.new\n start_idx = @idx\n while @idx - start_idx < array_sz\n packet << do_parse(signature.child)\n end\n\n if signature.child.sigtype == Type::DICT_ENTRY then\n packet = packet.inject(Hash.new) do |hash, pair|\n hash[pair[0]] = pair[1]\n hash\n\t end\n end\n when Type::STRUCT\n align(8)\n packet = Array.new\n signature.members.each do |elem|\n packet << do_parse(elem)\n end\n when Type::VARIANT\n string = get_signature\n # error checking please\n sig = Type::Parser.new(string).parse[0]\n packet = do_parse(sig)\n when Type::OBJECT_PATH\n packet = get_string\n when Type::STRING\n packet = get_string\n when Type::SIGNATURE\n packet = get_signature\n when Type::DICT_ENTRY\n align(8)\n key = do_parse(signature.members[0])\n value = do_parse(signature.members[1])\n packet = [key, value]\n else\n raise NotImplementedError,\n\t \"sigtype: #{signature.sigtype} (#{signature.sigtype.chr})\"\n end\n packet\n end",
"def allow?(packet)\n !pending? || Algorithms.allowed_packet?(packet)\n end",
"def check_packets()\n checked = Array.new()\n PQ.each do |packet| \n if (checked.include?(packet[:beefhook]+':'+String(packet[:stream_id])))\n next\n end\n checked << packet[:beefhook]+':'+String(packet[:stream_id])\n pc = 0\n PQ.each do |p| \n if (packet[:beefhook] == p[:beefhook] and packet[:stream_id] == p[:stream_id])\n pc += 1\n end\n end\n if (packet[:packet_count] == pc)\n packets = expunge(packet[:beefhook], packet[:stream_id])\n data = ''\n packets.each_with_index do |sp,i|\n if (packet[:beefhook] == sp[:beefhook] and packet[:stream_id] == sp[:stream_id])\n data += sp[:data]\n end\n end\n b64 = Base64.decode64(data) \n begin\n res = JSON.parse(b64).first\n res['beefhook'] = packet[:beefhook]\n res['request'] = @request\n res['beefsession'] = @request.get_hook_session_id()\n execute(res)\n rescue JSON::ParserError => e\n print_debug 'Network stack could not decode packet stream.'\n print_debug 'Dumping Stream Data [base64]: '+data\n print_debug 'Dumping Stream Data: '+b64\n end\n end\n end\n end",
"def packet_stream packet # :nodoc:\n payload = packet.payload\n\n return if payload.empty?\n\n source = packet.source\n\n if previous = @incomplete_streams.delete(source) then\n payload = previous << payload\n elsif /\\A....\\x04\\x08/m !~ payload then\n @drb_streams[source] = false\n return\n end\n\n stream = StringIO.new payload\n stream.set_encoding Encoding::BINARY, Encoding::BINARY\n stream\n end",
"def check_packets()\n checked = Array.new()\n PQ.each do |packet| \n if (checked.include?(packet[:beefhook]+':'+String(packet[:stream_id])))\n next\n end\n checked << packet[:beefhook]+':'+String(packet[:stream_id])\n pc = 0\n PQ.each do |p| \n if (packet[:beefhook] == p[:beefhook] and packet[:stream_id] == p[:stream_id])\n pc += 1\n end\n end\n if (packet[:packet_count] == pc)\n packets = expunge(packet[:beefhook], packet[:stream_id])\n data = ''\n packets.each_with_index do |sp,i|\n if (packet[:beefhook] == sp[:beefhook] and packet[:stream_id] == sp[:stream_id])\n data += sp[:data]\n end\n end\n b64 = Base64.decode64(data) \n begin\n res = JSON.parse(b64).first\n res['beefhook'] = packet[:beefhook]\n res['request'] = @request\n res['beefsession'] = @request[BeEF::Core::Configuration.instance.get('beef.http.hook_session_name')]\n execute(res)\n rescue JSON::ParserError => e\n print_debug 'Network stack could not decode packet stream.'\n print_debug 'Dumping Stream Data [base64]: '+data\n print_debug 'Dumping Stream Data: '+b64\n end\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /wishes/new GET /wishes/new.json | def new
@wish = Wish.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @wish }
end
end | [
"def new\n @wish_item = WishItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wish_item }\n end\n end",
"def new\n @wishlistitem = Wishlistitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishlistitem }\n end\n end",
"def new\n @wishline = Wishline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishline }\n end\n end",
"def new\n @wishname = Wishname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishname }\n end\n end",
"def new\n @wish_list_item = WishListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wish_list_item }\n end\n end",
"def new\n @wish_list = WishList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wish_list }\n end\n end",
"def new\n @wish = current_user.wishes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wish }\n end\n end",
"def new\n @wishwall = Wishwall.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishwall }\n end\n end",
"def new\n @new_item = NewItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_item }\n end\n end",
"def create\n @wish = Wish.new(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, :notice => 'Wish was successfully created.' }\n format.json { render :json => @wish, :status => :created, :location => @wish }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @wish.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @wish = Wish.new(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, notice: 'Wish was successfully created.' }\n format.json { render json: @wish, status: :created, location: @wish }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @wanted = Wanted.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wanted }\n end\n end",
"def new\n @like = Like.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @like }\n end\n end",
"def new\n @wishlist_item = WishlistItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishlist_item }\n end\n end",
"def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favorite }\n end\n end",
"def new\n @thing = Thing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end",
"def new\n @dish = Dish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dish }\n end\n end",
"def new\n @fish = Fish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fish }\n end\n end",
"def new\n @purge = Purge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purge }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /wishes POST /wishes.json | def create
@wish = current_user.wishes.build(params[:wish])
if @wish.save
flash[:success] = "Wish created!"
redirect_to root_url
else
@feed_items = []
render 'static_pages/home'
end
end | [
"def create\n @wish = Wish.new(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, :notice => 'Wish was successfully created.' }\n format.json { render :json => @wish, :status => :created, :location => @wish }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @wish.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @wish = Wish.new(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, notice: 'Wish was successfully created.' }\n format.json { render json: @wish, status: :created, location: @wish }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wish = Wish.create(wish_params)\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, notice: 'Wish was successfully created.' }\n format.json { render :show, status: :created, location: @wish }\n else\n format.html { render :new }\n format.json { render json: @wish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wish = current_user.wishes.build(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to(@wish, :notice => 'Wish was successfully created.') }\n format.xml { render :xml => @wish, :status => :created, :location => @wish }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @wish.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find_by(:id => params[:user_id])\n\t@wish_item = @user.wish_items.build(wish_item_params)\n #@wish_item = WishItem.new(wish_item_params)\n\n respond_to do |format|\n if @wish_item.save\n format.html { redirect_to @wish_item, notice: 'Wish item was successfully created.' }\n #format.json { render json: { :wish_item => current_user.wish_items } }\n format.json { render json: { :status => '200' } }\n else\n format.html { render json: { :params => @user, :error => 'create_item_failed' } }\n format.json { render json: { :params => @user, :error => 'create_item_failed' } }\n end\n end\n end",
"def create\n @item = Item.find(params[:item_id])\n @wish_item = @wishlist.add_item(@item)\n\n respond_to do |format|\n if @wish_item.save\n format.html { redirect_to @wish_item.wishlist}\n format.json { render :show, status: :created, location: @wish_item }\n else\n format.html { render :show }\n format.json { render json: @wish_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @wishes = Wish.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wishes }\n end\n end",
"def create\n @wish_list_item = WishListItem.new(params[:wish_list_item])\n\n respond_to do |format|\n if @wish_list_item.save\n format.html { redirect_to @wish_list_item, notice: 'Wish list item was successfully created.' }\n format.json { render json: @wish_list_item, status: :created, location: @wish_list_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wish_list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wishlist_item = WishlistItem.new(params[:wishlist_item])\n\n respond_to do |format|\n if @wishlist_item.save\n format.html { redirect_to @wishlist_item, :notice => 'Wishlist item was successfully created.' }\n format.json { render :json => @wishlist_item, :status => :created, :location => @wishlist_item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @wishlist_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @wish_list = WishList.new(params[:wish_list])\n @wish_list.user = current_user\n\t respond_to do |format|\n\t\t if @wish_list.save\n\t\t\t format.html { redirect_to @wish_list, notice: 'The Wish List item was successfully created.' }\n format.json { render json: @wish_list, status: :created, location: @wish_list }\n\t\t else\n\t\t\t format.html { render action: \"new\" }\n\t\t\t format.json { render json: @wish_list.errors, status: :unprocessable_entity }\n\t\t end\n\t end\t\n end",
"def create\n @wishlist = Wishlist.new(name: params[:wishlist][:name],\n user_id: current_user.email,\n shared: params[:wishlist][:shared])\n current_user.wishlists << @wishlist\n respond_to do |format|\n if @wishlist.save\n format.html { redirect_to @wishlist, notice: 'Wishlist was successfully created.' }\n format.json { render :index, status: :created, location: @wishlist }\n else\n format.html { render :new }\n format.json { render json: @wishlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wishwall = Wishwall.new(params[:wishwall])\n\n respond_to do |format|\n if @wishwall.save\n format.html { redirect_to @wishwall, notice: 'Wishwall was successfully created.' }\n format.json { render json: @wishwall, status: :created, location: @wishwall }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wishwall.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pizza = Pizza.new(pizza_params)\n if @pizza.save\n ActionCable.server.broadcast 'pizzas', {}\n render json: @pizza\n else\n render json: @pizza.errors, status: :unprocessable_entity\n end\n end",
"def create\n @wish_list = current_user.wish_lists.build(params[:wish_list])\n\n respond_to do |format|\n if @wish_list.save\n format.html { redirect_to new_wish_list_item_path(@wish_list), notice: 'Wish list was successfully created.' }\n format.json { render json: @wish_list, status: :created, location: @wish_list }\n else\n flash[:alert] = \"Wish list has not been created.\"\n format.html { render action: \"new\" }\n format.json { render json: @wish_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wish_list = WishList.new(params[:wish_list])\n current_wish_list.user = current_user\n current_wish_list.save\n\n respond_to do |format|\n if @wish_list.save\n format.html { redirect_to @wish_list, notice: 'Wish list was successfully created.' }\n format.json { render json: @wish_list, status: :created, location: @wish_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wish_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @wish = current_user.wishes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wish }\n end\n end",
"def create\n @storylike = Storylike.new(storylike_params)\n\n if @storylike.save\n render json: @storylike\n else\n render json: @storylike.errors, status: :unprocessable_entity\n end\n end",
"def create\n @wanted_item = WantedItem.new(wanted_item_params)\n\n respond_to do |format|\n if @wanted_item.save\n format.html { redirect_to @wanted_item, notice: 'Wanted item was successfully created.' }\n format.json { render :show, status: :created, location: @wanted_item }\n else\n format.html { render :new }\n format.json { render json: @wanted_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @wishes = Wish.all\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /wishes/1 PUT /wishes/1.json | def update
@wish = Wish.find(params[:id])
respond_to do |format|
if @wish.update_attributes(params[:wish])
format.html { redirect_to @wish, notice: 'Wish was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @wish.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @wish = Wish.find(params[:id])\n\n respond_to do |format|\n if @wish.update_attributes(params[:wish])\n format.html { redirect_to @wish, :notice => 'Wish was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @wish.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @wish_item = WishItem.find(params[:id])\n\n respond_to do |format|\n if @wish_item.update_attributes(params[:wish_item])\n format.html { redirect_to @wish_item, notice: 'Wish item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wish_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wish.update(wish_params)\n format.html { redirect_to @wish, notice: 'Wish was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wish = current_user.wishes.find(params[:id])\n redirect_to(@wish) if @wish.status != 0\n\n respond_to do |format|\n if @wish.update_attributes(params[:wish])\n format.html { redirect_to(@wish, :notice => 'Wish was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @wish.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @wishitem = Wishitem.find(params[:id])\n\n respond_to do |format|\n if @wishitem.update_attributes(params[:wishitem])\n format.html { redirect_to @wishitem, notice: 'Wishitem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wishitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wish_item.update(wish_item_params)\n format.html { redirect_to @wish_item, notice: 'Wish item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wish_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put *args\n make_request :put, *args\n end",
"def update\n @wishname = Wishname.find(params[:id])\n\n respond_to do |format|\n if @wishname.update_attributes(params[:wishname])\n format.html { redirect_to @wishname, notice: 'Wishname was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wishname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wish_list = WishList.find(params[:id])\n\n respond_to do |format|\n if @wish_list.update_attributes(params[:wish_list])\n format.html { redirect_to @wish_list, notice: 'The Wish List item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wish_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @final_wish\n @final_wish_info = @final_wish\n @previous_share_with = @final_wish_info.final_wishes.map(&:share_with_contact_ids)\n message = success_message\n FinalWishService.fill_wishes(final_wish_form_params, @final_wish_info, resource_owner.id)\n authorize_save\n respond_to do |format|\n if validate_params && @final_wish_info.update(final_wish_params)\n FinalWishService.update_shares(@final_wish_info, @previous_share_with, resource_owner)\n success_path(final_wish_path(@final_wish_info), final_wish_shared_view_path(shared_user_id: resource_owner.id, id: @final_wish_info.id))\n format.html { redirect_to @path, flash: { success: message } }\n format.json { render :show, status: :ok, location: @final_wish_info }\n else\n error_path(:edit)\n format.html { render controller: @path[:controller], action: @path[:action], layout: @path[:layout] }\n format.json { render json: @final_wish_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wish_list_item = WishListItem.find(params[:id])\n\n respond_to do |format|\n if @wish_list_item.update_attributes(params[:wish_list_item])\n format.html { redirect_to @wish_list_item, notice: 'Wish list item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wish_list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wish_list = WishList.find(params[:id])\n\n respond_to do |format|\n if @wish_list.update_attributes(params[:wish_list])\n format.html { redirect_to @wish_list, notice: 'Wish list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wish_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wish = Wish.new(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, :notice => 'Wish was successfully created.' }\n format.json { render :json => @wish, :status => :created, :location => @wish }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @wish.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wish_list_item.update(wish_list_item_params)\n format.html { redirect_to @wish_list_item, notice: 'Wish list item was successfully updated.' }\n format.json { render :show, status: :ok, location: @wish_list_item }\n else\n format.html { render :edit }\n format.json { render json: @wish_list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wishlist_item = WishlistItem.find(params[:id])\n\n respond_to do |format|\n if @wishlist_item.update_attributes(params[:wishlist_item])\n format.html { redirect_to @wishlist_item, :notice => 'Wishlist item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @wishlist_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @wish = Wish.new(params[:wish])\n\n respond_to do |format|\n if @wish.save\n format.html { redirect_to @wish, notice: 'Wish was successfully created.' }\n format.json { render json: @wish, status: :created, location: @wish }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @wish = Wish.find(params[:id])\n @wish.destroy\n\n respond_to do |format|\n format.html { redirect_to wishes_url }\n format.json { head :no_content }\n end\n end",
"def update\n @wishlist_item = WishlistItem.find(params[:id])\n\n respond_to do |format|\n if @wishlist_item.update_attributes(params[:wishlist_item])\n format.html { redirect_to @wishlist_item, notice: 'Wishlist item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wishlist_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @wishes = Wish.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wishes }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /aktions/1 GET /aktions/1.xml | def show
@aktion = Aktion.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @aktion }
end
end | [
"def index\n @aktions = @scope.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @aktions }\n end\n end",
"def index\n @kontakties = Kontakty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kontakties }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @aktion }\n end\n end",
"def index\n @aktions = Aktion.all\n end",
"def show\n @arc = Arc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arc.to_xml(:except => [ :created_at, :updated_at ], :include => :tahs) }\n end\n end",
"def index\n @instants = Instants.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @instants }\n end\n end",
"def show\n @announces_translation = AnnouncesTranslation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @announces_translation }\n end\n end",
"def show\n @instants = Instants.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instants }\n end\n end",
"def show\n @orc_ata_iten = OrcAtaIten.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @orc_ata_iten }\n end\n end",
"def show\n @kontak = Kontak.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kontak }\n end\n end",
"def show\n @kontaktart = Kontaktart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kontaktart }\n end\n end",
"def index\n @accions = do_index(Accion, params, true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accions }\n end\n end",
"def show\n @attestation = Attestation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @attestation }\n end\n end",
"def index\n @oauth_info = OauthInfo.find_by_id(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @oauth_infos }\n end\n end",
"def show\n @activist = Activist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @activist }\n end\n end",
"def show\n @aclasificacion = Aclasificacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @aclasificacion }\n end\n end",
"def show\n @analisis = Analisis.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @analisis }\n end\n end",
"def show\n @attraction = Attraction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attraction }\n end\n end",
"def index\n @aktions = Aktion.all\n\n respond_to do |format|\n format.html {render :layout => 'application'} # index.html.erb\n format.json { render json: @aktions }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /aktions/new GET /aktions/new.xml | def new
@aktion = Aktion.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @aktion }
end
end | [
"def new\n @annonce = Annonce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @annonce }\n end\n end",
"def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end",
"def new\n @instants = Instants.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instants }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @activation = Activation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activation }\n end\n end",
"def new\n @newz = Newz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newz }\n end\n end",
"def new\n @attraction = Attraction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attraction }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @revista = Revista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @revista }\n end\n end",
"def new\n @zakaz = Zakaz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @zakaz }\n end\n end",
"def new\n @creation = Creation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @creation }\n end\n end",
"def new\n @transmission = Transmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transmission }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announce }\n end\n end",
"def new\n @specificaton = Specificaton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @specificaton }\n end\n end",
"def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end",
"def new\n @aplicacion = Aplicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aplicacion }\n end\n end",
"def new\n @kontaktart = Kontaktart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kontaktart }\n end\n end",
"def new\n @announces_translation = AnnouncesTranslation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announces_translation }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /aktions POST /aktions.xml | def create
@aktion = Aktion.new(params[:aktion])
respond_to do |format|
if @aktion.save
flash[:notice] = 'Aktion was successfully created.'
format.html { redirect_to(@aktion) }
format.xml { render :xml => @aktion, :status => :created, :location => @aktion }
else
format.html { render :action => "new" }
format.xml { render :xml => @aktion.errors, :status => :unprocessable_entity }
end
end
end | [
"def create\n @kontakt = Kontakt.new(kontakt_params)\n\n respond_to do |format|\n if @kontakt.save\n format.html { redirect_to @kontakt, notice: 'Kontakt was successfully created.' }\n format.json { render :show, status: :created, location: @kontakt }\n else\n format.html { render :new }\n format.json { render json: @kontakt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @aktion = Aktion.new(aktion_params)\n\n respond_to do |format|\n if @aktion.save\n format.html { redirect_to @aktion, notice: 'Aktion was successfully created.' }\n format.json { render :show, status: :created, location: @aktion }\n else\n format.html { render :new }\n format.json { render json: @aktion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @aktions = Aktion.all\n end",
"def create\n @annonce = Annonce.new(params[:annonce])\n\n respond_to do |format|\n if @annonce.save\n flash[:notice] = \"Annonce enregistrée avec succès.\"\n format.html { redirect_to(@annonce) }\n format.xml { render :xml => @annonce, :status => :created, :location => @annonce }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @annonce.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @aktuator = Aktuator.new(aktuator_params)\n\n respond_to do |format|\n if @aktuator.save\n format.html { redirect_to @aktuator, notice: 'Aktuator was successfully created.' }\n format.json { render :show, status: :created, location: @aktuator }\n else\n format.html { render :new }\n format.json { render json: @aktuator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def create_request\n\t\tTyphoeus::Request.new(\n\t \"https://api.kontakt.io/device\",\n\t method: :get,\n\t #body: xml_body,\n\t headers: {\n\t \"Accept\" => \"application/vnd.com.kontakt+json;version=10\",\n\t \"Api-Key\" => \"#{ENV[\"KONTAKT_API_KEY\"]}\",\n\t \"Content-Type\" => \"application/x-www-form-urlencoded\",\n\t \"User-Agent\" => \"beaconoid/1.0\"\n\t }\n\t )\n\n\tend",
"def index\n @aktions = @scope.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @aktions }\n end\n end",
"def future_reservations\n method = \"futureReservations\"\n post_request(method)\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.new(benutzer_params(bNode))\n if @benutzer.save\n if bNode.xpath('objekt_zuordnungs').length > 0\n objekt_ids = bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i}\n @benutzer.setze_objekt_zuordnungen(objekt_ids)\n end\n success(@benutzer.id)\n else\n error(@benutzer.errors)\n end\n end",
"def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend",
"def create\n @kontaktart = Kontaktart.new(params[:kontaktart])\n\n respond_to do |format|\n if @kontaktart.save\n flash[:notice] = 'Kontaktart was successfully created.'\n format.html { redirect_to(@kontaktart) }\n format.xml { render :xml => @kontaktart, :status => :created, :location => @kontaktart }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @kontaktart.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @attestation = Attestation.new(params[:attestation].permit(allowed_params))\n\n respond_to do |format|\n if @attestation.save\n flash[:notice] = 'Attestation was successfully created.'\n format.html { redirect_to(@attestation) }\n format.xml do\n render xml: @attestation, status: :created, location: @attestation\n end\n else\n format.html { render action: 'new' }\n format.xml do\n render xml: @attestation.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def new\n @aktion = Aktion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aktion }\n end\n end",
"def create\r\n @attraction_translation = AttractionTranslation.new(attraction_translation_params)\r\n\r\n respond_to do |format|\r\n if @attraction_translation.save\r\n format.html { redirect_to @attraction_translation, notice: 'Tradução de atração criada com sucesso.' }\r\n format.json { render action: 'show', status: :created, location: @attraction_translation }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @attraction_translation.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @kontak = Kontak.new(params[:kontak])\n\n respond_to do |format|\n if @kontak.save\n flash[:peringatan] = 'Kontak was successfully created.'\n format.html { redirect_to :action => \"index\"}\n format.xml { render :xml => @kontak, :status => :created, :location => @kontak }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @kontak.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_accueil_et_inscription\n\t\tpost '/accueil', identifiant: '2', date_naiss: '1915-12-19'\n\t\tassert last_response.body.include? 'son inscription'\n\tend",
"def POST; end",
"def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /aktions/1 PUT /aktions/1.xml | def update
@aktion = Aktion.find(params[:id])
respond_to do |format|
if @aktion.update_attributes(params[:aktion])
flash[:notice] = 'Aktion was successfully updated.'
format.html { redirect_to(@aktion) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @aktion.errors, :status => :unprocessable_entity }
end
end
end | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def put_entry(id,summary)\n xml = <<DATA\n <entry xmlns=\"http://purl.org/atom/ns#\">\n <summary type=\"text/plain\"></summary>\n </entry>\nDATA\n\n doc = REXML::Document.new(xml)\n doc.elements['/entry/summary'].add_text(summary)\n\n # REXML -> String\n data=String.new\n doc.write(data)\n\n #make request\n path=\"/atom/edit/#{id}\"\n req=Net::HTTP::Put.new(path)\n req['Accept']= 'application/x.atom+xml,application/xml,text/xml,*/*',\n req['X-WSSE']= @credential_string\n\n #YHAAAA!!!\n res = @http.request(req,data)\n return res\n end",
"def update\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n\n update_params = {inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool}\n respond_to do |format|\n if @checklisten_vorlage.update(update_params)\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n else\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><error />'}\n end\n end\n end",
"def update\n @atom = Atom.find(params[:id])\n\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n flash[:notice] = 'Atom was successfully updated.'\n format.html { redirect_to(@atom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @atom.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*a) route 'PUT', *a end",
"def update\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n format.html { redirect_to @atom, notice: 'Atom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @atom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @aktuator.update(aktuator_params)\n format.html { redirect_to @aktuator, notice: 'Aktuator was successfully updated.' }\n format.json { render :show, status: :ok, location: @aktuator }\n else\n format.html { render :edit }\n format.json { render json: @aktuator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:location][:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.xml { head :ok }\n end\n end\n end",
"def update\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.find(params[:id])\n \n #Sicherstellen, dass Benutzer synchronisiert wird auch wenn nur Objekt-Zuordnungen anders sind!\n @benutzer.updated_at = DateTime.now \n\n if bNode.xpath('objekt_zuordnungs').length > 0\n @benutzer.setze_objekt_zuordnungen(bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i})\n end\n if @benutzer.update(benutzer_params(bNode))\n success(nil)\n else\n error(@benutzer.errors)\n end\n end",
"def update\n @arc = Arc.find(params[:id])\n\n respond_to do |format|\n if @arc.update_attributes(params[:arc])\n flash[:notice] = 'Arc was successfully updated.'\n format.html { redirect_to(@arc) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @arc.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @kraken = Kraken.find(params[:id])\n\n respond_to do |format|\n if @kraken.update_attributes(params[:kraken])\n format.html { redirect_to(@kraken, :notice => 'Kraken was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kraken.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @attestation = Attestation.find(params[:id])\n\n respond_to do |format|\n if @attestation.update(params.fetch(:attestation, {}))\n flash[:notice] = 'Attestation was successfully updated.'\n format.html { redirect_to(@attestation) }\n format.xml { head :ok }\n else\n format.html { render action: 'edit' }\n format.xml do\n render xml: @attestation.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def put *args\n make_request :put, *args\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n @aircraft = Aircraft.find(params[:id])\n\n respond_to do |format|\n if @aircraft.update_attributes(params[:aircraft])\n add_to_log(t('Aircraft updated log') + @aircraft.name,\"aircrafts\",\"update\")\n flash[:notice] = t('Aircraft updated')\n format.html { redirect_to(@aircraft) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aircraft.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @kontak = Kontak.find(params[:id])\n\n respond_to do |format|\n if @kontak.update_attributes(params[:kontak])\n flash[:notice] = 'Kontak was successfully updated.'\n format.html { redirect_to(@kontak) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kontak.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def update\n request = RestClient.put File.join(API_SERVER,\"rest-api/departments\"), { \n 'id' => params['id'], \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n\n redirect_to :action => :index\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /aktions/1 DELETE /aktions/1.xml | def destroy
@aktion = Aktion.find(params[:id])
@aktion.destroy
respond_to do |format|
format.html { redirect_to(aktions_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @zakaz1 = Zakaz1.find(params[:id])\n @zakaz1.destroy\n\n respond_to do |format|\n format.html { redirect_to(zakaz1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @transaction_xml = Transaction::Xml.find(params[:id])\n @transaction_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(transaction_xmls_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @kontak = Kontak.find(params[:id])\n @kontak.destroy\n\n respond_to do |format|\n format.html { redirect_to(kontaks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attestation = Attestation.find(params[:id])\n @attestation.destroy\n\n respond_to do |format|\n format.html { redirect_to(attestations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @acceso = Acceso.find(params[:id])\n @acceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(accesos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @autorizacion = Autorizacion.find(params[:id])\n @autorizacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(autorizacions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @access_entry = AccessEntry.find(params[:id])\n @access_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(access_entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aclasificacion = Aclasificacion.find(params[:id])\n @aclasificacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(aclasificaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @arc = Arc.find(params[:id])\n @arc.destroy\n\n respond_to do |format|\n format.html { redirect_to(arcs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @kontakty = Kontakty.find(params[:id])\n @kontakty.destroy\n\n respond_to do |format|\n format.html { redirect_to(kontakties_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @autorizacion = Autorizacion.find(params[:id])\n @autorizacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(autorizaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @atribuicao = Atribuicao.find(params[:id])\n @atribuicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(atribuicao_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @zakaz = Zakaz.find(params[:id])\n @zakaz.destroy\n\n respond_to do |format|\n format.html { redirect_to(zakazs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @specificaton = Specificaton.find(params[:id])\n @specificaton.destroy\n\n respond_to do |format|\n format.html { redirect_to(specificatons_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @verano_acceso = VeranoAcceso.find(params[:id])\n @verano_acceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(verano_accesos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @asignacion = Asignacion.find(params[:id])\r\n @asignacion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacions_url) }\r\n format.xml { head :ok }\r\n end\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets flag to make create/update account the default account | def add_default_account(post)
post[:defaultacct] = 'Y'
end | [
"def account_set_default(optname, optarg)\n Tw::Conf['default_user'] = optarg\n Tw::Conf.save()\n self.renderer.puts(\"set default user \\\"@#{Tw::Conf['default_user']}\\\"\")\n return 0\n end",
"def find_or_set_default_account\n # FIXME: API clients are scoped to their account so this code should\n # never need to run for them.\n return if default_account\n\n begin\n service = Fog::Compute.new(to_fog)\n accounts = service.accounts\n\n @account = accounts.select { |acc| %w[pending active].include?(acc.status) }.first.id\n save_default_account(@account) if @account\n rescue Brightbox::BBConfigError\n # We can't get a suitable fog connection so we can't select an\n # account\n rescue Excon::Errors::Unauthorized\n # This is a helper, if it fails let the other code warn and prompt\n end\n end",
"def set_default!\n ShippingAddress.update_all('current_default = 0', 'user_id = ' + self.user_id.to_s)\n ShippingAddress.update(self.id, :current_default => true)\n end",
"def default_account=(addresss)\n @core.web3.JS[:eth].JS[:defaultAccount] = addresss\n end",
"def default\n options[:ignore_no_org] = true\n if target = shift_argument\n options[:org] = target\n end\n\n if org == \"personal\" || options[:personal]\n action(\"Setting personal account as default\") do\n org_api.remove_default_org\n end\n elsif org && !options[:using_default_org]\n action(\"Setting #{org} as the default organization\") do\n org_api.set_default_org(org)\n end\n elsif org\n display(\"#{org} is the default organization.\")\n else\n display(\"Personal account is default.\")\n end\n end",
"def edit_account; self.account_edit=true; end",
"def default_account\n accounts.where(is_default: true).first || accounts.first\n end",
"def fix_default_acc_plan\n acc_plan_manager = @client.account_plans\n acc_plan_def = acc_plan_manager['Default']\n acc_plan_manager.create(name: 'Default').set_default unless acc_plan_def\n end",
"def set_default\n @project.set_default_twitter_account(@twitter_account)\n redirect_to project_twitter_accounts_path(@project),\n notice: \"#{ @twitter_account.at_screen_name } is now the project's default Twitter account.\"\n end",
"def set_default\n self.member.payout_methods.active_only.each do |pm|\n pm.update_attribute(:default, false) if pm.default?\n end\n self.update_attribute(:default, true)\n end",
"def create_default_user\n user = User.new\n user.last_name = 'Pool'\n user.first_name = 'Car'\n user.email = 'carpool@123.com'\n user.password = '12345678'\n user.carpool = 'true'\n user.save!\n user\nend",
"def change_default!\n Company.where(user_id: user_id).update_all(default: false)\n end",
"def set_as_user_default\n self.default = true if (self.user && self.user.groups.count == 0)\n end",
"def set_account\n unless self.role_before_type_cast == 0\n key = Eth::Key.new\n data = SecureRandom.alphanumeric(8)\n unique_id = self.id.to_s\n\n Client.personal_import_raw_key(key.private_hex,data) rescue nil \n self.account_password = Encrypt_me.call(self.id,self.created_at,data) rescue nil\n self.account_address = self.role_before_type_cast == 0 ? Client.personal_list_accounts[\"result\"][0] : key.address rescue nil #get_new_address(data) \n\n self.save rescue nil\n\n end\n end",
"def set_default_membership(default_membership)\n raise \"Membership must belong to account!\" unless default_membership.account_id==self.id\n self.memberships.each do | membership |\n membership.update_attributes({ :default => (membership.id == default_membership.id) })\n end\n end",
"def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end",
"def update_default\n user.update_attribute(:default_email_address_id, self.id) if default && self.id \n end",
"def default(name)\n configure(\"default username #{name}\")\n end",
"def default?\n is_default == true or user.accounts.count == 1\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds profile to post and sets update flag | def add_profile(post, profile)
post[:profile] = profile
post[:profileupdate] = 'Y'
end | [
"def add_profile(member)\n filter_profiles.create(profile: member, is_approved: true)\n end",
"def save\n overwrite @api.put('/profile.json',\n 'name' => name,\n 'timezone' => timezone,\n 'email' => email\n )\n end",
"def add_to_profile(profile_name:, profile_data:)\n Faraday.post \"#{@@profile_service_url}/profile/#{profile_name}\", profile_data\n rescue StandardError => e\n puts \"Error adding to profile : #{e.message}\"\n end",
"def set_profile(profile_contents)\n path = self.api_root + '/register/profile'\n process_firecloud_request(:post, path, profile_contents.to_json)\n end",
"def create_or_update_user_profile\n user_profile = UserProfile.update_info(structure, user)\n # Tag it as commented\n structure.add_tags_on(user_profile, UserProfile::DEFAULT_TAGS[:comments])\n nil\n end",
"def update_tag_profile\n # body = {\n # cmd: \"update_tag_profile\"\n # }\n\n end",
"def save(_user_profile_obj); end",
"def touch_profile\n\t\tuser.try(:profile).try(:touch)\n\tend",
"def update_profile?\n not is_profile_ok?\n end",
"def save_or_create_profile\n if profile.present?\n profile.actor_id = id\n profile.save!\n else\n create_profile\n end\n end",
"def profile_update(user)\n send_as :profile\n recipients user.facebook_user.facebook_session.user\n profile render(:partial => 'facebook_publisher/profile', \n :assigns => { :posts => Post.find_all_by_user_id(user.id, :order => 'created_at desc', :limit => 5),\n :blavel_user => user,\n :facebook_user => user.facebook_user.facebook_session.user })\n end",
"def update_profile(user)\n create_feed(user, {:title => 'Profile changed', :description => \"#{create_link(user)}'s changed his profile\"})\n end",
"def create_profile\n\t\t# update the last created profile to associate with user\n\t\tProfile.last.update(user_id: User.last.id, fname: User.last.name.split[0], lname: User.last.name.split[1])\n\tend",
"def process_update(profile)\n id = profile['profileId']\n doc = process_doc(id)\n doc['lastModified'] = Time.now.to_i,\n processed.update_one({'_id' => id}, doc)\n end",
"def associate_user_with_profile!(user, profile)\n profile.update!(user_id: user.id) if profile.user != user\n end",
"def save_and_create_profile\n self.profile = Profile.new\n self.save\n end",
"def add_profile(opts)\n opts = check_params(opts,[:profiles])\n super(opts)\n end",
"def update\n @profile = @user.profile \n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n flash[:notice] = t('profiles.new.success')\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n if user_signed_in?\n @post.profile_id = Profile.find_by(user_id: current_user.id).id\n end\n if @post.save\n redirect_to '/profile/' + @post.profile_id.to_s\n else\n render 'new'\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses profileid and acctid from profile, and adds it parameters, used for profile deletion | def add_profile_parameters(parameters, profile)
profileid, acctid = profile.split('/')
parameters[:profileid] = profileid
parameters[:acctid] = acctid
end | [
"def create_DB_profile\n \n @profile = ProfileId.new\n @profile.user_name = params[:user_name]\n @profile.profile_id = @parsed[\"profileId\"]\n @profile.save\n end",
"def add_profile(opts)\n opts = check_params(opts,[:profiles])\n super(opts)\n end",
"def add_profile(post, profile)\n post[:profile] = profile\n post[:profileupdate] = 'Y'\n end",
"def update_profile(options = {}) \n # query profile info\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(URI_PROFILES, :params => { 'filter[name]' => options[:name] })\n if response.status.success?\n responseObj = JSON.parse(response.body)\n queried_profile_list = responseObj[\"data\"]\n if queried_profile_list.length() > 0\n profile = queried_profile_list[0]\n end\n else\n Asca::Tools::Log.error(response.body)\n return\n end\n \n if !profile\n Asca::Tools::Log.error(\"No profile named #{options[:name]} found\")\n return\n end\n # create new profile\n profile_type = profile[\"attributes\"][\"profileType\"]\n \n # get bundle id\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(profile[\"relationships\"][\"bundleId\"][\"links\"][\"self\"])\n bundle_id = JSON.parse(response.body)[\"data\"][\"id\"]\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(profile[\"relationships\"][\"certificates\"][\"links\"][\"self\"])\n certificate_ids = JSON.parse(response.body)[\"data\"].map { |cer| cer[\"id\"] }\n \n # get all device ids\n device_ids = Asca::REST::Provisioning::Devices.list_devices.map { |device|\n device[\"id\"]\n }\n \n # delete old prifile\n delete_profile :name => options[:name]\n \n if profile_type.include? 'APP_STORE'\n create_new_profile :name => options[:name], :type => profile_type, :bundle_id => bundle_id, :certificate_ids => certificate_ids\n else\n create_new_profile :name => options[:name], :type => profile_type, :bundle_id => bundle_id, :device_ids => device_ids, :certificate_ids => certificate_ids\n end\n \n return true\n end",
"def handle_profile_id(id)\n case id\n when CustomerProfile\n set_fields(:customer_profile_id => id.customer_profile_id.to_s)\n when nil\n nil\n else\n set_fields(:customer_profile_id => id.to_s)\n end\n end",
"def run_import_profile(profile)\n ap \"importing #{profile}\"\n # check to see if the player profile exists, otherwise import it\n import_profile = Hash.new\n profile[:emails].each do |player_email|\n import_profile = Profile.where(\"lower(email) = LOWER('#{player_email}')\").first\n if !import_profile.nil?\n break\n end\n end\n if profile[:emails].blank?\n profile[:emails].push(\"#{profile[:first_name]}#{profile[:last_name]}@teamsnap.com\")\n end\n # this player doesn't exist create a new profile\n # Set the profile as the first email from the list\n if import_profile.blank?\n import_profile = Profile.new\n import_profile.email = profile[:emails].first\n end\n\n\n # try to find a profile with at least one of the email addresses\n import_profile.first_name = profile[:first_name]\n import_profile.last_name = profile[:last_name]\n if import_profile.first_name.blank?\n import_profile.first_name = 'importedPlayer*'\n end\n\n if import_profile.last_name.blank?\n import_profile.last_name = 'importedPlayer*'\n end\n import_profile.gender = profile[:gender]\n import_profile.shirt_size = profile[:shirt_size]\n import_profile.is_pickup_player = profile[:is_pickup_player]\n import_profile.emergency_contact_name = profile[:emergency_contact_name]\n import_profile.emergency_contact_relationship = profile[:emergency_contact_relationship]\n import_profile.emergency_contact_phone = profile[:emergency_contact_phone]\n import_profile.dob = profile[:dob]\n import_profile.address = profile[:address]\n import_profile.address2 = profile[:address2]\n import_profile.city = profile[:city]\n import_profile.state = profile[:state]\n import_profile.zip = profile[:zip]\n random_string = (0...8).map { (65 + rand(26)).chr }.join\n import_profile.password = random_string\n\n if !import_profile.valid?\n error = Hash.new\n error[:type] = \"profile #{import_profile.first_name} #{import_profile.last_name} #{import_profile.email}\"\n error[:errors] = import_profile.errors\n @errors.push(error)\n ap \"---------Couldn't save profile #{import_profile.first_name} #{import_profile.last_name} #{import_profile.email} ----------\"\n ap import_profile.errors\n end\n import_profile.save\n import_profile\n end",
"def update_profile_by_profile_id(profile_id, user_profile_data)\n # PUT /d2l/api/lp/(version)/profile/(profileId)\n # NOTE: Example of User.UserProfile JSON Data Block\n # { \"Nickname\": <string>,\n # \"Birthday\": {\n # \"Month\": <number>,\n # \"Day\": <number>\n # },\n # \"HomeTown\": <string>,\n # \"Email\": <string>,\n # \"HomePage\": <string>,\n # \"HomePhone\": <string>,\n # \"BusinessPhone\": <string>,\n # \"MobilePhone\": <string>,\n # \"FaxNumber\": <string>,\n # \"Address1\": <string>,\n # \"Address2\": <string>,\n # \"City\": <string>,\n # \"Province\": <string>,\n # \"PostalCode\": <string>,\n # \"Country\": <string>,\n # \"Company\": <string>,\n # \"JobTitle\": <string>,\n # \"HighSchool\": <string>,\n # \"University\": <string>,\n # \"Hobbies\": <string>,\n # \"FavMusic\": <string>,\n # \"FavTVShows\": <string>,\n # \"FavMovies\": <string>,\n # \"FavBooks\": <string>,\n # \"FavQuotations\": <string>,\n # \"FavWebSites\": <string>,\n # \"FutureGoals\": <string>,\n # \"FavMemory\": <string>,\n # \"SocialMediaUrls\": [ // Array of SocialMediaUrl blocks\n # {\n # \"Name\": <string>,\n # \"Url\": <string:URL>\n # },\n # { <composite:SocialMediaUrl> }, ...\n # ]\n # }\n # NOTE: The back-end service also expects a file names \"profileImage\"\n # RETURNS: a UserProfile JSON data block for the updated personal profile.\nend",
"def update_profile(profile)\n @type = Type::CIM_UPDATE_PROFILE\n @fields.merge!(profile.to_hash)\n make_request\n end",
"def update\n\n puts \"\\ncandidates_profiles#update\".green\n\n params.each do |p|\n puts \"#{p}\".cyan\n end\n\n @candidates_profile = CandidatesProfile.find(params[:candidates_profile_id])\n\n #@candidates_profile = CandidatesProfile.find(params[:id])\n\n @candidates_profile.name = params[:name]\n @candidates_profile.summary = params[:summary]\n @candidates_profile.profiledata = params[:profiledata]\n\n if @candidates_profile.save\n @candidate = Candidate.find(@candidates_profile.candidate_id)\n @candidates_profile = @candidate.candidates_profiles.paginate(:page => params[:page], :per_page => 20)\n redirect_to File.join('/candidates/',@candidate.id.to_s,'/candidates_profiles')\n else\n render text = \"Error while saving profile \" + @candidates_profile.errors.to_xml\n end\n end",
"def set_ProfileID(value)\n set_input(\"ProfileID\", value)\n end",
"def add_to_profile(profile_name:, profile_data:)\n Faraday.post \"#{@@profile_service_url}/profile/#{profile_name}\", profile_data\n rescue StandardError => e\n puts \"Error adding to profile : #{e.message}\"\n end",
"def set_ProfileID(value)\n set_input(\"ProfileID\", value)\n end",
"def profile( key, profile )\n profile = profile.dup\n base = profile.delete( :base_profile ) || :default\n base_profile = @profiles[ base ]\n if base_profile\n profile = base_profile.merge( profile )\n if base_profile[ :roles ] && profile[ :roles ]\n profile[ :roles ] = ( base_profile[ :roles ] | profile[ :roles ] )\n end\n end\n\n @profiles[ key ] = profile\n end",
"def update_profile\n @profile = @account.employee\n \n if params[:profile].present?\n @profile.assign_attributes(profile_params)\n @profile.save\n redirect_to gns_core.my_profile_backend_accounts_path, flash: {success: 'Profile has been updated successfully.'}\n else\n redirect_to gns_core.my_profile_backend_accounts_path, flash: {error: 'Profile update failed. Please try again!'}\n end\n end",
"def profile_params\n params.require(:profile).permit(:institution_name, :description, :lending_policy, :user_id, :picture, location_attributes: [:id, :street, :state, :postcode, :location, :profile_id], loaner_attributes: [:id, :name, :phone], borrower_attributes: [:id, :name, :phone])\n end",
"def associate_user_with_profile!(user, profile)\n profile.update!(user_id: user.id) if profile.user != user\n end",
"def profile\n\t\t@user = Account.find_by_id(params[:id])\n\n # add more conditions based which type of account it is\n\t\tif @user.account_type == Account.roles[:user]\n\t\t\t@user_details = User.find_by_account_id(params[:id])\n\t\t\tredirect_to :controller => :users, :action => :history, :id => params[:id]\n\t\telsif @user.account_type == Account.roles[:npo]\n\t\t\t@user_details = Npo.find_by_account_id(params[:id])\n\t\t\tredirect_to :controller => :npos, :action => :profile, :id => params[:id]\n\t\tend\n\n\t\tif !@user\n\t\t\tflash[:error] = \"There is an error with your profile, please contact the administrator at admins@weeve.it\"\n\t\t\tredirect_to root_url\n\t\tend\n\tend",
"def get_user_profile_by_profile_id(profile_id)\n path = \"/d2l/api/lp/#{$lp_ver}/profile/#{profile_id}\"\n _get(path)\n # Returns UserProfile JSON data block\nend",
"def handle_payment_profile_id(id)\n case id\n when PaymentProfile\n set_fields(:customer_payment_profile_id => id.customer_payment_profile_id.to_s)\n when nil\n nil\n else\n set_fields(:customer_payment_profile_id => id.to_s)\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /list_invites/1 DELETE /list_invites/1.json | def destroy
@list_invite.destroy
respond_to do |format|
format.html { redirect_to list_invites_url }
format.json { head :no_content }
end
end | [
"def destroy\n @invite_list = InviteList.find(params[:id])\n @invite_list.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n invite = current_user.sent_invites.find(params[:id])\n raise PermissionViolation unless invite.destroyable_by?(current_user)\n \n invite.delete\n \n respond_to do |format|\n format.json { render :json => [{'status' => 'ok'}]}\n end\n end",
"def destroy\n @invite_status = InviteStatus.find(params[:id])\n @invite_status.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_statuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to(invites_url) }\n format.xml { head :ok }\n end\n end",
"def remove_invite\n @invited = Dinner.find(params[:id]).invites.find_by(invited_id: params[:user_id])\n @invited.delete\n render json: { message: 'user uninvited' }\n end",
"def destroy\n\t\tredirect_to guild_invites_url, :alert => \"Already used\" and return unless @guild.invites.find(params[:id]).state == \"waiting\"\n\t\t@guild.invites.destroy(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to guild_invites_url, notice: 'Invite was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @user_invite = UserInvite.find(params[:id])\n @user_invite.destroy\n\n respond_to do |format|\n format.html { redirect_to user_invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n invitation = invitable.find(params[:id])\n invitation.destroy if invitation\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @invited.destroy\n respond_to do |format|\n format.html { redirect_to inviteds_url, notice: 'Invited was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inviterequest = Inviterequest.find(params[:id])\n @inviterequest.destroy\n\n respond_to do |format|\n format.html { redirect_to inviterequests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitacion = Invitacion.find(params[:id])\n @invitacion.destroy\n\n respond_to do |format|\n format.html { redirect_to invitaciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_request = InviteRequest.find(params[:id])\n @invite_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(invite_requests_url) }\n format.xml { head :ok }\n end\n end",
"def delete_invites\r\n Invite.delete_all [\"user_id=?\", self.id] # I'm invited to\r\n Invite.delete_all [\"inviter_id=? and user_id is not null\", self.id] # My invitations, unless they're site invites\r\n end",
"def delete_invite(token, code)\n request(\n __method__,\n :delete,\n \"#{api_base}/invites/#{code}\",\n Authorization: token\n )\n end",
"def destroy\n @invitation_list.destroy\n respond_to do |format|\n format.html { redirect_to invitation_lists_url, notice: 'Invitation list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n @maintain_invite_user.destroy\n\n respond_to do |format|\n format.html { redirect_to maintain_invite_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invocy.destroy\n respond_to do |format|\n format.html { redirect_to invocies_url, notice: 'Invocy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the permissions associated with the role | def permissions
Roles.type_map[role_type].permissions
end | [
"def role_permissions\n return @role_permissions\n end",
"def permissions\n Roles.type_map[role_type.first].permissions\n end",
"def permissions\n if @permissions.nil?\n perm_array = []\n roles.each { |r| perm_array << r.permission_ids }\n @permissions = perm_array.flatten.uniq\n else\n @permissions\n end\n end",
"def get_permissions\n if @role.type_role==\"system\"\n\t\t\t@permissions = Permission.find(:all, :order => 'name ASC')\n\t else\n @permissions = Permission.type_of(@role.type_role)\n end\n end",
"def permissions\n cache_id = \"#{@user.class}/#{@user.id}/#{yield(role_assignments).count}/permissions\"\n Rails.cache.fetch(cache_id, expires_in: 12.hours) do\n yield(role_assignments).map do |ra|\n ra.role.operations.map do |operation|\n {\n target_id: ra.target_id,\n target_type: ra.target_type,\n operation: operation.slug.to_sym\n }\n end\n end.flatten\n end\n end",
"def permissions(role_id, action)\n Permission.where(:role_id => role_id,\n :resource_type => @resource_type_name, :action => action).order(\n 'resource_type,role_id,sequence').all\n end",
"def permissions\n @json['projectRole']['permissions']\n end",
"def all_permissions\n return permissions unless role\n (permissions + role.permissions).uniq\n end",
"def all_permissions\n permissions = Array.new\n \n all_roles.each do |role|\n permissions.concat(role.permissions)\n end\n \n return permissions\n end",
"def role_permissions_for(context)\n auth_scope do\n return permission_class.joins(permission_role_plural_key).where(permission_role_plural_key => {role_foreign_key.to_sym => id, :context_type => context.class_name, :context_id => context.id})\n end\n end",
"def permissions\n return @permissions\n end",
"def existing_permissions(role)\n role.permissions.where.not(action: CardPermissions::STATELESS_ACTIONS).where.not(filter_by_card_id: nil)\n end",
"def all_permissions\n (self.permissions + group_permissions + role_permissions).flatten\n end",
"def permissions_from_policy\n @policy_document[:roles].map do |_role, permissions|\n permissions\n end.flatten.uniq\n end",
"def aggregate_permissions\n roles.load.inject(HashWithIndifferentAccess.new) do |aggregate, role|\n aggregate.deep_merge(role.permissions) do |_key, effect, another_effect|\n effect == true || another_effect == true\n end\n end\n end",
"def load_permissions \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]} \n end",
"def system_permissions\n\t\t\t\t\treturn self.system_role.permissions\n\t\t\t\tend",
"def get_permissions(roles, account_href)\n permissions = []\n roles.each do |role|\n if @policy.has_key?(role)\n permissions = permissions + (@policy[role][account_href] || @policy[role]['default'] || [])\n end\n end\n permissions.uniq\n end",
"def permissions\n Array.wrap(self[:permissions]).collect(&:to_sym)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the nearest timeframe | def set_time_frame time, time_slot = 30.minutes
Time.at(((time.to_i / time_slot).round * time_slot) + time_slot).to_i
end | [
"def timeframe=(val)\n raise(ArgumentError, 'timeframe value must be in the days_ago_list') unless days_ago_list.include? val\n\n @timeframe = val\n refresh_data\n\n end",
"def set_default_times\n if !self.start\n return\n end\n\n if self.start.hour == 0 # hour set to 0 if not otherwise defined...\n self.start = self.start + 9.hours\n end\n\n if !self.end\n if self.online?\n self.end = self.start + 1.hour\n else\n diff = 17 - self.start.hour\n self.end = self.start + diff.hours\n end\n end\n # TODO: Set timezone for online events. Where to get it from, though?\n # TODO: Check events form to add timezone autocomplete.\n # Get timezones from: https://timezonedb.com/download\n\n end",
"def set_current_time_as_adjusted\n self.adjusted_at = Time.current\n end",
"def set_default_times\n return if use_start_and_end_times\n self.start = start.beginning_of_day\n self.end = self.end.end_of_day\n self.timeline_start = timeline_start.beginning_of_day\n self.timeline_end = timeline_end.end_of_day\n end",
"def DateTime_SetRange(hdp, gd, rgst) send_date_time_pick_message(hdp, :SETRANGE, wparam: gd, lparam: rgst) end",
"def set_time_frame time, time_slot = 30.minutes\n time_frame = []\n time_frame[0] = (time.to_i / time_slot).round * time_slot\n time_frame[1] = time_frame[0] + time_slot\n time_frame\n end",
"def target_framerate=( framerate )\n\t\t\t\tif framerate\n\t\t\t\t\t@target_frametime = 1000.0 / framerate\n\t\t\t\telse\n\t\t\t\t\t@target_frametime = nil\n\t\t\t\tend\n\t\t\trescue ZeroDivisionError\n\t\t\t\t@target_frametime = nil\n\t\t\tend",
"def set_flight_time\n self.flight_time = (arrival_time-departure_time) / 1.hour\n end",
"def set_Timeframe(value)\n set_input(\"Timeframe\", value)\n end",
"def closest_int_start(inttime,utc_start,longitude,now=DateTime.now)\n target_utc = DateTime.new(now.year,now.month,now.day,utc_start)\n puts \"Target UTC: \" + target_utc.to_time.to_s\n target_lst = target_utc.last(longitude=longitude)\n puts \"Target LST: \" + target_lst.to_hmsstr \n puts \"Target LST: \" + target_lst.to_f.to_s\n # get the array of allowed integration start times, and see which\n # best matches our target. For now let's force the start time to be\n # before the observation time. The minimum difference between the\n # our target times and the allowed times is the amount we need to shift\n # our start time.\n st = get_st_vectors(inttime)\n offset = (st.sbt!(target_lst.to_f)).mul!(3600)\n nearest_offset = offset[offset<=0].max * (23.9344/24.0)#max because values are negative\n puts \"Closest allowed start time residual: \" + (nearest_offset/3600.0).to_s\n # offset the target utc start time by the right number of seconds\n puts \"Requested time \" + target_utc.to_time.to_s\n puts \"granted time \" + (target_utc.to_time+nearest_offset).to_s\n puts \"granted time \" + (target_utc.to_time+nearest_offset).to_f.to_s\n start_time = (target_utc.to_time + nearest_offset).to_f\nend",
"def set_timezone(timezone); end",
"def shift_start_at(personal_time, reference_time, personal_point, reference_point, learning_rate_ema)\n if personal_time.start_at > Time.zone.now\n personal_time.start_at =\n round_to_date(\n personal_point + ((reference_time.start_at - reference_point) * learning_rate_ema),\n @course_tz\n )\n end\n # Hard limits to make sure we don't fail bounds checks\n personal_time.start_at = [personal_time.start_at, reference_time.start_at, reference_time.end_at].compact.min\n end",
"def setupTimeRange()\n @timeOrigin = Time.parse(@demandConf[:timeOrigin]) ;\n @timeUntil = Time.parse(@demandConf[:timeUntil]) ;\n end",
"def set_timespan(doc, object)\n\n # For this import, assume everything is current, even if it isn't marked that way\n\n object.create_timespan if object.timespan.nil?\n object.timespan.update_attribute(:is_current, true)\n\n #puts 'updating timespan:::::' + object.class.to_s\n #if object.respond_to? :feature\n # puts \"Feature PID == #{object.feature.pid}\"\n #end\n #puts \"ERRORS == #{object.errors.inspect}\"\n #result = object.timespan.nil? ? object.create_timespan(:is_current => true) : object.timespan.update_attribute(:is_current, true)\n #puts result.inspect\n\n #if(doc.attributes['isCurrent'])\n # if(doc.attributes['isCurrent']=='yes')\n # object.timespan = Timespan.new(:is_current => true)\n # elsif(doc.attributes['isCurrent']=='no')\n # object.timespan = Timespan.new(:is_current => false)\n # end\n #end\n end",
"def set_next_run_at\n now = Time.zone.now\n ideal_next_run = ideal_next_run_from(now)\n\n self.next_run_at = if ideal_next_run == cron_worker_next_run_from(now)\n ideal_next_run\n else\n cron_worker_next_run_from(ideal_next_run)\n end\n end",
"def set_end_time\n self.end_time = self.start_time + (10800) #3*60*60\n end",
"def set_end_time\n self.end_time = self.start_time + 3.hours if self.end_time.blank?\n end",
"def __evolve_time__\n ::Time.configured.local(year, month, day)\n end",
"def set_starting_at\n self.starting_at = Date.current unless self.starting_at.presence\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the recipe classes in order based on the Gemfile order | def ordered_recipes
return @ordered_recipes if @ordered_recipes
names = Bundler.load.dependencies.map(&:name)
# Setup a hash with the recipe name and the recipe class
recipe_pool = recipes.dup.inject({}) {|memo,recipe| memo[recipe.gem_name] = recipe ; memo }
# Go through the gems in the order they are in the Gemfile, then
# add them to the ordered list
@ordered_recipes = []
names.each do |name|
if recipe_pool[name]
@ordered_recipes << recipe_pool[name]
recipe_pool.delete(name)
end
end
# Add the remaining recipes (load them after everything else)
@ordered_recipes += recipe_pool.values
return @ordered_recipes
end | [
"def full_class_list\r\n v = first_last_versions\r\n packages.collect { |pkg|\r\n pkg.classes.collect { |c| c.to_full_qualified_s(v[0], v[1]) }\r\n }.flatten.sort{|a,b| a.casecmp b }\r\n end",
"def cookbook_order\n @cookbook_order ||= begin\n ordered_cookbooks = []\n seen_cookbooks = {}\n run_list_expansion.recipes.each do |recipe|\n cookbook = Chef::Recipe.parse_recipe_name(recipe).first\n add_cookbook_with_deps(ordered_cookbooks, seen_cookbooks, cookbook)\n end\n logger.debug(\"Cookbooks to compile: #{ordered_cookbooks.inspect}\")\n ordered_cookbooks\n end\n end",
"def depends_on\n if self.depends\n self.depends.split(', ').sort.inject([]) do |res, name|\n if p = self.search_class_name.where(name: name.split(/ /)[0]).first\n res << p\n else\n logger.info(\"No package #{name.split(/ /)[0]} for #{self.depends} in #{self.inspect}\")\n end\n res\n end\n else\n []\n end\n end",
"def custom_cookbook_order\n @custom_cookbook_order ||= begin\n ordered_cookbooks = []\n seen_cookbooks = {}\n run_list_expansion.recipes.each do |recipe|\n cookbook = Chef::Recipe.parse_recipe_name(recipe).first\n custom_add_cookbook_with_deps(ordered_cookbooks, seen_cookbooks, cookbook)\n end\n Chef::Log.debug(\"Cookbooks to compile: #{ordered_cookbooks.inspect}\")\n ordered_cookbooks\n end\n end",
"def gather_gems\n @specs = Gem.loaded_specs\n .values\n .select {|spec| spec.name[@mask]}\n .sort {|first, second| first.name <=> second.name}\n end",
"def find_classes\n puppetClasses = []\n Dir.glob( SpkDashboard::MANIFEST_ROOT + \"/modules/**/*.pp\" ).each do |manifest|\n File.read( manifest ).each do |line|\n foundClass = line.match(/^class (\\S+).*\\{/)\n if foundClass and puppetClasses.include?( foundClass[1] ) == false\n puppetClasses << foundClass[1]\n end\n end\n end\n \n return puppetClasses\n end",
"def list_classes\r\n list = []\r\n JavaClass::Gems::ZipFile.new(@jarfile).entries do |entry|\r\n name = entry.name\r\n next unless entry.file? and name =~ JavaLanguage::CLASS_REGEX # class file\r\n list << name\r\n end\r\n list\r\n end",
"def fully_qualified_recipe_names\n files_for(\"recipes\").inject([]) do |memo, recipe|\n rname = recipe[:name].split(\"/\")[1]\n rname = File.basename(rname, \".rb\")\n memo << \"#{name}::#{rname}\"\n memo\n end\n end",
"def runtime_specific_gems\n []\n end",
"def get_dependents(pkgs)\n dependents = []\n to_check = pkgs.map { |pkg| pkg[:metadata][:filename] }\n dependency = get_dependency_mapping\n while pkgfile = to_check.pop\n pkgs = dependency[pkgfile.to_s]\n next if pkgs.nil?\n dependents |= pkgs\n to_check |= pkgs.map { |pkg| pkg[:metadata][:filename] }\n end\n return dependents\n end",
"def sorted_classes\n @sorted_classes ||= class_names.sort.map { |name| @classes[name] }\n end",
"def init_gemspecs\n Gem::Specification.sort { |a, b|\n names = a.name <=> b.name\n next names if names.nonzero?\n b.version <=> a.version\n }\n end",
"def classes()\n\t\t\t\tlist = []\n\t\t\t\tdir = Dir.new( path() )\n\t\t\t\t\n\t\t\t\tdir.each do |file|\n\t\t\t\t\tnext if File.directory?( path() + \"/\" + file )\n\t\t\t\t\tnext if ( file[/^([A-Z][A-Za-z]*)+\\.class\\.rb$/] == nil )\n\t\t\t\t\tlist << clazz( $1 )\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn list\n\t\t\tend",
"def class_files\n []\n end",
"def depend_upon(match_name) #, constraint)\n list = []\n each do |name, libs|\n case libs\n when Library\n list << libs if libs.requirements.any?{ |r| match_name == r['name'] } \n else\n libs.each do |lib|\n list << lib if lib.requirements.any?{ |r| match_name == r['name'] } \n end\n end\n end\n list\n end",
"def list_known_classes names = []\n classes = []\n stores.each do |store|\n classes << store.modules\n end\n classes = classes.flatten.uniq.sort\n unless names.empty? then\n filter = Regexp.union names.map { |name| /^#{name}/ }\n classes = classes.grep filter\n end\n puts classes.join(\"\\n\")\n end",
"def gem_array\n Gem.loaded_specs.values\n end",
"def recipes\n @_recipes ||= (\n %w[dorc **/*.rake].map { |f| Dir[File.join(DO_PATH, f)] }.flatten +\n %w[./Do ./Dofile].map { |f| File.expand_path(f) } <<\n File.expand_path('../common.rb', __FILE__)\n ).reject { |f| !File.exist?(f) }\n end",
"def expected_for_recipes(cookbooks)\n latest = get_latest_cookbooks(cookbooks)\n nested = latest.map do |cookbook_spec|\n cookbook_name, version_specs = cookbook_spec\n latest_version = version_specs.first\n _version_string, recipe_names =latest_version\n\n # don't sort the recipes for the Ruby endpoint; CouchDB keeps them in insertion order\n recipe_names.sort!\n\n recipe_names.map do |recipe_name|\n \"#{cookbook_name}::#{recipe_name}\"\n end\n end\n nested.flatten\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the list of classes that match the current list of roles in the correct run order | def recipe_classes_with_roles(roles)
# Check to make sure some recipes have been added
if ordered_recipes.size == 0
raise Thor::InvocationError, 'no recipes have been defined'
end
if (roles.is_a?(Array) && roles.size == 0) || roles == :all
# Use all classes
role_classes = ordered_recipes
else
# Remove classes that don't fit the roles being used
role_classes = ordered_recipes.reject do |recipe_class|
![roles].flatten.map(&:to_s).include?(recipe_class.class_role)
end
end
end | [
"def classes\n if role\n return [role] unless @classes\n @classes << role unless @classes.include?(role)\n end\n\n @classes\n end",
"def roles_enabled\n migrate_roles\n\n hiera = hiera_load\n return [] unless hiera.key?('classes')\n\n roles = hiera['classes'].map do |r|\n r.match(/^role::(\\S+)/) { |m| m[1] }\n end\n roles.compact.sort.uniq\n end",
"def get_classes_from_role(role, options)\n certname = options[:certname_for_facts]\n global_config = get_global_config\n global_config = find_facts(certname).merge(global_config)\n get_classes_per_scenario(global_config, role)\n end",
"def get_roles_by_order\n run_order = []\n roles.each do |role|\n role.role_element_orders.each do |roe|\n run_order[roe.order] = [] unless run_order[roe.order]\n run_order[roe.order] << role\n end\n end\n run_order\n end",
"def get_role_classes_from_scenario(name)\n role_classes = {}\n # iterate through each roles in a scenario\n get_scenario_data(name)['roles'].each do |role_name, values|\n role_classes[role_name] = (values['classes'] || []) + get_classes_from_groups(values['class_groups'])\n end\n role_classes\n end",
"def find_roles *roles\n role_model.where(:name => roles.flatten)\n end",
"def instances_by_role(*roles)\n roles = roles.flatten.map(&:to_s)\n instances.select { |inst| roles.include?(inst.role.to_s) }\n end",
"def fetch_current_role_names(current_roles)\n current_role_names = []\n ROLES.keys.each do |role_type|\n current_roles.fetch(role_type, []).each do |current_role|\n role_name = get_role_name(role_type, current_role)\n\n break if role_name.nil?\n\n current_role_names << role_name\n end\n end\n current_role_names\n end",
"def run_list\n self.roles.collect { |role| \"role[#{role}]\" } +\n self.recipes.collect { |recipe| \"recipe[#{recipe}]\" }\n end",
"def roles\n return proposed_snapshot.roles if proposed? \n return active_snapshot.roles if active?\n []\n end",
"def roles\n user_types.collect do |roleuser|\n roleuser.role.to_sym\n end\n end",
"def list_known_classes names = []\n classes = []\n stores.each do |store|\n classes << store.modules\n end\n classes = classes.flatten.uniq.sort\n unless names.empty? then\n filter = Regexp.union names.map { |name| /^#{name}/ }\n classes = classes.grep filter\n end\n puts classes.join(\"\\n\")\n end",
"def role_names() #:doc:\n roles && roles.map { |r| r.name.downcase }\n end",
"def r_classes\n not_tested = @elements.dup\n classes = []\n \n until not_tested.empty?\n classes << r_class(not_tested.first)\n not_tested = not_tested.reject { |el| classes.last.include? el }\n end\n \n classes.sort(&subset_sorter)\n end",
"def get_role_classes_from_scenario(name, scope)\n role_classes = {}\n # iterate through each roles in a scenario\n get_scenario_data(name)['roles'].each do |role_name, values|\n role_classes[role_name] = process_classes(values, scope)\n end\n role_classes\n end",
"def roles\n role_registry.roles.keys\n end",
"def get_role_classes_from_scenario(name, scope)\n role_classes = {}\n scope = scope.merge({'scenario' => name})\n # iterate through each roles in a scenario\n scenario_data = get_scenario_data(name, scope)\n (scenario_data['roles'] || []).each do |role_name, values|\n role_classes[role_name] = process_classes(values, scope).uniq\n end\n role_classes\n end",
"def roles\n [get_appdirect_attr('value.ext4')].tap do |roles| # Roles array starts with one value: value.ext4 (possibly nil)\n get_appdirect_attr('count.ext4').to_i.times do |i| # Then we use the roles count to cycle through each role variable \n roles << get_appdirect_attr(\"value.ext4.#{i+1}\") # And shift it into the array\n end\n end.reject {|v| !v } # remove nils \n end",
"def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Invokes all recipes that implement the passed in role | def invoke_roles(task_name, roles, options={})
role_classes = self.recipe_classes_with_roles(roles)
# Run the taks on each role class
role_classes.each do |recipe_class|
# This class matches the role, so we should run it
recipe = recipe_class.new([], options)
task = recipe_class.tasks[task_name.to_s]
recipe.invoke_task(task)
# Copy back and updated options
options = recipe.options
end
end | [
"def recipe_from_role(name)\n role = Chef::Search::Query.new.search(:role, \"name:#{name}\")[0][0]\n if role.nil?\n fail \"Search for #{name} failed. Has the role been created?\"\n end\n\n run_list = role.env_run_list[chef_environment]\n run_list.select { |rli| rli.type == :recipe }.map(&:name)\n end",
"def execute_recipes!\n config = SwitchTower::Configuration.new\n config.logger.level = options[:verbose]\n config.set :password, options[:password]\n config.set :pretend, options[:pretend]\n\n options[:pre_vars].each { |name, value| config.set(name, value) }\n\n # load the standard recipe definition\n config.load \"standard\"\n\n options[:recipes].each { |recipe| config.load(recipe) }\n options[:vars].each { |name, value| config.set(name, value) }\n\n actor = config.actor\n options[:actions].each { |action| actor.send action }\n end",
"def tell(role_name, method_name, ...)\n if context == self || context.contains?(self)\n context.dispatch(role(role_name), method_name, ...)\n end\n end",
"def run_role(role, client_opts: CHEF_CLIENT_OPTS)\n chef_client(\"-o 'role[#{role}]'\", client_opts: client_opts)\n end",
"def role r\n if block_given? && current_roles.include?(r.to_s)\n puts \"ROLE: #{r}\"\n yield\n end\n end",
"def evaluate\n __evaluate(object, relevant_roles)\n end",
"def includes_recipe?(recipe)\n # todo expand roles?\n self.run_list.include?(\"#{recipe}\")\n end",
"def ingredient_by_role(role)\n element.ingredient_by_role(role)\n end",
"def method_missing(*args, &block)\n @recipe.chain.__send__(*args, &block)\n end",
"def execute_recipes!\n config = Backup::Configuration.new\n #config.logger.level = options[:verbose]\n #options[:pre_vars].each { |name, value| config.set(name, value) }\n options[:vars].each { |name, value| config.set(name, value) }\n\n # load the standard recipe definition\n config.load \"standard\"\n options[:recipes].each do |recipe| \n global = options[:global] || File.dirname(recipe) + \"/global.rb\"\n config.load global if File.exists? global # cache this?\n end\n\n options[:recipes].each_with_index do |recipe,i|\n config.load(recipe) \n $state = setup_saved_state(recipe, config) \n warn \"DEPRICATED: Using multiple recipes with one command is deprecated for the time being. Just run a different command if you want to do two recipes at the same time\" if i > 0\n\n end\n\n #options[:vars].each { |name, value| config.set(name, value) }\n\n actor = config.actor\n actor.start_process! # eventually make more options, like the ability\n # to run each action individually\n #options[:actions].each { |action| actor.send action }\n end",
"def run_list\n self.roles.collect { |role| \"role[#{role}]\" } +\n self.recipes.collect { |recipe| \"recipe[#{recipe}]\" }\n end",
"def recipes\n @packer.recipes + @packer.roles.map { |r| recipe_from_role(r) }.flatten\n end",
"def ingredient_by_role(role)\n ingredients.detect { |ingredient| ingredient.role == role.to_s }\n end",
"def roles(&block)\n if block_given?\n instance_eval(&block)\n else\n @roles\n end\n end",
"def current_user_has_role(role_ids_or_syms, &block)\r\n yield block if current_user_has_role?(role_ids_or_syms)\r\n end",
"def find_all_for_role(role)\n roles = role.get_parents\n roles << role\n return find_for_role(roles.collect(&:id))\n end",
"def method_missing(method_id, *args)\n\t\tif match = matches_dynamic_role_check?(method_id)\n\t\t\ttokenize_roles(match.captures.first).each do |check|\n\t\t\t\troles.each do |role|\n\t\t\t\t\treturn true if role.name.downcase == check\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn false\n\t\telse\n\t\t\tsuper\n\t\tend\n\tend",
"def recipe_with_search(type)\n search = {:invalid_syntax => 'run_list:recipe[foo::bar]', :valid_syntax => 'run_list:recipe\\[foo\\:\\:bar\\]',\n :with_subexpression => %q{roles:#{node['foo']['role']}}}[type]\n write_recipe %Q{\n search(:node, \"#{search}\") do |matching_node|\n puts matching_node.to_s\n end\n }\n end",
"def accept_role role\n self.roles.push role\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /air_moistures GET /air_moistures.json | def index
@air_moistures = AirMoisture.all
end | [
"def index\n @armors = Armor.all\n\n render json: @armors\n end",
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def index\n @airlines = Airline.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @airlines }\n end\n end",
"def show\n @air = Air.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @air }\n end\n end",
"def index\n @soil_moistures = SoilMoisture.all\n end",
"def index\n @armoires = Armoire.all\n end",
"def index\n @gas_mileages = GasMileage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gas_mileages }\n end\n end",
"def index\n @murais = Mural.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @murais }\n end\n end",
"def index\n @captures = Capture.all\n\n render json: @captures\n end",
"def index\n @animations = Animation.all\n\n render json: @animations\n end",
"def index\n @rainfalls = Rainfall.all\n respond_to do |format|\n format.html { render json: @rainfalls} \n end\n end",
"def index\n @airplanes = Airplane.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @airplanes }\n end\n end",
"def index\n @atmospheres = Atmosphere.all\n end",
"def index\n @mugshots = Mugshot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mugshots }\n end\n end",
"def index\n @mosaics = Mosaic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mosaics }\n end\n end",
"def index\n @title = \"Moonlyters\"\n @moonlyters = Moonlyter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @moonlyters }\n end\n end",
"def index\n @miilraws = Miilraw.all\n end",
"def index\n @waivers = Waiver.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @waivers }\n end\n end",
"def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /air_moistures POST /air_moistures.json | def create
@air_moisture = AirMoisture.new(air_moisture_params)
respond_to do |format|
if @air_moisture.save
format.html { redirect_to @air_moisture, notice: 'Air moisture was successfully created.' }
format.json { render :show, status: :created, location: @air_moisture }
else
format.html { render :new }
format.json { render json: @air_moisture.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @air = Air.new(params[:air])\n\n respond_to do |format|\n if @air.save\n format.html { redirect_to @air, :notice => 'Air was successfully created.' }\n format.json { render :json => @air, :status => :created, :location => @air }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @air.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @air_moistures = AirMoisture.all\n end",
"def create\n @airtime = Airtime.new(params[:airtime])\n\n respond_to do |format|\n if @airtime.save\n format.html { redirect_to @airtime, notice: 'Airtime was successfully created.' }\n format.json { render json: @airtime, status: :created, location: @airtime }\n else\n format.html { render action: \"new\" }\n format.json { render json: @airtime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @soil_moisture = SoilMoisture.new(soil_moisture_params)\n\n respond_to do |format|\n if @soil_moisture.save\n format.html { redirect_to @soil_moisture, notice: 'Soil moisture was successfully created.' }\n format.json { render :show, status: :created, location: @soil_moisture }\n else\n format.html { render :new }\n format.json { render json: @soil_moisture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @armoire = Armoire.new(armoire_params)\n\n if @armoire.save\n render :show, status: :created, location: @armoire\n else\n render json: @armoire.errors, status: :unprocessable_entity\n end\n end",
"def create\n @air_quality = AirQuality.new(air_quality_params)\n\n if @air_quality.save\n render json: @air_quality, status: :created, location: @air_quality\n else\n render json: @air_quality.errors, status: :unprocessable_entity\n end\n end",
"def create\n @miilraw = Miilraw.new(miilraw_params)\n\n respond_to do |format|\n if @miilraw.save\n format.html { redirect_to @miilraw, notice: 'Miilraw was successfully created.' }\n format.json { render :show, status: :created, location: @miilraw }\n else\n format.html { render :new }\n format.json { render json: @miilraw.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload_floor_plan(args = {}) \n post(\"/files.json/floorplan/images\", args)\nend",
"def create\n @aile = Aile.new(aile_params)\n\n respond_to do |format|\n if @aile.save\n format.html { redirect_to @aile, notice: 'Aile was successfully created.' }\n format.json { render action: 'show', status: :created, location: @aile }\n else\n format.html { render action: 'new' }\n format.json { render json: @aile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wi_mn_d_min_t_air = WiMnDMinTAir.new(wi_mn_d_min_t_air_params)\n\n respond_to do |format|\n if @wi_mn_d_min_t_air.save\n format.html { redirect_to @wi_mn_d_min_t_air, notice: 'Wi mn d min t air was successfully created.' }\n format.json { render action: 'show', status: :created, location: @wi_mn_d_min_t_air }\n else\n format.html { render action: 'new' }\n format.json { render json: @wi_mn_d_min_t_air.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wi_mn_d_ave_t_air = WiMnDAveTAir.new(wi_mn_d_ave_t_air_params)\n\n respond_to do |format|\n if @wi_mn_d_ave_t_air.save\n format.html { redirect_to @wi_mn_d_ave_t_air, notice: 'Wi mn d ave t air was successfully created.' }\n format.json { render action: 'show', status: :created, location: @wi_mn_d_ave_t_air }\n else\n format.html { render action: 'new' }\n format.json { render json: @wi_mn_d_ave_t_air.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @air = Air.new(air_params)\n @air.room_id = current_user.id\n respond_to do |format|\n if @air.save\n format.html { redirect_to @air, notice: 'Air was successfully created.' }\n format.json { render :show, status: :created, location: @air }\n else\n format.html { render :new }\n format.json { render json: @air.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mile = Mile.new(params[:mile])\n\n respond_to do |format|\n if @mile.save\n format.html { redirect_to @mile, notice: 'Mile was successfully created.' }\n format.json { render json: @mile, status: :created, location: @mile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @moon = Moon.new(moon_params)\n\n respond_to do |format|\n if @moon.save\n format.html { redirect_to @moon, notice: 'Moon was successfully created.' }\n format.json { render :show, status: :created, location: @moon }\n else\n format.html { render :new }\n format.json { render json: @moon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @airfield = Airfield.new(airfield_params)\n\n respond_to do |format|\n if @airfield.save\n format.html { redirect_to @airfield, notice: 'Airfield was successfully created.' }\n format.json { render :show, status: :created, location: @airfield }\n else\n format.html { render :new }\n format.json { render json: @airfield.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @imobiliaria = Imobiliaria.new(imobiliaria_params)\r\n\r\n respond_to do |format|\r\n if @imobiliaria.save\r\n format.json { render json: @imobiliaria, status: :created }\r\n else \r\n format.json { render json: @imobiliaria.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @mile = Mile.new(mile_params)\n\n respond_to do |format|\n if @mile.save\n format.html { redirect_to @mile, notice: 'Mile was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mile }\n else\n format.html { render action: 'new' }\n format.json { render json: @mile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @air = Air.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @air }\n end\n end",
"def create\n @air_crew = AirCrew.new(params[:air_crew])\n\n respond_to do |format|\n if @air_crew.save\n format.html { redirect_to @air_crew, notice: 'Air crew was successfully created.' }\n format.json { render json: @air_crew, status: :created, location: @air_crew }\n else\n format.html { render action: \"new\" }\n format.json { render json: @air_crew.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |