query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
:positive / :neutral / :negative | def polarity
@polarity ||=
case
when score.zero?
:neutral
when score.positive?
:positive
when score.negative?
:negative
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positive; end",
"def positive; end",
"def positive?; end",
"def negative?() @positive==false end",
"def label() @positive end",
"def negative?\n !@positive \n end",
"def negative?; end",
"def positive?() @positive==true end",
"def negative_test\r\n @negative = true\r\n end",
"... | [
"0.76109487",
"0.76109487",
"0.75455785",
"0.748136",
"0.7091676",
"0.70389146",
"0.7023802",
"0.6953184",
"0.67904353",
"0.66695666",
"0.64578575",
"0.6450785",
"0.64476395",
"0.644294",
"0.644294",
"0.6316237",
"0.62634635",
"0.6204397",
"0.6199487",
"0.6189255",
"0.6182144... | 0.63083667 | 16 |
TODO: Dry it up. This is duplicated elsewhere. | def object_for(object_or_id, klass)
case object_or_id
when klass then object_or_id
when Integer
klass.find_by(id: object_or_id)
else
raise ArgumentError,
"must provide a #{ klass } or a valid #{ klass } id"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def from; end",
"def from; end",
"def from; end",
"def from; end",
"def terpene; end",
"def anchored; end",
"def loc; end",
"def loc; end",
"def loc... | [
"0.7258023",
"0.6360955",
"0.6296373",
"0.6296373",
"0.6296373",
"0.6296373",
"0.5965617",
"0.5780043",
"0.5780043",
"0.5780043",
"0.5780043",
"0.5772213",
"0.5748733",
"0.5733801",
"0.5733801",
"0.5733801",
"0.5730782",
"0.5696027",
"0.5662914",
"0.560671",
"0.55952805",
"... | 0.0 | -1 |
Write a method that takes the 3 angles of a triangle as arguments, and returns a symbol :right, :acute, :obtuse, or :invalid depending on whether the triangle is a right, acute, obtuse, or invalid triangle. Input : 3 numbers, angles of the triangle, integers values Output : symbol, type of the triangle or invalid msg (acute, right, obtuse, invalid) Rules: :invalid sum of 3 angles must be == 180 all of angles must be greater than 0 :right one angle is a right angle (90 degrees) :acute all 3 angles are less than 90 degrees :obtuse one angle is greater than 90 degrees Data structure Input numbers integer values converted to array of 3 elements output symbol that represent type of triangle or invalid input Algorithm create array of angles case statement that returns appropriate symbol when certain requirments are met => :invalid if angles sum != 180 or angles include 0 => :right if any angle == 90 => :acute if all angles are less than 90 => :obtuse otherwise | def triangle(angle_1, angle_2, angle_3)
angles = [angle_1, angle_2, angle_3]
case
when angles.sum != 180 || angles.include?(0)
:invalid
when angles.any?(90)
:right
when angles.all? { |angle| angle < 90 }
:acute
else
:obtuse
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triangle(angle1, angle2, angle3)\n angles = [angle1, angle2, angle3]\n return :invalid if angles.sum != 180\n return :invalid if angles.any? {|angle| angle <= 0}\n return :right if angles.any? {|angle| angle == 90}\n return :acute if angles.all? {|angle| angle < 90}\n return :obtuse if angles.any? {|angl... | [
"0.85333085",
"0.85224205",
"0.8477124",
"0.8457057",
"0.84270364",
"0.84120065",
"0.8407602",
"0.84048146",
"0.8391992",
"0.8371835",
"0.83487827",
"0.8312553",
"0.83079696",
"0.82998854",
"0.8250665",
"0.82035416",
"0.8194497",
"0.81898564",
"0.81737095",
"0.8096712",
"0.78... | 0.8493945 | 2 |
Autorizacion, pregunta si el usuario esta logueado | def logged_in_dog
unless logged_in?
redirect_to '/'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logado?\n !current_user.nil?\n end",
"def revisar_usuario\n if session[:usuario].empty?\n flash[:notice] = \"Debe loguearsar para poder seguir\"\n redirect_to \"/login\"\n end\n end",
"def verificar_autenticado_admin\n unless session[:usuario_admin] #else if,tiene quer ser falso\... | [
"0.72099483",
"0.70316184",
"0.7003652",
"0.6995591",
"0.6963468",
"0.68989384",
"0.6888302",
"0.6888302",
"0.687992",
"0.68741006",
"0.6810691",
"0.67748564",
"0.6759546",
"0.6743784",
"0.67345256",
"0.67239904",
"0.6689287",
"0.66641426",
"0.66192067",
"0.661506",
"0.660562... | 0.0 | -1 |
Hovers the widget defined by +name+ and optional +args+. | def hover(name, *args)
widget(name, *args).hover
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hover\n base.image_for(\"#{name}_hover\")\n end",
"def hover_click(*args)\n if args.size == 1\n driver.action.click(element).perform\n else\n sym,id = args\n driver.action.click(driver.find_element(sym.to_sym,id)).perform\n end\n\n end",
"def mouse_over locator\r\n ... | [
"0.59003514",
"0.5877121",
"0.5668789",
"0.5668789",
"0.559635",
"0.548851",
"0.5447665",
"0.54334414",
"0.540149",
"0.53910315",
"0.5373412",
"0.5340327",
"0.5338084",
"0.5295968",
"0.52948105",
"0.52810556",
"0.5279943",
"0.5199232",
"0.51675224",
"0.5116657",
"0.50699365",... | 0.90037346 | 0 |
Double clicks the widget defined by +name+ and optional +args+. | def double_click(name, *args)
widget(name, *args).double_click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_click(name, *args)\n widget(name, *args).right_click\n end",
"def doubleclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil)\n $marathon.click(componentName, false, 2, o1, o2, o3, o4)\nend",
"def double_click(*args)\n case args.length\n when 1 then click_image(args[0]... | [
"0.75034124",
"0.7450685",
"0.7434601",
"0.7431053",
"0.735549",
"0.7069308",
"0.68412656",
"0.6669535",
"0.6624832",
"0.65474355",
"0.6547266",
"0.64397454",
"0.63531953",
"0.63485444",
"0.63150084",
"0.63038003",
"0.61704737",
"0.61327314",
"0.6113735",
"0.61123866",
"0.611... | 0.916154 | 0 |
Right clicks the widget defined by +name+ and optional +args+. | def right_click(name, *args)
widget(name, *args).right_click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_click(name, *args)\n widget(name, *args).double_click\n end",
"def rightclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)\n $marathon.click(componentName, true, o1, o2, o3, o4, o5)\nend",
"def rightclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = ni... | [
"0.81100863",
"0.7150753",
"0.7143982",
"0.6974602",
"0.67703515",
"0.67618877",
"0.67600584",
"0.66718864",
"0.64862144",
"0.629425",
"0.6235374",
"0.6235374",
"0.6235374",
"0.6178716",
"0.6176475",
"0.6120835",
"0.6095269",
"0.6095269",
"0.60702384",
"0.60663825",
"0.606638... | 0.8895936 | 0 |
Returns a widget instance for the given name. | def widget(name, *args)
eventually { document.widget(name, *args) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object(name)\n gtk_builder_get_object(@builder, name)\n end",
"def jmaki_load_widget(name)\n # Return previously parsed content (if any)\n if !@jmaki_widgets\n @jmaki_widgets = { }\n end\n previous = @jmaki_widgets[name]\n if previous\n return previous\n end\n conte... | [
"0.6700946",
"0.6534847",
"0.6436914",
"0.6254253",
"0.60838956",
"0.6064248",
"0.5990443",
"0.5872015",
"0.5869043",
"0.5864325",
"0.5836126",
"0.5826878",
"0.58184946",
"0.57983124",
"0.5732239",
"0.56951845",
"0.5688887",
"0.5665339",
"0.56639415",
"0.5634459",
"0.56262785... | 0.67785233 | 0 |
Returns a list of widget instances for the given name. | def widgets(name, *args)
document.widgets(name, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def widgets(win_name)\n @driver.getQuickWidgetList(win_name).map do |java_widget|\n case java_widget.getType\n when QuickWidget::WIDGET_ENUM_MAP[:button]\n QuickButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:checkbox]\n QuickCheckbox.new(self,j... | [
"0.7471749",
"0.6291563",
"0.6247767",
"0.62255275",
"0.60761404",
"0.60491467",
"0.60024506",
"0.5961512",
"0.5910529",
"0.58980614",
"0.5896949",
"0.5856864",
"0.58459985",
"0.5744007",
"0.5697456",
"0.5674075",
"0.56366825",
"0.5594575",
"0.55323553",
"0.553062",
"0.550094... | 0.68105316 | 1 |
rerun one or more assertions until either they all pass, or Capybara::UI times out, which will result in a test failure. | def eventually(wait_time = Capybara.default_max_wait_time, &block)
Checkpoint.wait_for wait_time, &block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test02_4GroupsRepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\tfourGroupSelect\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS06T02: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test_040\n test_000\n login(\"root\... | [
"0.59381896",
"0.5861545",
"0.5833031",
"0.5802814",
"0.5767462",
"0.5763799",
"0.5761762",
"0.5761372",
"0.57537913",
"0.5729829",
"0.5718388",
"0.5703899",
"0.56978977",
"0.5696707",
"0.569051",
"0.56802905",
"0.5666066",
"0.5663195",
"0.5642982",
"0.5642401",
"0.5626163",
... | 0.0 | -1 |
Needs a better name | def new_url_friendly_token
self.title.downcase.gsub(/\.|!|,|:|\/|\\|"|'|\?/, "").gsub(/\s+/, '-')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def custom; end",
"def custom; end",
"def formation; end",
"def who_we_are\r\n end",
"def terpene; end",
"def suivre; end",
"def verdi; end",
"def lo... | [
"0.7934856",
"0.6995856",
"0.69715554",
"0.69715554",
"0.69715554",
"0.69715554",
"0.6818438",
"0.65719235",
"0.65719235",
"0.6519513",
"0.64612186",
"0.64191276",
"0.64080924",
"0.62746495",
"0.62142885",
"0.62142885",
"0.62142885",
"0.6213299",
"0.6207486",
"0.6191437",
"0.... | 0.0 | -1 |
EMPLOYEE_LDAP_UID = "212386" Takes an object that responds to :ldap_uid Or, takes the ldap_uid as a String or Integer. | def login_user(ldap_obj)
if ldap_obj.is_a?(String) || ldap_obj.is_a?(Integer)
ldap_uid = ldap_obj
else
ldap_uid = ldap_obj.ldap_uid
end
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:cas, { uid: ldap_uid.to_s })
visit(login_url())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ldap_id\n\t\tself.id = Devise::LDAP::Adapter.get_ldap_param(self.username,\"uidnumber\").first\n end",
"def ldap_person\n @person ||= UCB::LDAP::Person.find_by_uid(self.login) if self.login\n end",
"def get_uid(email, ldap_entry)\n # Get the first uid value (this should always be the cano... | [
"0.68740445",
"0.6342161",
"0.6110116",
"0.58546776",
"0.5807252",
"0.5701588",
"0.56797004",
"0.56797004",
"0.56554055",
"0.56110746",
"0.55768347",
"0.5570641",
"0.5544131",
"0.5540651",
"0.55337566",
"0.5528226",
"0.5523299",
"0.55200166",
"0.54965156",
"0.54965156",
"0.54... | 0.53609556 | 27 |
D: Return a cached rendering of the object loaded for later drawing usage. | def gl_draw_list( model )
@face_index.each do |fidx|
# https://docs.microsoft.com/en-us/windows/desktop/opengl/glbegin
# What do the faces look like?
#glBegin( GL_TRIANGLES ) # triangles
#glBegin( GL_QUADS ) # squares
glBegin( GL_POLYGON ) # polygon shapes, (openGL figures it out...)
face = @faces[fidx]
# draw each texture face on the object mesh.
for i in 0...face.vertex_count do
# prep tri/quad/poly face section drawing vars
vi = face.vtx_index[i]
ni = face.nrm_index[0] != -1 ? face.nrm_index[i] : nil
ti = face.tex_index[0] != -1 ? face.tex_index[i] : nil
# vertext plane start location:
glNormal3f( model.normal[ni][0], model.normal[ni][1], model.normal[ni][2] ) if ni
if ti # if has texture.
# Gosu has issues with inversion Y plane for texture maping.
# for this we offset the text cord by bottom of image reading down instead of up.
# OpenGL textures are read from the bottomRight of the image to the TopLeft.
# Gosu loads images into IO stream TopLeft and would end up being read Upside down.
# Hense a subtraction from fload 1.0 for text cord. - BestGuiGui
glTexCoord2f( model.texcoord[ti][0], 1.0 - model.texcoord[ti][1] )
end
# plane texture corners to vertex points:
glVertex3f( model.vertex[vi][0], model.vertex[vi][1], model.vertex[vi][2] )
end
glEnd()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached_render\n if Global.file_cache\n cached_render_file\n else\n cached_render_memory\n end\n end",
"def cached_render_file\n rendered = uncached_render\n\n global_epath = Global.public_root/self.controller.mapping/extended_path\n FileUtils.mkdir_p(File.dirnam... | [
"0.7685884",
"0.63373435",
"0.6220672",
"0.604395",
"0.59927267",
"0.59593034",
"0.58232397",
"0.5812821",
"0.576603",
"0.5667125",
"0.56234354",
"0.5606334",
"0.56011724",
"0.55613625",
"0.55403614",
"0.5491478",
"0.5486506",
"0.5449549",
"0.5441233",
"0.5425705",
"0.5416308... | 0.0 | -1 |
D: return the objects total face count. | def get_face_count
count = 0
@groups.each_value do |grp|
count += grp.faces.size
end
return count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_objects_count\n @game_objects.count\n end",
"def count_objects\n ObjectSpace.count_objects\n end",
"def count_objects\n count = 0\n @objects.keys.each do |key|\n count += @objects[key].length\n end\n\n return count\n end",
"def objects_count\n @objects_count ||= ... | [
"0.7563178",
"0.75399995",
"0.73734385",
"0.7326226",
"0.700369",
"0.69684803",
"0.6877062",
"0.6816855",
"0.6805063",
"0.6798709",
"0.6780053",
"0.6742576",
"0.67302614",
"0.672904",
"0.6615932",
"0.6594205",
"0.6587683",
"0.6582197",
"0.65558004",
"0.65522766",
"0.6549445",... | 0.8467805 | 0 |
D: Called from with in a ' gl do ' block after the object was properly loaded. | def render
@groups.each_value do |grp|
#print("#{grp.name} ")
glCallList( grp.displaylist ) # call precahed operation to save gpu/cpu
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loaded()\n end",
"def onLoaded()\n @object.loaded\n end",
"def gl_draw\n return if @destoryed # map will take care of the class object.\n # https://docs.microsoft.com/en-us/windows/desktop/opengl/glpushmatrix\n glPushMatrix # for the most part operations should keep to themselfs with lo... | [
"0.65729517",
"0.6163924",
"0.6021082",
"0.6014012",
"0.5973201",
"0.5861735",
"0.5779779",
"0.5762361",
"0.5747806",
"0.57429296",
"0.57343614",
"0.56684595",
"0.5666622",
"0.56608355",
"0.5644843",
"0.56314695",
"0.56200767",
"0.56200767",
"0.56200767",
"0.56200767",
"0.561... | 0.0 | -1 |
D: Read a .obj file and turn the lines into data points to create the object. | def parse
wo_lines = IO.readlines( @file_dir )
@current_group = get_group( "default" )
@current_material_name = "default"
puts("+Loading .obj file:\n \"#{@file_dir.sub(ROOT, '')}\"") if @verbose
# parse file context
wo_lines.each do |line|
tokens = line.split
# make sense of the object tokens
string = line.sub("\r", "")
process_line(tokens[0], tokens[1..tokens.length-1], string.sub("\n", ""))
end
@object_name = @file_dir.split('/').last
@object_name.sub!(".obj", '')
# verbose status updates
puts("+Object name is \"#{@object_name}\" with (#{@objects.size}) Internal Objects.") if @verbose
if get_group("default").faces.empty?
@groups.delete("default")
end
@current_group = nil
@current_material_name = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_objects(file, objects)\n objects.each do |data_type|\n num = DataNumber.new.read(file).data\n\n # use i to indentify the type of object.\n num.times do ||\n _obj = data_type.new.read(file)\n end\n end\n end",
"def from_file line\n\t\tvals = line.split(\"-\")\n\t\t@type ... | [
"0.6930454",
"0.62949574",
"0.61179334",
"0.60561913",
"0.59808797",
"0.59243625",
"0.5873185",
"0.56598336",
"0.5589822",
"0.55775833",
"0.5478374",
"0.54504454",
"0.53911966",
"0.53388566",
"0.53007317",
"0.5274141",
"0.5268032",
"0.5266095",
"0.5262088",
"0.5230244",
"0.52... | 0.6578253 | 1 |
parse D: Record the draw action for faster refrence in later gl_draws for the object. | def setup
self.parse() # load file
puts("+Constructing a total of (#{@groups.keys.size}) Groups:") if @verbose
@groups.each_value do |grp|
grp.displaylist = glGenLists( 1 )
glNewList(grp.displaylist, GL_COMPILE )
puts(" * \"#{grp.name}\" : Faces(#{grp.faces.size}) openGL draw list cached.") if @verbose
grp.gl_draw_list(self) # create precahced draw operation
glEndList()
end
puts("+Total Count of Faces: [ #{self.get_face_count} ]") if @verbose
# display materials information
puts("+Material Lib: \"#{material_lib}\" with (#{@current_materials.size}) Name Refrences.") if @verbose
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw\n\t\t@move_action.draw\n\tend",
"def draw; end",
"def draw; end",
"def draw\n end",
"def draw\n end",
"def draw\n end",
"def draw\n end",
"def draw\n\t\t\n\tend",
"def draw\n\t\t\n\tend",
"def draw\n\t\t\n\tend",
"def draw\n\t\t\n\tend",
"def draw\n\tend",
"def draw\n\n\t... | [
"0.6554437",
"0.5880962",
"0.5880962",
"0.5828265",
"0.5828265",
"0.5828265",
"0.578141",
"0.5737402",
"0.5737402",
"0.5737402",
"0.5737402",
"0.5718622",
"0.56853026",
"0.5673699",
"0.54960084",
"0.54728097",
"0.5469598",
"0.5464913",
"0.545161",
"0.5439377",
"0.5413563",
... | 0.0 | -1 |
D: Returns Group object (or creates new Group when there's no matching group found) | def get_group( name )
if ( !@groups.has_key?( name ) )
@groups[name] = Group.new( name )
end
return @groups[name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_or_create_group\n name = metadata['group']\n\n db = DB::Groups.find(name, pool)\n grp = load_group\n\n if db.nil?\n # The group does not exist, create it\n Commands::Group::Create.run!(\n pool: pool.name,\n name: grp.name\n )\n\n return DB::... | [
"0.77750725",
"0.7636884",
"0.7586702",
"0.7051282",
"0.7011853",
"0.6918788",
"0.6911392",
"0.6824593",
"0.66583335",
"0.6640229",
"0.65873617",
"0.652099",
"0.652099",
"0.652099",
"0.652099",
"0.652099",
"0.6519217",
"0.6499652",
"0.64856726",
"0.6478147",
"0.64704424",
"... | 0.68601763 | 7 |
D: Read each line of an object file exported with 3d party software for loading into OpenGL draw methods. D: | def process_line( key, values, line_string)
case key
#---------------------------------------------------------
# List of geometric vertices, with (x, y, z [,w]) coordinates,
# w is optional and defaults to 1.0.
when "v"
values.collect! { |v| v.to_f }
@vertex.push( values )
#---------------------------------------------------------
# List of vertex normals in (x,y,z) form; normals might not be unit vectors.
# https://en.wikipedia.org/wiki/Normal_(geometry)
when "vn"
values.collect! { |v| v.to_f }
@normal.push( values )
#---------------------------------------------------------
# List of texture coordinates, in (u, [v ,w]) coordinates, these
# will vary between 0 and 1, v and w are optional and default to 0.
when "vt"
values.collect! { |v| v.to_f }
values = values[0..1]
#values.size.times do |index|
# values[index] *= -1.0 # inverse Y cord in texture file?
#end
@texcoord.push( values ) # u and v
puts("Texture pos: [#{values.join(', ')}] From: \'#{line_string}\'") if DEBUGGING
#---------------------------------------------------------
# Named objects and polygon groups.
when "o"
@objects << values.first
#---------------------------------------------------------
# Polygon group names.
when "g", "group"
if values.length == 0
# p "anonymous group detected. treat as \"default\"."
@current_group = get_group( "default" )
else
# Only the first group is adopted even if there are multiple group names on the line.
@current_group = get_group( values[0] )
end
@current_group.mtl_name = @current_material_name
#---------------------------------------------------------
# Smooth shading across polygons? * can also mark shader groups with int value *
when "s"
setting = values.first # convert into boolean
@smooth_shading = setting.include?('on') or setting.include?('true')
#---------------------------------------------------------
# Polygonal face element, these can be packaged in a number of ways.
# index is offset to start drawing at tile index 0, hense minus 1
when "f"
vertex_count = values.length
case values[0]
when /\d+\/\d+\/\d+/ # v/vt/vn
face = Face.new( vertex_count )
print("Face: ") if DEBUGGING
values.each_with_index do |value, i|
v, vt, vn = value.split( '/' )
face.vtx_index[i] = v.to_i - 1
face.tex_index[i] = vt.to_i - 1
face.nrm_index[i] = vn.to_i - 1
print("[#{face.vtx_index[i]}, #{face.tex_index[i]}, #{face.nrm_index[i]}] ") if DEBUGGING
end
# --------------------------------------
when /\d+\/\/\d+/ # v//vn
face = Face.new( vertex_count )
print("Face: ") if DEBUGGING
values.each_with_index do |value, i|
v, vn = value.split( '//' )
face.vtx_index[i] = v.to_i - 1
face.nrm_index[i] = vn.to_i - 1
print("[#{face.vtx_index[i]}, #{face.nrm_index[i]}] ") if DEBUGGING
end
# --------------------------------------
when /\d+\/\d+/ # v/vt
face = Face.new( vertex_count )
print("Face: ") if DEBUGGING
values.each_with_index do |value, i|
v, vt = value.split( '/' )
face.vtx_index[i] = v.to_i - 1
face.tex_index[i] = vt.to_i - 1
print("[#{face.vtx_index[i]}, #{face.tex_index[i]}] ") if DEBUGGING
end
# --------------------------------------
when /\d+/ # v
face = Face.new( vertex_count )
print("Face: ") if DEBUGGING
values.each_with_index do |value, i|
face.vtx_index[i] = value.to_i - 1
print("[#{face.vtx_index[i]}] ") if DEBUGGING
end
# --------------------------------------
else
p "unknown face format detected."
end
@current_group.faces.push( face )
@current_group.face_index.push( @current_group.faces.length - 1 )
puts("") if DEBUGGING
#---------------------------------------------------------
when /^\#+/, nil
#puts "comment or empty line."
#---------------------------------------------------------
# The .mtl file may contain one or more named material definitions.
when "mtllib"
# https://en.wikipedia.org/wiki/Materials_system
# https://en.wikipedia.org/wiki/Wavefront_.obj_file#Material_template_library
@material_lib = MaterialLibrary.new(values.first)
#---------------------------------------------------------
# The material name matches a named material definition in an external .mtl file.
when "usemtl"
@current_materials << values.first
#---------------------------------------------------------
else
puts " -Unsupported .obj token #{key} given. Ignored."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file\n filename = full_path_from_edict_file(@config[\"filename\"])\n ### Get all the line into memory\n file_obj = File.new(filename, \"r\")\n file_obj.each do |line|\n @added_lines.push line\n end\n end",
"def parse\n wo_lines = IO.readlines( @file_dir )\n @current_group... | [
"0.6420392",
"0.6225856",
"0.6061187",
"0.6059899",
"0.6020622",
"0.57642144",
"0.57232845",
"0.5711985",
"0.5678978",
"0.56769335",
"0.55477196",
"0.55265605",
"0.54853624",
"0.5438154",
"0.53964245",
"0.5357252",
"0.5342644",
"0.5332066",
"0.53283304",
"0.53227806",
"0.5320... | 0.5311559 | 21 |
Records when was the world seen into the world's coordinator record | def add_record(id, time = Time.now)
record = find_world id
@executor[id] ||= record.data[:class] == 'Dynflow::Coordinator::ExecutorWorld'
record.data[:meta].update(:last_seen => self.class.format_time(time))
@world.coordinator.update_record(record)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_seen_at() ; info_time(:last_seen) ; end",
"def just_saw\n\t\t\t@last_seen = Time.now\n\t\tend",
"def history_added; end",
"def stamp\n self.dateChanged = Time.now\n self.changedBy = ApplicationController.application_name\n end",
"def stamp\n self.dateChanged = Time.now\n sel... | [
"0.5985351",
"0.5702953",
"0.5644542",
"0.5639094",
"0.5639094",
"0.5639094",
"0.56062806",
"0.5555142",
"0.5473823",
"0.5473823",
"0.5377818",
"0.5344288",
"0.53417057",
"0.5312277",
"0.5312277",
"0.5312277",
"0.5312277",
"0.5312277",
"0.5312277",
"0.52680624",
"0.5266372",
... | 0.58622915 | 1 |
Looks into the cache whether the world has an executor | def executor?(id)
@executor[id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def executing?(name)\n Threaded.executing?(name)\n end",
"def executable?\n \n # Return false if picked up by another WQ instance\n if id\n old_lock_version = lock_version\n self.reload\n return false if old_lock_version != lock_version\n end\n \n # Retu... | [
"0.6265423",
"0.61224943",
"0.6103797",
"0.60713375",
"0.6040377",
"0.6039144",
"0.60386235",
"0.60386235",
"0.60386235",
"0.60244215",
"0.59997284",
"0.5996314",
"0.59745073",
"0.5966175",
"0.59192693",
"0.58917797",
"0.5882518",
"0.58809906",
"0.58665013",
"0.58665013",
"0.... | 0.7203416 | 0 |
Loads the coordinator record from the database and checks whether the world was last seen within the time limit | def fresh_record?(id)
record = find_world(id)
return false if record.nil?
@executor[id] = record.data[:class] == 'Dynflow::Coordinator::ExecutorWorld'
time = self.class.load_time(record.data[:meta][:last_seen])
time >= Time.now - @max_age
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_is_recent_enough?\n # It's possible for a replica to not replay WAL data for a while,\n # despite being up to date. This can happen when a primary does not\n # receive any writes for a while.\n #\n # To prevent this from happening we check if the lag size (in b... | [
"0.54737556",
"0.5451",
"0.53868717",
"0.53526783",
"0.5323105",
"0.5323105",
"0.5298916",
"0.5298916",
"0.5277637",
"0.52180606",
"0.5167324",
"0.5094911",
"0.50887007",
"0.5088627",
"0.5065216",
"0.50643003",
"0.50152117",
"0.5013471",
"0.49971685",
"0.4965012",
"0.49443424... | 0.70421654 | 0 |
Records when was the world with provided id last seen using a PingCache | def add_ping_cache_record(id)
log Logger::DEBUG, "adding ping cache record for #{id}"
@ping_cache.add_record id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_seen_at() ; info_time(:last_seen) ; end",
"def add_record(id, time = Time.now)\n record = find_world id\n @executor[id] ||= record.data[:class] == 'Dynflow::Coordinator::ExecutorWorld'\n record.data[:meta].update(:last_seen => self.class.format_time(time))\n ... | [
"0.61532664",
"0.56334555",
"0.5567016",
"0.55406165",
"0.5500623",
"0.5338272",
"0.5311125",
"0.5244022",
"0.5236393",
"0.5226602",
"0.52120185",
"0.5211168",
"0.5197269",
"0.51751626",
"0.5146236",
"0.51421404",
"0.5099745",
"0.5097896",
"0.5097896",
"0.50839597",
"0.507730... | 0.6573504 | 0 |
Tries to reduce the number of sent Ping requests by first looking into a cache. If the destination world is an executor world, the result is resolved solely from the cache. For client worlds the Ping might be sent if the cache record is stale. | def with_ping_request_caching(request, future)
return yield unless request.is_a?(Dynflow::Dispatcher::Ping)
return yield unless request.use_cache
if @ping_cache.fresh_record?(request.receiver_id)
future.fulfill(true)
else
if @ping_cache.executor?(request.receiver_id)
future.reject false
else
yield
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def try_route_with_internal_cache(type, name)\n if host = self.cache[name]\n logger.debug \"Found '#{host}' for #{type} '#{name}' from Internal Cache.\"\n host\n else\n logger.warn \"No entry in Internal Cache...\"\n try_route_with_new_redis_connection(type, name)\n end\n... | [
"0.5506904",
"0.5448852",
"0.536698",
"0.5194941",
"0.5173094",
"0.51420766",
"0.5075313",
"0.5038279",
"0.49995124",
"0.49597052",
"0.49459925",
"0.49328312",
"0.48977798",
"0.48755512",
"0.48401",
"0.4835775",
"0.48188362",
"0.48129246",
"0.48111284",
"0.47891805",
"0.47847... | 0.58573693 | 0 |
GET /dor_masters GET /dor_masters.json | def index
@dor_masters = DorMaster.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @djrmasters = Djrmaster.all\n end",
"def index\n @masters = Master.all\n end",
"def index\n @masters = Master.all.paginate(page: params[:page], per_page: 200)\n end",
"def index\n @town_masters = TownMaster.all\n end",
"def index\n @masterservices = Masterservice.all\n end",... | [
"0.6960988",
"0.68790364",
"0.64194214",
"0.64019245",
"0.63474435",
"0.62803537",
"0.6245516",
"0.62290746",
"0.6191616",
"0.6131362",
"0.61055446",
"0.60811263",
"0.60811263",
"0.60555166",
"0.6026892",
"0.6005102",
"0.6000466",
"0.5991465",
"0.5956027",
"0.59559053",
"0.59... | 0.728603 | 0 |
GET /dor_masters/1 GET /dor_masters/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dor_masters = DorMaster.all\n \n end",
"def index\n @masters = Master.all\n end",
"def index\n @djrmasters = Djrmaster.all\n end",
"def show\n @distro = Distro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @... | [
"0.70674694",
"0.6753521",
"0.6730584",
"0.6461148",
"0.6461148",
"0.6327087",
"0.6272245",
"0.6239664",
"0.62156254",
"0.61957324",
"0.61737627",
"0.61737627",
"0.6163546",
"0.61025316",
"0.60730755",
"0.60434246",
"0.6039213",
"0.6011654",
"0.60007054",
"0.59532195",
"0.593... | 0.0 | -1 |
POST /dor_masters POST /dor_masters.json | def create
@dor_master = DorMaster.new(dor_master_params)
respond_to do |format|
if @dor_master.save
format.html { redirect_to @dor_master, notice: 'Dor master was successfully created.' }
format.json { render :show, status: :created, location: @dor_master }
else
format.html { render :new }
format.json { render json: @dor_master.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @master = Master.new(master_params)\n\n respond_to do |format|\n if @master.save\n format.html { redirect_to @master, notice: 'Master was successfully created.' }\n format.json { render :show, status: :created, location: @master }\n else\n format.html { render :new... | [
"0.62448233",
"0.61886626",
"0.6172584",
"0.6143834",
"0.60216755",
"0.59618944",
"0.5952",
"0.59434",
"0.59066623",
"0.5819302",
"0.57763493",
"0.57525057",
"0.57051605",
"0.568505",
"0.5588518",
"0.55665827",
"0.55290824",
"0.5518695",
"0.551768",
"0.55174637",
"0.55152285"... | 0.6797411 | 0 |
PATCH/PUT /dor_masters/1 PATCH/PUT /dor_masters/1.json | def update
respond_to do |format|
if @dor_master.update(dor_master_params)
format.html { redirect_to @dor_master, notice: 'Dor master was successfully updated.' }
format.json { render :show, status: :ok, location: @dor_master }
else
format.html { render :edit }
format.json { render json: @dor_master.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @master.update(master_params)\n format.html { redirect_to @master, notice: 'Master was successfully updated.' }\n format.json { render :show, status: :ok, location: @master }\n else\n format.html { render :edit }\n format.json { rend... | [
"0.6608503",
"0.6519024",
"0.64278144",
"0.64157003",
"0.62379485",
"0.62108123",
"0.61983496",
"0.61805767",
"0.6169099",
"0.61632514",
"0.61289513",
"0.61267215",
"0.6074874",
"0.60691965",
"0.60635203",
"0.6034237",
"0.60055965",
"0.6003266",
"0.596919",
"0.5958468",
"0.59... | 0.67960846 | 0 |
DELETE /dor_masters/1 DELETE /dor_masters/1.json | def destroy
@dor_master.destroy
respond_to do |format|
format.html { redirect_to dor_masters_url, notice: 'Dor master was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @hot_master.destroy\n respond_to do |format|\n format.html { redirect_to hot_masters_url, notice: DELETE_NOTICE }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destr... | [
"0.70097053",
"0.7001957",
"0.6980012",
"0.69762015",
"0.696791",
"0.69638145",
"0.692363",
"0.6921887",
"0.6910164",
"0.6890854",
"0.6880473",
"0.68403643",
"0.6836584",
"0.6821473",
"0.6800084",
"0.67787975",
"0.6775802",
"0.67735064",
"0.6769035",
"0.6743476",
"0.6716086",... | 0.7358595 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_dor_master
@dor_master = DorMaster.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def dor_master_params
params.require(:dor_master).permit(:date, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Export the word frequency data. This saves its data out as a CSV file to be downloaded by the user later. As of yet, we don't offer display in the browser; I think this data is so complex that you'll want to pull it up on a spreadsheet. Note that there are also parameters to be passed in to the `ComputeWordFrequencies` concern; see that concern's documentation for the specification of those arguments. | def perform
options.clean_options!
at(0, 100, t('common.progress_initializing'))
user = User.find(options[:user_id])
dataset = user.datasets.active.find(options[:dataset_id])
task = dataset.analysis_tasks.find(options[:task_id])
task.name = t('.short_desc')
task.save
# Do the analysis
analyzer = compute_word_frequencies(
dataset,
->(p) { at(p, 100, t('.progress_calculating')) },
options)
corpus_size = RLetters::Solr::CorpusStats.new.size
# Create some CSV
at(100, 100, t('common.progress_finished'))
csv_string = CSV.generate do |csv|
csv << [t('.csv_header', name: dataset.name)]
csv << ['']
# Output the block data
if analyzer.blocks.size > 1
csv << [t('.each_block')]
name_row = ['']
header_row = ['']
word_rows = []
analyzer.word_list.each do |w|
word_rows << [w]
end
types_row = [t('.types_header')]
tokens_row = [t('.tokens_header')]
ttr_row = [t('.ttr_header')]
analyzer.blocks.each_with_index do |b, i|
s = analyzer.block_stats[i]
name_row << s[:name] << '' << '' << ''
header_row << t('.freq_header') \
<< t('.prop_header') \
<< t('.tfidf_dataset_header') \
<< t('.tfidf_corpus_header')
word_rows.each do |r|
word = r[0]
r << (b[word] || 0).to_s
r << ((b[word] || 0).to_f / s[:tokens].to_f).to_s
r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,
analyzer.df_in_dataset[word],
dataset.entries.size)
if analyzer.df_in_corpus.present?
r << Math.tfidf((b[word] || 0).to_f / s[:tokens].to_f,
analyzer.df_in_corpus[word],
corpus_size)
else
r << ''
end
end
# Output the block stats at the end
types_row << s[:types].to_s << '' << '' << ''
tokens_row << s[:tokens].to_s << '' << '' << ''
ttr_row << (s[:types].to_f / s[:tokens].to_f).to_s << '' << '' << ''
end
csv << name_row
csv << header_row
word_rows.each do |r|
csv << r
end
csv << types_row
csv << tokens_row
csv << ttr_row
end
# Output the dataset data
csv << ['']
csv << [t('.whole_dataset')]
csv << ['', t('.freq_header'), t('.prop_header'),
t('.df_header'), t('.tfidf_corpus_header')]
analyzer.word_list.each do |w|
tf_in_dataset = analyzer.tf_in_dataset[w]
r = [w,
tf_in_dataset.to_s,
(tf_in_dataset.to_f / analyzer.num_dataset_tokens).to_s]
if analyzer.df_in_corpus.present?
r << analyzer.df_in_corpus[w].to_s
r << Math.tfidf(tf_in_dataset, analyzer.df_in_corpus[w],
corpus_size)
else
r << ''
r << ''
end
csv << r
end
csv << [t('.types_header'), analyzer.num_dataset_types.to_s]
csv << [t('.tokens_header'), analyzer.num_dataset_tokens.to_s]
csv << [t('.ttr_header'), (analyzer.num_dataset_types.to_f /
analyzer.num_dataset_tokens).to_s]
csv << ['']
end
# Write it out
ios = StringIO.new(csv_string)
file = Paperclip.io_adapters.for(ios)
file.original_filename = 'word_frequency.csv'
file.content_type = 'text/csv'
task.result = file
# We're done here
task.finish!
completed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_csv\n CSV.generate do |csv|\n csv << %w[word count]\n sort_words.each do |word_count|\n csv << word_count\n end\n end\n end",
"def freqs_to_csv(frequencies, path)\n CSV.open(path, \"wb\") do |csv|\n frequencies.map { |k, v| csv << [k, v] }\n end\nend",
"def write_to_csv... | [
"0.70070314",
"0.6349633",
"0.59001243",
"0.57907706",
"0.5592818",
"0.55902904",
"0.5419103",
"0.5399358",
"0.5346235",
"0.530937",
"0.5235047",
"0.5232909",
"0.5226917",
"0.51887214",
"0.5182279",
"0.5138057",
"0.5129115",
"0.5110452",
"0.50978327",
"0.5093862",
"0.507107",... | 0.0 | -1 |
What is the longest height based on width of dp[i][j] | def expand(dp, i, j)
height = 0
width = dp[i][j]
# Up
i.downto(0).each do |m|
break if dp[m][j] < width
height += 1
end
# Down
(i+1..dp.size-1).each do |m|
break if dp[m][j] < width
height += 1
end
height*width
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_area(height)\n max_area = 0\n seen = {}\n\n (0...height.length).each do |idx|\n next if seen[idx]\n seen[idx] = true\n\n (idx + 1...height.length).each do |idx2|\n h = [height[idx], height[idx2]].min\n area = h * (idx2 - idx)\n max_area = area > max_area ? area : max_area\n en... | [
"0.64059925",
"0.63923764",
"0.63339835",
"0.631743",
"0.631596",
"0.6270813",
"0.6242039",
"0.6204277",
"0.6183002",
"0.6183002",
"0.6183002",
"0.6183002",
"0.6183002",
"0.6183002",
"0.61391354",
"0.6133667",
"0.61227804",
"0.61004394",
"0.61004394",
"0.604049",
"0.60266834"... | 0.66691875 | 0 |
GET /announcements GET /announcements.xml | def index
@announcements = Announcement.find(:all, :order => 'starts_at desc')
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @announcements }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @announcements = Announcement.all\n end",
"def show\n @announcement = Announcement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @announcement }\n end\n end",
"def index\n @announcements = Announcement.all\n ... | [
"0.7219041",
"0.7165205",
"0.7117977",
"0.7117977",
"0.70310444",
"0.68501073",
"0.6684618",
"0.668279",
"0.6629289",
"0.6588111",
"0.65563077",
"0.6494598",
"0.6453911",
"0.6453911",
"0.6436308",
"0.6436308",
"0.6394005",
"0.6350244",
"0.63181615",
"0.62904847",
"0.6275297",... | 0.7142449 | 2 |
GET /announcements/new GET /announcements/new.xml | def new
@announcement = Announcement.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @announcement }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @announcement }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: ... | [
"0.7923954",
"0.75682324",
"0.7436319",
"0.7276343",
"0.71831554",
"0.7018658",
"0.70069426",
"0.6921423",
"0.6859628",
"0.6828302",
"0.6828028",
"0.6810493",
"0.6788889",
"0.6767258",
"0.67655563",
"0.67655563",
"0.6735334",
"0.6735334",
"0.6735334",
"0.673487",
"0.6732698",... | 0.7999204 | 1 |
POST /announcements POST /announcements.xml | def create
@announcement = Announcement.new(params[:announcement])
respond_to do |format|
if @announcement.save
flash[:notice] = 'Announcement was successfully created.'
format.html { redirect_to announcements_path }
format.xml { render :xml => @announcement, :status => :created, :location => @announcement }
else
format.html do
flash[:notice] = 'Announcement was not Successfully created'
render :action => "new"
end
format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @announcement = Announcement.new(announcement_params)\n\n respond_to do |format|\n if @announcement.save\n format.html { render html: '200' }\n format.json { render 'announcements/announcement', status: :created, announcement: @announcement }\n else\n format.html {... | [
"0.6889887",
"0.6874412",
"0.6874412",
"0.68625504",
"0.6846886",
"0.6703081",
"0.6667529",
"0.66169566",
"0.658104",
"0.6554651",
"0.6519784",
"0.6501138",
"0.64651704",
"0.64454",
"0.6397792",
"0.63735604",
"0.63589764",
"0.63033664",
"0.62843746",
"0.6250486",
"0.62473965"... | 0.6905966 | 0 |
PUT /announcements/1 PUT /announcements/1.xml | def update
@announcement = Announcement.find(params[:id])
respond_to do |format|
if @announcement.update_attributes(params[:announcement])
flash[:notice] = 'Announcement was successfully updated.'
format.html { redirect_to announcements_path }
format.xml { head :ok }
else
format.html do
flash[:notice] = 'Announcement was not successfully updated'
render :action => "edit"
end
format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @announce = Announce.find(params[:id])\n\n respond_to do |format|\n if @announce.update_attributes(params[:announce])\n format.html { redirect_to @announce, notice: 'Announce was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren... | [
"0.70501745",
"0.70501745",
"0.6947444",
"0.68963695",
"0.6712588",
"0.66069967",
"0.6593863",
"0.6541586",
"0.6496441",
"0.64277583",
"0.64277583",
"0.64277583",
"0.64277583",
"0.64251",
"0.64005053",
"0.64005053",
"0.64005053",
"0.64005053",
"0.64005053",
"0.63305634",
"0.6... | 0.67390853 | 4 |
DELETE /announcements/1 DELETE /announcements/1.xml | def destroy
@announcement = Announcement.find(params[:id])
@announcement.destroy
respond_to do |format|
format.html do
flash[:notice] = 'Announcement has been successfully delected'
redirect_to announcements_path
end
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @announcement = Announcement.find(params[:id])\n @announcement.destroy\n\n respond_to do |format|\n format.html { redirect_to(announcements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @announcement = Announcement.find(params[:id])\n @announcement.dest... | [
"0.76277906",
"0.76277906",
"0.72927845",
"0.7263305",
"0.72017324",
"0.7185462",
"0.7109124",
"0.70955485",
"0.7067623",
"0.69841677",
"0.69841677",
"0.69841677",
"0.69730854",
"0.69530404",
"0.69160426",
"0.6912065",
"0.6796883",
"0.6796883",
"0.6796883",
"0.6738845",
"0.66... | 0.73915064 | 2 |
Passes in data from scraper when recipe is created | def initialize(recipe_hash)
recipe_hash.each do |attribute, value|
self.send(("#{attribute}="), value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_attributes_to_recipes\n EasyVegan::Recipe.all.each do |recipe|\n recipe.add_recipe_attributes(EasyVegan::Scraper.scrape_recipe_page(recipe.url))\n #binding.pry\n end\n end",
"def scrap_recipe\n recipe = RecipeScraper::Recipe.new @marmiton_url\n # convert recipe object to hash and m... | [
"0.7101345",
"0.6914661",
"0.6780243",
"0.66360384",
"0.66146755",
"0.6586129",
"0.65501857",
"0.6498371",
"0.64172715",
"0.6395194",
"0.634839",
"0.62956136",
"0.6275702",
"0.62426317",
"0.61983293",
"0.6165611",
"0.615139",
"0.6127436",
"0.6110336",
"0.6104298",
"0.60805494... | 0.0 | -1 |
:nodoc: A utility method for escaping HTML tag characters. This method is also aliased as h. puts html_escape('is a > 0 & a is a > 0 & a < 10? | def html_escape(s) # rubocop:disable Lint/DuplicateMethods
unwrapped_html_escape(s).html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_escape(s)\n s.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\")\n end",
"def html_escape(html)\n html.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] }\n end",
"def escape_html(html)\n html.to_s.gsub(/&/n, '&').gsub(/\\\"/n, '"... | [
"0.7907655",
"0.7850751",
"0.7720355",
"0.76722777",
"0.76233643",
"0.7612577",
"0.75817907",
"0.753323",
"0.73845303",
"0.72401065",
"0.7226192",
"0.7224788",
"0.7222203",
"0.7201686",
"0.7168123",
"0.7160892",
"0.7160892",
"0.7147957",
"0.7109266",
"0.71079224",
"0.70828307... | 0.73188645 | 9 |
A utility method for escaping HTML without affecting existing escaped entities. html_escape_once('1 "1 < 2 & 3" html_escape_once('<< Accept & Checkout') => "<< Accept & Checkout" | def html_escape_once(s)
ActiveSupport::Multibyte::Unicode.tidy_bytes(s.to_s).gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE).html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escape_html(html)\n html.to_s.gsub(/&/n, '&').gsub(/\\\"/n, '"').gsub(/>/n, '>').gsub(/</n, '<').gsub(/\\//, '/')\n end",
"def html_escape(s)\n s.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\")\n end",
"def html_escape(html)\n ... | [
"0.7659324",
"0.7431817",
"0.7410545",
"0.73798484",
"0.72654486",
"0.7259068",
"0.72082597",
"0.7204409",
"0.7168063",
"0.71091866",
"0.7028644",
"0.7019925",
"0.69891906",
"0.69772464",
"0.697479",
"0.6972722",
"0.6940584",
"0.6871477",
"0.6854818",
"0.6830356",
"0.6830356"... | 0.7269618 | 4 |
A utility method for escaping XML names of tags and names of attributes. xml_name_escape('1 "1___2___3" It follows the requirements of the specification: | def xml_name_escape(name)
name = name.to_s
return "" if name.blank?
return name if name.match?(SAFE_XML_TAG_NAME_REGEXP)
starting_char = name[0]
starting_char.gsub!(INVALID_TAG_NAME_START_REGEXP, TAG_NAME_REPLACEMENT_CHAR)
return starting_char if name.size == 1
following_chars = name[1..-1]
following_chars.gsub!(INVALID_TAG_NAME_FOLLOWING_REGEXP, TAG_NAME_REPLACEMENT_CHAR)
starting_char << following_chars
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml_escape(input); end",
"def escape_name(name)\n escaped_name = \"\"\n name.each_char do |char|\n if (char =~ /[-A-Za-z0-9_]/) != nil\n escaped_name += char\n else\n converted_char = TAG_NAME_MAP[char]\n if not converted_char\n msg = \"Bad charac... | [
"0.6893634",
"0.6816913",
"0.667457",
"0.6610737",
"0.62776357",
"0.6230387",
"0.6137847",
"0.6127742",
"0.6103563",
"0.59219015",
"0.5745236",
"0.57385474",
"0.56709146",
"0.5514325",
"0.5474733",
"0.5453317",
"0.53750974",
"0.5334463",
"0.52972114",
"0.51998824",
"0.519555"... | 0.8096469 | 0 |
ps:dynos [QTY] DEPRECATED: use `heroku ps:scale dynos=N` scale to QTY web processes if QTY is not specified, display the number of web processes currently running Example: $ heroku ps:dynos 3 Scaling dynos... done, now running 3 | def dynos
# deprecation notice added to v2.21.3 on 03/16/12
display("~ `heroku ps:dynos QTY` has been deprecated and replaced with `heroku ps:scale dynos=QTY`")
dynos = shift_argument
validate_arguments!
if dynos
action("Scaling dynos") do
new_dynos = api.put_dynos(app, dynos).body["dynos"]
status("now running #{new_dynos}")
end
else
app_data = api.get_app(app).body
if app_data["stack"] == "cedar"
raise(Heroku::Command::CommandFailed, "For Cedar apps, use `heroku ps`")
else
display("#{app} is running #{quantify("dyno", app_data["dynos"])}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale\n app = extract_app\n current_process = nil\n changes = args.inject({}) do |hash, process_amount|\n if process_amount =~ /^([a-zA-Z0-9_]+)([=+-]\\d+)$/\n hash[$1] = $2\n end\n hash\n end\n\n error \"Usage: heroku ps:scale web=2 worker+1\" if changes.empty?\n\n chan... | [
"0.71599984",
"0.6719939",
"0.6648999",
"0.65706456",
"0.64959514",
"0.63000065",
"0.6083706",
"0.60714066",
"0.60307807",
"0.5999182",
"0.59672076",
"0.5902492",
"0.5813543",
"0.57681733",
"0.5696201",
"0.562424",
"0.56133723",
"0.5515396",
"0.5492279",
"0.54920906",
"0.5470... | 0.85126865 | 0 |
ps:workers [QTY] DEPRECATED: use `heroku ps:scale workers=N` scale to QTY background processes if QTY is not specified, display the number of background processes currently running Example: $ heroku ps:dynos 3 Scaling workers... done, now running 3 | def workers
# deprecation notice added to v2.21.3 on 03/16/12
display("~ `heroku ps:workers QTY` has been deprecated and replaced with `heroku ps:scale workers=QTY`")
workers = shift_argument
validate_arguments!
if workers
action("Scaling workers") do
new_workers = api.put_workers(app, workers).body["workers"]
status("now running #{new_workers}")
end
else
app_data = api.get_app(app).body
if app_data["stack"] == "cedar"
raise(Heroku::Command::CommandFailed, "For Cedar apps, use `heroku ps`")
else
display("#{app} is running #{quantify("worker", app_data["workers"])}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale\n app = extract_app\n current_process = nil\n changes = args.inject({}) do |hash, process_amount|\n if process_amount =~ /^([a-zA-Z0-9_]+)([=+-]\\d+)$/\n hash[$1] = $2\n end\n hash\n end\n\n error \"Usage: heroku ps:scale web=2 worker+1\" if changes.empty?\n\n chan... | [
"0.75243735",
"0.7109988",
"0.7030956",
"0.68412995",
"0.6611573",
"0.65560544",
"0.6552528",
"0.6513395",
"0.64037216",
"0.6269072",
"0.6216943",
"0.62060666",
"0.6107998",
"0.60794353",
"0.60278094",
"0.5986876",
"0.5923211",
"0.59193754",
"0.58857477",
"0.5788496",
"0.5770... | 0.85246956 | 0 |
ps list dynos for an app Example: $ heroku ps === run: oneoff dyno run.1: up for 5m: `bash` === web: `bundle exec thin start p $PORT` web.1: created for 30s | def index
validate_arguments!
quota_resp = api.request(
:expects => [200, 404],
:method => :post,
:path => "/apps/#{app}/actions/get-quota",
:headers => {
"Accept" => "application/vnd.heroku+json; version=3.app-quotas",
"Content-Type" => "application/json"
}
)
if quota_resp.status = 200
quota = quota_resp.body
now = Time.now.getutc
quota_message = if quota["allow_until"]
"Free quota left:"
elsif quota["deny_until"]
"Free quota exhausted. Unidle available in:"
end
if quota_message
quota_timestamp = (quota["allow_until"] ? Time.parse(quota["allow_until"]).getutc : Time.parse(quota["deny_until"]).getutc)
time_left = time_remaining(Time.now.getutc, quota_timestamp)
display("#{quota_message} #{time_left}")
end
end
processes_resp = api.request(
:expects => 200,
:method => :get,
:path => "/apps/#{app}/dynos",
:headers => {
"Accept" => "application/vnd.heroku+json; version=3",
"Content-Type" => "application/json"
}
)
processes = processes_resp.body
processes_by_command = Hash.new {|hash,key| hash[key] = []}
processes.each do |process|
now = Time.now
type = process["type"]
elapsed = now - Time.iso8601(process['updated_at'])
since = time_ago(now - elapsed)
size = process["size"] || "1X"
if type == "run"
key = "run: one-off processes"
item = "%s (%s): %s %s: `%s`" % [ process["name"], size, process["state"], since, process["command"] ]
else
key = "#{type} (#{size}): `#{process["command"]}`"
item = "%s: %s %s" % [ process['name'], process['state'], since ]
end
processes_by_command[key] << item
end
extract_run_id = /\.(\d+).*:/
processes_by_command.keys.each do |key|
processes_by_command[key] = processes_by_command[key].sort do |x,y|
x.match(extract_run_id).captures.first.to_i <=> y.match(extract_run_id).captures.first.to_i
end
end
processes_by_command.keys.sort.each do |key|
styled_header(key)
styled_array(processes_by_command[key], :sort => false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dynos\n # deprecation notice added to v2.21.3 on 03/16/12\n display(\"~ `heroku ps:dynos QTY` has been deprecated and replaced with `heroku ps:scale dynos=QTY`\")\n\n dynos = shift_argument\n validate_arguments!\n\n if dynos\n action(\"Scaling dynos\") do\n new_dynos = api.put_dynos(... | [
"0.73928475",
"0.6466832",
"0.6284456",
"0.62837636",
"0.62009585",
"0.61865413",
"0.618166",
"0.5909264",
"0.5864595",
"0.582588",
"0.57914877",
"0.5757039",
"0.574483",
"0.5734405",
"0.57155836",
"0.57106364",
"0.57038933",
"0.56999964",
"0.56834555",
"0.5605254",
"0.556620... | 0.5821393 | 10 |
ps:restart [DYNO] restart an app dyno if DYNO is not specified, restarts all dynos on the app Examples: $ heroku ps:restart web.1 Restarting web.1 dyno... done $ heroku ps:restart web Restarting web dyno... done $ heroku ps:restart Restarting dynos... done | def restart
dyno = shift_argument
validate_arguments!
message, options = case dyno
when NilClass
["Restarting dynos", {}]
when /.+\..+/
ps = args.first
["Restarting #{ps} dyno", { :ps => ps }]
else
type = args.first
["Restarting #{type} dynos", { :type => type }]
end
action(message) do
api.post_ps_restart(app, options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart\n app = extract_app\n\n opts = case args.first\n when NilClass then\n display \"Restarting processes... \", false\n {}\n when /.+\\..+/\n ps = args.first\n display \"Restarting #{ps} process... \", false\n { :ps => ps }\n else\n type = args.first\n disp... | [
"0.7808233",
"0.70183223",
"0.6879686",
"0.6516336",
"0.6363924",
"0.60094196",
"0.58866405",
"0.58373404",
"0.5832172",
"0.5785113",
"0.5772512",
"0.57717407",
"0.5747413",
"0.5747413",
"0.5747413",
"0.57333165",
"0.5728457",
"0.57136476",
"0.57011676",
"0.56873596",
"0.5675... | 0.8166115 | 0 |
ps:scale [DYNO1=AMOUNT1 [DYNO2=AMOUNT2 ...]] scale dynos by the given amount appending a size (eg. web=2:2X) allows simultaneous scaling and resizing omitting any arguments will display the app's current dyno formation, in a format suitable for passing back into ps:scale Examples: $ heroku ps:scale web=3:2X worker+1 Scaling dynos... done, now running web at 3:2X, worker at 1:1X. $ heroku ps:scale web=3:2X worker=1:1X | def scale
requires_preauth
changes = args.map do |arg|
if change = arg.scan(/^([a-zA-Z0-9_]+)([=+-]\d+)(?::([\w-]+))?$/).first
formation, quantity, size = change
quantity = quantity[1..-1].to_i if quantity[0] == "="
{ "type" => formation, "quantity" => quantity, "size" => size}
end
end.compact
if changes.empty?
display_dyno_formation(get_formation)
else
action("Scaling dynos") do
new_scales = scale_dynos(get_formation, changes)
.map {|p| "#{p["type"]} at #{p["quantity"]}:#{p["size"]}" }
status("now running " + new_scales.join(", ") + ".")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale\n app = extract_app\n current_process = nil\n changes = args.inject({}) do |hash, process_amount|\n if process_amount =~ /^([a-zA-Z0-9_]+)([=+-]\\d+)$/\n hash[$1] = $2\n end\n hash\n end\n\n error \"Usage: heroku ps:scale web=2 worker+1\" if changes.empty?\n\n chan... | [
"0.84337085",
"0.8178167",
"0.7227012",
"0.61763364",
"0.6095144",
"0.60669017",
"0.60046065",
"0.5976218",
"0.5916795",
"0.5891229",
"0.58905953",
"0.58272845",
"0.5774898",
"0.57496274",
"0.5703743",
"0.56961936",
"0.5634388",
"0.56343645",
"0.5618801",
"0.558516",
"0.55707... | 0.7968315 | 2 |
ps:stop DYNOS stop an app dyno Examples: $ heroku stop run.3 Stopping run.3 dyno... done $ heroku stop run Stopping run dynos... done | def stop
dyno = shift_argument
validate_arguments!
message, options = case dyno
when NilClass
error("Usage: heroku ps:stop DYNO\nMust specify DYNO to stop.")
when /.+\..+/
ps = args.first
["Stopping #{ps} dyno", { :ps => ps }]
else
type = args.first
["Stopping #{type} dynos", { :type => type }]
end
action(message) do
api.post_ps_stop(app, options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop\n app = extract_app\n opt =\n if (args.first =~ /.+\\..+/)\n ps = args.first\n display \"Stopping #{ps} process... \", false\n {:ps => ps}\n elsif args.first\n type = args.first\n display \"Stopping #{type} processes... \", false\n {:type => type}\... | [
"0.7689535",
"0.6727713",
"0.66109985",
"0.6512392",
"0.64470345",
"0.6379886",
"0.6272218",
"0.6232683",
"0.6217167",
"0.61890554",
"0.61530733",
"0.60952646",
"0.6041457",
"0.60395795",
"0.6026322",
"0.60040057",
"0.5992933",
"0.59891784",
"0.5984854",
"0.59835947",
"0.5983... | 0.8608918 | 0 |
ps:type [TYPE | DYNO=TYPE [DYNO=TYPE ...]] manage dyno types called with no arguments shows the current dyno type called with one argument sets the type where type is one of free|hobby|standard1x|standard2x|performance called with 1..n DYNO=TYPE arguments sets the type per dyno | def type
requires_preauth
app
formation = get_formation
changes = if args.any?{|arg| arg =~ /=/}
args.map do |arg|
if arg =~ /^([a-zA-Z0-9_]+)=([\w-]+)$/
type, new_size = $1, $2
current_p = formation.find{|f| f["type"] == type}
if current_p.nil?
error("Type '#{type}' not found in process formation.")
end
p = current_p.clone
p["size"] = new_size
p
end
end.compact
elsif args.any?
size = shift_argument.downcase
validate_arguments!
formation.map{|p| p["size"] = size; p}
end
scale_dynos(formation, changes) if changes
display_dyno_type_and_costs(get_formation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dynos\n # deprecation notice added to v2.21.3 on 03/16/12\n display(\"~ `heroku ps:dynos QTY` has been deprecated and replaced with `heroku ps:scale dynos=QTY`\")\n\n dynos = shift_argument\n validate_arguments!\n\n if dynos\n action(\"Scaling dynos\") do\n new_dynos = api.put_dynos(... | [
"0.6452378",
"0.6076077",
"0.5816268",
"0.58134836",
"0.562134",
"0.5597749",
"0.55790997",
"0.5565822",
"0.55205387",
"0.5448634",
"0.54452974",
"0.5393754",
"0.5387079",
"0.53657347",
"0.5345301",
"0.5333334",
"0.5332284",
"0.53318477",
"0.5329026",
"0.5329026",
"0.5295395"... | 0.6811966 | 0 |
Use for_model instead of instatiating a record directly. | def initialize(model_class)
@model_class = model_class
@records = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_record(record)\n end",
"def initialize_with_record(record)\n inst = self.new\n inst.send(:_record=, record)\n inst.send(:_id=, record.id)\n inst\n end",
"def build_new_record\n @record = record_class.new\n end",
"def build_new_record\n @reco... | [
"0.69229025",
"0.68515086",
"0.6688589",
"0.6688589",
"0.66503125",
"0.6616689",
"0.65591997",
"0.6530984",
"0.6530438",
"0.64464325",
"0.63948905",
"0.6371378",
"0.6371378",
"0.6361553",
"0.6353687",
"0.6325439",
"0.62255085",
"0.62229866",
"0.6217759",
"0.61888677",
"0.6180... | 0.5784329 | 80 |
Entry method for building records. Delegates to build_records after remember_depth. | def populate(amount, options = {}, &block)
self.class.remember_depth do
build_records(Populator.interpret_value(amount), options[:per_query] || DEFAULT_RECORDS_PER_QUERY, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_new_record\n @record = record_class.new\n end",
"def build_new_record\n @record = record_class.new\n end",
"def build_records(amount, per_query, &block)\n amount.times do\n record = Record.new(@model_class, last_id_in_database + @records.size + 1)\n @records... | [
"0.6380753",
"0.6380753",
"0.6206229",
"0.6184977",
"0.608119",
"0.583847",
"0.58199894",
"0.57396543",
"0.56746197",
"0.5632309",
"0.5629587",
"0.5629191",
"0.5603841",
"0.5567505",
"0.55652845",
"0.55078983",
"0.54793346",
"0.5443821",
"0.5433214",
"0.53924257",
"0.53747195... | 0.0 | -1 |
Builds multiple Populator::Record instances and calls save_records them when :per_query limit option is reached. | def build_records(amount, per_query, &block)
amount.times do
record = Record.new(@model_class, last_id_in_database + @records.size + 1)
@records << record
block.call(record) if block
save_records if @records.size >= per_query
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def records_for_populate(options = {})\n records_base(options)\n end",
"def batch_new\n @records = Array.new(BATCH_SIZE) { record_class.new }\n end",
"def populate(amount, options = {}, &block)\n self.class.remember_depth do\n build_records(Populator.interpret_value(amount), options... | [
"0.6347587",
"0.6280318",
"0.6273725",
"0.61053175",
"0.6043005",
"0.60100335",
"0.6005123",
"0.58896416",
"0.58104354",
"0.56245124",
"0.5624205",
"0.5618063",
"0.5584915",
"0.5576702",
"0.5422031",
"0.5382576",
"0.5377016",
"0.5369153",
"0.5334501",
"0.5328362",
"0.5290196"... | 0.7806644 | 0 |
Saves the records to the database by calling populate on the current database adapter. | def save_records
unless @records.empty?
@model_class.connection.populate(@model_class.quoted_table_name, columns_sql, rows_sql_arr, "#{@model_class.name} Populate")
@last_id_in_database = @records.last.id
@records.clear
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def records_for_populate(options = {})\n records_base(options)\n end",
"def save; record.save; end",
"def seed_db\n @records.each do |row|\n $db.execute(\n \"INSERT INTO records\n (report_type, patient_name, service_from, service_thru, paid_date, hic_num, gross_reimb, cash_ded... | [
"0.6028996",
"0.5786327",
"0.5729236",
"0.5583682",
"0.5581483",
"0.5580849",
"0.5558667",
"0.55084544",
"0.5504932",
"0.55004543",
"0.55002517",
"0.5483511",
"0.5482774",
"0.5481345",
"0.54726607",
"0.5472178",
"0.54720837",
"0.5460149",
"0.5454292",
"0.5440043",
"0.5440043"... | 0.73466486 | 0 |
Splat argument: When we don't know how many arguments there are about to be, arguments preceded by a . | def whats_up (greeting, *friends)
friends.each {|friend| puts "#{greeting}, #{friend}."}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __splat(x) end",
"def splat_mth(*mult_arg)\n p mult_arg #it's array :) !\n p mult_arg.class\n p mult_arg.object_id\n mult_arg.map {|arg| }\n end",
"def not_just_splat(x, *args, y)\n puts x\n puts y\n puts args.inspect\nend",
"def parse_splat_args\n unless self.empty?\n args = self#.fla... | [
"0.8149754",
"0.75178397",
"0.72043073",
"0.7155663",
"0.70270354",
"0.6963802",
"0.6958345",
"0.6917654",
"0.68903",
"0.6846986",
"0.6783576",
"0.6749449",
"0.67411035",
"0.6726766",
"0.67259175",
"0.65101284",
"0.6490654",
"0.6470298",
"0.6468138",
"0.639402",
"0.6375808",
... | 0.0 | -1 |
Methods names can end with ? , !(this has dangerous side effects though) | def can_divide_by?(number)
return false if number.zero?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def despined?(*)\n end",
"def hungry?\n# Method names can end with \"?\".\n# Usually, we do this only if the method\n# returns true or false, like this:\n@stuff_in_belly <= 2\nend",
"def bang_method?\n method_name.to_s.end_with?('!')\n end",
"def name_safe?; end",
"def respond_to_missing?(me... | [
"0.7289983",
"0.6941463",
"0.68825996",
"0.68788123",
"0.6870282",
"0.67922676",
"0.6762275",
"0.67344606",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.6635433",
"0.66312814"... | 0.0 | -1 |
Factorial Method!!!! and Methods can have default argumenents | def factorial(n)
n==0? 1 : n*factorial(n-1) #if n equals to 0 return 1 otherwise return n*....
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factorial(n)\nend",
"def factorial\n (1..self).inject(:*)\n end",
"def factorial_with_default(n = 4)\n\tn == 0? 1: n * factorial_with_default(n - 1)\nend",
"def factorial(int)\n (1..self).reduce(:*) || 1\nend",
"def factorials_rec(num)\n \nend",
"def factorials_rec(num)\n \nend",
"def factor... | [
"0.7867671",
"0.75926185",
"0.7582463",
"0.7560864",
"0.7535442",
"0.7535442",
"0.7518699",
"0.75105613",
"0.74762005",
"0.74726427",
"0.74584305",
"0.7455591",
"0.74438846",
"0.7437645",
"0.74359405",
"0.74328685",
"0.74316776",
"0.7431082",
"0.7431082",
"0.741955",
"0.74094... | 0.73814243 | 26 |
SPLAT prefixes paramater inside method definition...can apply to middle paramater | def max(one_param, *numbers, another)
#Variable length parameters passed in become an array
numbers.max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefix=(_arg0); end",
"def prefixes; end",
"def prefixes; end",
"def name_prefix=(_arg0); end",
"def prefix(argument_1, argument_2)\n print argument_1\n print argument_2\nend",
"def _prefixes; end",
"def prefix=(_); end",
"def local_prefixes; end",
"def pha; sparam(3); end",
"def prefix; ... | [
"0.7125027",
"0.67845947",
"0.67845947",
"0.66851884",
"0.65727156",
"0.65386015",
"0.6379095",
"0.6301147",
"0.62303406",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6226857",
"0.6183735",
"0.6061737... | 0.0 | -1 |
output =>1 Explicit way to configure a block in a methodUse call method to call a blockway to configure a block in a method Use & in front of the last paramater | def two_times_explicit (&i_am_a_block)
return "No block" if i_am_a_block.nil?
i_am_a_block.call
i_am_a_block.call
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method &block, a\r\n\t1\r\nend",
"def my_method(&my_block)\n\n puts \"hello method\"\n\n my_block.call\n\n return my_block\n\nend",
"def call_block(&block)\n block.call\nend",
"def callBlock\n yield\n yield\nend",
"def my_method(&my_block)\n puts 'from my_method : before calling call met... | [
"0.7057743",
"0.6989624",
"0.69814533",
"0.693251",
"0.69140464",
"0.69092166",
"0.69092166",
"0.6906271",
"0.69022655",
"0.68904406",
"0.6887485",
"0.6871183",
"0.6868464",
"0.6868368",
"0.68581504",
"0.6840222",
"0.6697308",
"0.66582584",
"0.6637301",
"0.6610386",
"0.660928... | 0.0 | -1 |
=> Hello => Hello Implicit way to configure a block in a methodUse yield to call block | def two_times_implicit
return "No block" unless block_given?
yield
yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_block \n yield('hello', 99) \nend",
"def call_block \n yield('hello', 99) \nend",
"def call_block\n yield('hello', 99)\nend",
"def call_block\n yield('hello', 99)\nend",
"def call_block\n yield('hello', 99)\nend",
"def hello(&block)\n puts block\n block.call\nend",
"def hello(&block... | [
"0.83039707",
"0.83039707",
"0.8232341",
"0.8232341",
"0.8232341",
"0.813319",
"0.80806017",
"0.8061794",
"0.7985368",
"0.7985368",
"0.7903087",
"0.7893397",
"0.7860689",
"0.78492445",
"0.7847974",
"0.7779097",
"0.7774063",
"0.7774063",
"0.77500445",
"0.77141297",
"0.76782125... | 0.0 | -1 |
=> No block method that capitalizes a word | def capitalize(string)
puts "#{string[0].upcase}#{string[1..-1]}" #"#{string.capitalize}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capitalize!() end",
"def capitalize() end",
"def capitalize(word)\n\nend",
"def capitalize_each_word(phrase)\r\n\r\nend",
"def capitalized\n name.titleize.capitalize\n end",
"def capitalize\n \"Foo\"\n end",
"def snake_case(name); end",
"def capitalize(input); end",
"def downcase!() end"... | [
"0.78011245",
"0.77305764",
"0.74313015",
"0.7295321",
"0.72289777",
"0.71878475",
"0.7178844",
"0.71226275",
"0.70924824",
"0.70476234",
"0.70318043",
"0.7026399",
"0.7023131",
"0.7005624",
"0.69891024",
"0.698248",
"0.698248",
"0.6948854",
"0.6936364",
"0.6930801",
"0.69057... | 0.0 | -1 |
used to validate the information coming in from the form, if the validations pass, it inserts the record to the database and redirect the user to another page, else display the error messages telling the user why the form failed. | def create
@item = Item.new(item_params)
if @item.save
redirect_to items_path
else
render action: "new"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_and_save(success_message, failure_template)\n unless @form.valid?\n render failure_template\n return\n end\n\n @form.save\n\n redirect_to index_path, :notice => success_message\n end",
"def create\n #the params method = the content coming from the form\n\n #this creates ... | [
"0.7159191",
"0.6354729",
"0.6352355",
"0.63414425",
"0.62699723",
"0.6123094",
"0.60799",
"0.6058346",
"0.6008327",
"0.60071665",
"0.599789",
"0.59938365",
"0.5983699",
"0.59812415",
"0.597655",
"0.59649825",
"0.5943817",
"0.5934695",
"0.59044546",
"0.5898384",
"0.5882348",
... | 0.0 | -1 |
is used to display a specific resource(data) along with the associated resources(data) | def show
@item = Item.find(params[:id])
@category = Category.find(@item.category_id)
@review = Review.new
@cart_line_item = CartLineItem.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_for_resource(identifier)\n styled_header(\"Resource Info\")\n\n resource = resolve_addon!(identifier)\n\n styled_hash({\n 'Name' => resource['name'],\n 'Plan' => resource['plan']['name'],\n 'Billing App' => resource['app']['name'],\n '... | [
"0.73300344",
"0.7196806",
"0.70932996",
"0.70901185",
"0.68900746",
"0.6803851",
"0.6753969",
"0.67305934",
"0.6683125",
"0.66748",
"0.66573083",
"0.66536033",
"0.66448855",
"0.66190106",
"0.65899",
"0.65740675",
"0.6519679",
"0.6482815",
"0.64824617",
"0.64824617",
"0.64624... | 0.0 | -1 |
strong parameters used to prevent from mass assignment web attack | def item_params
params[:item].permit(:name,:price,:stock,:description,:category_id,:cod_available, :release_datetime, :image_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def per... | [
"0.712205",
"0.7113655",
"0.70037556",
"0.6983433",
"0.6875035",
"0.6853846",
"0.6761016",
"0.67413783",
"0.67345095",
"0.6715525",
"0.6636251",
"0.66338116",
"0.6627648",
"0.6618234",
"0.6609441",
"0.6597091",
"0.65825504",
"0.6572082",
"0.65184814",
"0.65035963",
"0.6479663... | 0.0 | -1 |
in the array. The array will never be empty and the numbers will always be positive integers. given an array of integer calculate the average of all numbers numbers are all > 0 iterate over array , sum them and divide by the size of the array | def average(array)
return 0 if array.empty?
array.sum / array.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average(array)\n sum = 0\n\n if array.empty? || array.index {|x| x > 0} == 1\n puts \"Your array may be empty or contain negative intergers\"\n else\n array.each do |int|\n sum +=int\n end\n sum /= array.size\n end\nend",
"def average(array)\n if array.size <= 0\n return 0.0\n en... | [
"0.8515971",
"0.80971307",
"0.8026708",
"0.7913091",
"0.78915274",
"0.7843364",
"0.78430045",
"0.78333044",
"0.7821757",
"0.78204864",
"0.776393",
"0.775869",
"0.7738436",
"0.77343947",
"0.7728443",
"0.7726349",
"0.77074075",
"0.7706711",
"0.77022445",
"0.76725954",
"0.763962... | 0.8112079 | 1 |
The average method is defined on line 10, it takes a parameter, array. Considering its name, we can assume the method aims to work with an array. It creates a new scope for the array parameter, which is now accessible as a local variable inside the method. On line 12, array.sum is divided by array.size array.sum is a method that sums every number in an array of integers. It returns that sum as an integer array.size is a method that counts the items in an array an returns the result as an integer. Considering the division operator, we must make sure the divisor is > 0. The average method returns the result of the operation on line 12, because in ruby, a method always returns the result of the last line inside the method definition. When invoked, the method uses the scope defined by the method definition. It takes the array used as param to perform the average operation and return it. It's a non destructive method as it does not mutate the caller. | def average(array)
array.sum / array.size.to_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average(array)\n array.sum / array.length\nend",
"def average(array)\n average = array.sum / array.count\nend",
"def average(array)\n return sum(array)/array.length \nend",
"def average(arr)\n arr.sum / arr.length\nend",
"def average(arr)\n arr.sum / arr.length\nend",
"def average(arr)\n arr.s... | [
"0.83735883",
"0.8323118",
"0.8275525",
"0.82207704",
"0.82207704",
"0.82207704",
"0.82149005",
"0.81618404",
"0.814547",
"0.81379557",
"0.81353235",
"0.81244266",
"0.8108425",
"0.8108425",
"0.81068444",
"0.8092033",
"0.80911946",
"0.8087398",
"0.8066428",
"0.8054799",
"0.804... | 0.803653 | 22 |
go on for all possible path | def follow_rules_for(configuration, character)
rules_for(configuration, character).map {|rule| rule.follow(configuration)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(path, type); end",
"def initial_paths; end",
"def explore\n while (target = search_unknown)\n # puts \"PATH: #{target.inspect}\"\n target.each do |dir|\n output = @vm.run(input: [dir]).first\n case output\n when 0 # droid hits wall\n @map.set(@dr... | [
"0.6163916",
"0.60427177",
"0.6012938",
"0.58966655",
"0.58792925",
"0.5869507",
"0.5804902",
"0.5804902",
"0.5804902",
"0.5804902",
"0.5804902",
"0.5674536",
"0.566665",
"0.5666097",
"0.56572413",
"0.56527025",
"0.5649057",
"0.56365585",
"0.56361127",
"0.56250316",
"0.560485... | 0.0 | -1 |
find all posiible rules | def rules_for(configuration, character)
# note that it is select (filter), not detect (find)
rules.select {|rule| rule.applies_to?(configuration, character)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rules; end",
"def rules; end",
"def rules; end",
"def rules; end",
"def rules; end",
"def rules; end",
"def rules; end",
"def rules_by_name; end",
"def rules\n @rules.map{|r| [r.name, r.rule]}.to_h\n end",
"def rules\n @rules ||= []\n end",
"def rules\n @rules ||= []\... | [
"0.725512",
"0.725512",
"0.725512",
"0.725512",
"0.725512",
"0.725512",
"0.725512",
"0.6940835",
"0.66957676",
"0.6689045",
"0.6689045",
"0.66325474",
"0.66325474",
"0.66325474",
"0.66182363",
"0.65997565",
"0.6530327",
"0.6530327",
"0.64696985",
"0.6368541",
"0.6315894",
"... | 0.6318903 | 20 |
Use callbacks to share common setup or constraints between actions. | def set_resource
@resource = Resource.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
GET /families GET /families.xml | def index
@families = Family.paginate(:per_page => 5, :page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @families }
format.js # index.js.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_families\n http_get(:uri=>\"/plugins/families\", :fields=>x_cookie)\n end",
"def index\n @families = Family.all\n end",
"def index\n @families = Family.all\n end",
"def index\n @families = Family.all\n end",
"def index\r\n @families = Family.all\r\n end",
"def index\n ... | [
"0.69550765",
"0.67924446",
"0.67924446",
"0.67924446",
"0.669971",
"0.6692907",
"0.65623444",
"0.6510627",
"0.6505992",
"0.6369165",
"0.63567764",
"0.62196285",
"0.61817163",
"0.6140663",
"0.6099821",
"0.6084856",
"0.6009684",
"0.59886146",
"0.5938279",
"0.5931289",
"0.58910... | 0.6082653 | 16 |
GET /families/1 GET /families/1.xml | def show
@family ||= Family.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @family }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @families = Family.all\n end",
"def index\n @families = Family.all\n end",
"def index\n @families = Family.all\n end",
"def index\n @index_action = true\n @families = Family.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { re... | [
"0.66391575",
"0.66391575",
"0.66391575",
"0.6602366",
"0.6556731",
"0.6552282",
"0.6541676",
"0.6533416",
"0.639149",
"0.63565314",
"0.63284785",
"0.6238541",
"0.6151105",
"0.60792756",
"0.60305876",
"0.6013372",
"0.6001987",
"0.5892585",
"0.5880879",
"0.5880842",
"0.5808232... | 0.6711528 | 0 |
GET /families/new GET /families/new.xml | def new
@family = Family.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @family }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @family = Family.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @family }\n end\n end",
"def new\n @family_member = FamilyMember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fami... | [
"0.69727224",
"0.6833814",
"0.66612226",
"0.6651011",
"0.6544284",
"0.65422297",
"0.64651847",
"0.6417502",
"0.6383113",
"0.637568",
"0.6369943",
"0.63574874",
"0.6318974",
"0.631751",
"0.631751",
"0.6314131",
"0.6285898",
"0.6262994",
"0.6224628",
"0.62236106",
"0.6202178",
... | 0.7474895 | 0 |
POST /families POST /families.xml | def create
@family = Family.new(params[:family])
respond_to do |format|
if @family.save
flash[:notice] = 'Family was successfully created.'
format.html { redirect_to(@family) }
format.xml { render :xml => @family, :status => :created, :location => @family }
else
format.html { render :action => "new" }
format.xml { render :xml => @family.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @family = Family.new(params[:family])\n\n respond_to do |format|\n if @family.save\n flash[:notice] = 'Family was successfully created.'\n format.html { redirect_to(@family) }\n format.xml { render :xml => @family, :status => :created, :location => @family }\n els... | [
"0.60733354",
"0.6072399",
"0.58886254",
"0.58508116",
"0.5639434",
"0.5605569",
"0.5539265",
"0.5530745",
"0.5517634",
"0.5512985",
"0.5511537",
"0.54106337",
"0.53630924",
"0.5349675",
"0.534874",
"0.5343693",
"0.5343693",
"0.5343693",
"0.5334595",
"0.53041863",
"0.5255488"... | 0.60738903 | 0 |
PUT /families/1 PUT /families/1.xml | def update
@family ||= Family.find(params[:id])
respond_to do |format|
if @family.update_attributes(params[:family])
flash[:notice] = 'Family was successfully updated.'
format.html { redirect_to(@family) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @family.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @family = Family.find(params[:id])\n\n respond_to do |format|\n if @family.update_attributes(params[:family])\n flash[:notice] = \"Family #{@family.business_name} was successfully updated.\"\n format.html { redirect_to(@family) }\n format.xml { head :ok }\n else\n... | [
"0.61421263",
"0.59061885",
"0.5898075",
"0.58918715",
"0.58918715",
"0.5859121",
"0.5848183",
"0.58446854",
"0.58446854",
"0.5784108",
"0.5741172",
"0.5739658",
"0.57295436",
"0.56958514",
"0.56777835",
"0.5633969",
"0.56147975",
"0.5611409",
"0.558681",
"0.55664265",
"0.551... | 0.621874 | 0 |
DELETE /families/1 DELETE /families/1.xml | def destroy
@family ||= Family.find(params[:id])
@family.destroy
respond_to do |format|
format.html { redirect_to(families_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n# @family = Family.find(params[:id])\n# @family.destroy\n#\n# respond_to do |format|\n# format.html { redirect_to(families_url) }\n# format.xml { head :ok }\n# end\n end",
"def destroy\n @family = Family.find(params[:id])\n @family.destroy\n\n respond_to do |format|\... | [
"0.6905691",
"0.6569807",
"0.64943194",
"0.64396614",
"0.6367237",
"0.6339901",
"0.6333035",
"0.6294966",
"0.6293467",
"0.6292798",
"0.6276343",
"0.62606055",
"0.62497",
"0.6212668",
"0.6197228",
"0.617815",
"0.6145188",
"0.6105732",
"0.61008066",
"0.60920554",
"0.6083808",
... | 0.72651905 | 0 |
GET /contact_stores GET /contact_stores.json | def index
@contact_stores = ContactStore.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def index\n @stores = @commerce.stores\n end",
"def index\n @admin_stores = Admin::Store.all\n\n respond_to do |format|\n format.h... | [
"0.6989113",
"0.66856945",
"0.659619",
"0.6567925",
"0.65228313",
"0.64396065",
"0.6334135",
"0.6324183",
"0.6324067",
"0.63140893",
"0.62966347",
"0.62866545",
"0.6275036",
"0.6259201",
"0.6256949",
"0.6251011",
"0.6251011",
"0.62449163",
"0.6203063",
"0.6203063",
"0.6203063... | 0.73882145 | 0 |
GET /contact_stores/1 GET /contact_stores/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @contact_stores = ContactStore.all\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @admin_stores = Admin::Store.all\n\n respond_to do |format|\n ... | [
"0.7137191",
"0.692844",
"0.68865675",
"0.65734345",
"0.6569214",
"0.6569214",
"0.6569214",
"0.6569214",
"0.65103877",
"0.6505333",
"0.6484428",
"0.6450121",
"0.6430919",
"0.6428235",
"0.6423595",
"0.6364399",
"0.6364399",
"0.633674",
"0.63311",
"0.632712",
"0.6327116",
"0.... | 0.0 | -1 |
POST /contact_stores POST /contact_stores.json | def create
@contact_store = ContactStore.new(contact_store_params)
respond_to do |format|
if @contact_store.save
format.html { redirect_to @contact_store, notice: 'Contact store was successfully created.' }
format.json { render :show, status: :created, location: @contact_store }
else
format.html { render :new }
format.json { render json: @contact_store.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @cakestore = Cakestore.new(cakestore_params)\n\n respond_to do |format|\n if @cakestore.save\n format.html { redirect_to @cakestore, notice: 'Cakestore was successfully created.' }\n format.json { render :show, status: :created, location: @cakestore }\n else\n form... | [
"0.6434339",
"0.6414449",
"0.636926",
"0.6366385",
"0.6327758",
"0.6300838",
"0.6299978",
"0.6299978",
"0.6260686",
"0.6242875",
"0.6241692",
"0.6225512",
"0.62102145",
"0.62017196",
"0.617447",
"0.61275536",
"0.610702",
"0.6085593",
"0.6042473",
"0.60225576",
"0.60078377",
... | 0.73613364 | 0 |
PATCH/PUT /contact_stores/1 PATCH/PUT /contact_stores/1.json | def update
respond_to do |format|
if @contact_store.update(contact_store_params)
format.html { redirect_to @contact_store, notice: 'Contact store was successfully updated.' }
format.json { render :show, status: :ok, location: @contact_store }
else
format.html { render :edit }
format.json { render json: @contact_store.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @store.update(store_params)\n format.html { redirect_to [:phone, @store], notice: 'Store was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sto... | [
"0.63273424",
"0.6290714",
"0.62886846",
"0.62306434",
"0.6179664",
"0.6154706",
"0.6137701",
"0.6125984",
"0.6125984",
"0.6125984",
"0.6125984",
"0.60858524",
"0.6080788",
"0.6072238",
"0.6065387",
"0.6054712",
"0.60390294",
"0.60240775",
"0.6008811",
"0.5950208",
"0.5942085... | 0.69166386 | 0 |
DELETE /contact_stores/1 DELETE /contact_stores/1.json | def destroy
@contact_store.destroy
respond_to do |format|
format.html { redirect_to contact_stores_url, notice: 'Contact store was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cakestore.destroy\n respond_to do |format|\n format.html { redirect_to cakestores_url, notice: 'Cakestore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store.destroy\n respond_to do |format|\n format.html { redirect_t... | [
"0.7212821",
"0.7168814",
"0.7154229",
"0.7154229",
"0.7154229",
"0.7154229",
"0.71260476",
"0.71260476",
"0.71260476",
"0.71260476",
"0.71050686",
"0.70846194",
"0.70506907",
"0.7039082",
"0.70173824",
"0.7004824",
"0.69737554",
"0.6938925",
"0.6929737",
"0.6913436",
"0.6903... | 0.76097816 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_contact_store
@contact_store = ContactStore.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def contact_store_params
params.require(:contact_store).permit(:name, :email, :tel, :message, :date_time, :nickname, :utf8, :authenticity_token, :commit)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
GET /tickets GET /tickets.json | def index
@sprint = params[:sprint].presence || Sprint.current!
@tickets = Ticket.for_sprint(@sprint).by_created_at_desc
@tickets = @tickets.for_project(params[:project]) if params[:project].present?
@tickets = @tickets.for_user(params[:user]) if params[:user].present?
@tickets = @tickets.search_name(params[:description]) if params[:description].present?
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tickets }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetTickets params = {}\n\n params = params.merge(path: 'tickets.json')\n APICall(params)\n\n end",
"def getUserTickets\n @user = User.find(params[:id])\n render json: @user.tickets\n end",
"def index\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # ind... | [
"0.812432",
"0.7915244",
"0.76279",
"0.76198745",
"0.7595226",
"0.7439142",
"0.7317611",
"0.7301728",
"0.73013884",
"0.7277282",
"0.7274308",
"0.7272302",
"0.7221539",
"0.71765393",
"0.7116907",
"0.7116907",
"0.7116907",
"0.7116907",
"0.7116907",
"0.7116907",
"0.70597136",
... | 0.7173541 | 14 |
GET /tickets/1 GET /tickets/1.json | def show
@ticket = Ticket.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @ticket }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetTicket id\n\n APICall(path: \"tickets/#{id}.json\")\n\n end",
"def GetTickets params = {}\n\n params = params.merge(path: 'tickets.json')\n APICall(params)\n\n end",
"def getUserTickets\n @user = User.find(params[:id])\n render json: @user.tickets\n end",
"def sho... | [
"0.7985267",
"0.7595772",
"0.7489845",
"0.7379687",
"0.7338592",
"0.7323581",
"0.72120136",
"0.7165008",
"0.7152847",
"0.71043557",
"0.69847274",
"0.69769794",
"0.6925518",
"0.6924985",
"0.6895925",
"0.68454385",
"0.6820753",
"0.6820753",
"0.6820753",
"0.6820753",
"0.6820753"... | 0.7233424 | 9 |
GET /tickets/new GET /tickets/new.json | def new
@ticket = Ticket.new(sprint: Sprint.current!)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @ticket }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n... | [
"0.80568236",
"0.80568236",
"0.80568236",
"0.80568236",
"0.7853418",
"0.7546344",
"0.7528544",
"0.7509112",
"0.74955624",
"0.7435305",
"0.7317495",
"0.7317495",
"0.73148",
"0.73072803",
"0.72983253",
"0.7287808",
"0.7203171",
"0.7203171",
"0.7203171",
"0.7203171",
"0.7157161"... | 0.7991255 | 4 |
POST /tickets POST /tickets.json | def create
@ticket = Ticket.new(params[:ticket])
respond_to do |format|
if @ticket.save
format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }
format.json { render json: @ticket, status: :created, location: @ticket }
else
format.html { render action: 'new' }
format.json { render json: @ticket.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateTicket params = {}\n\n APICall(path: 'tickets.json',method: 'POST',payload: {ticket: params}.to_json)\n \n end",
"def create\n @ticket = Ticket.new(ticket_params)\n respond_to do |format|\n if @ticket.save\n format.html { render json: @ticket.to_json }\n form... | [
"0.78799874",
"0.72312945",
"0.70262116",
"0.7003522",
"0.69879574",
"0.6953623",
"0.6908814",
"0.6908814",
"0.6908814",
"0.6908814",
"0.6908253",
"0.6900516",
"0.6867757",
"0.68270665",
"0.68270665",
"0.6817758",
"0.6763566",
"0.67327195",
"0.6725813",
"0.67150265",
"0.66922... | 0.70381755 | 2 |
PUT /tickets/1 PUT /tickets/1.json | def update
@ticket = Ticket.find(params[:id])
respond_to do |format|
if @ticket.update_attributes(params[:ticket])
format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @ticket.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @ticket.update_attributes(params[:ticket])\n\n respond_with(@story, @ticket)\n end",
"def update\n @ticket = @event.tickets.find(params[:id])\n r... | [
"0.7889341",
"0.69945663",
"0.6989293",
"0.6935721",
"0.6854655",
"0.68403566",
"0.68403566",
"0.68403566",
"0.68403566",
"0.68403566",
"0.68029016",
"0.6772724",
"0.67701954",
"0.6749982",
"0.6736265",
"0.6736265",
"0.67348725",
"0.6734714",
"0.6734714",
"0.6734714",
"0.6734... | 0.6851879 | 5 |
DELETE /tickets/1 DELETE /tickets/1.json | def destroy
@ticket = Ticket.find(params[:id])
@ticket.destroy
if request.xhr?
render nothing: true
else
respond_to do |format|
format.html { redirect_to tickets_url(params.except(:action, :controller, :_method, :authenticity_token, :utf8, :id)) }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteTicket id\n \n APICall(path: \"tickets/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @ticket.destroy\n respond_to do |format|\n format.html { redirect_to tickets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ticket.d... | [
"0.8142457",
"0.7563549",
"0.7563228",
"0.7563228",
"0.7563228",
"0.7563228",
"0.7563228",
"0.75205696",
"0.75205696",
"0.75205696",
"0.75205696",
"0.75205696",
"0.75205696",
"0.7511588",
"0.7503354",
"0.7473698",
"0.7396861",
"0.7391147",
"0.73365825",
"0.7319954",
"0.731995... | 0.0 | -1 |
Notify that a new booking has been received | def send_new_booking_request_notifications
if pay_now
notify_manager_pay_now
notify_request_to_customer_pay_now
else
notify_manager
notify_request_to_customer
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_booking_notification(booking)\n @booking = booking\n mail(\n to: @booking.user_email,\n subject: 'Reserva realizada.')\n end",
"def statusChange(booking)\n @booking = booking\n\n mail to: booking.user.email, subject: \"Ta reservation pour #{@booking.location.name} a un nouveau stat... | [
"0.78234166",
"0.69990104",
"0.6875808",
"0.68024135",
"0.67590994",
"0.6716075",
"0.6681293",
"0.6679437",
"0.6668682",
"0.6668348",
"0.66662496",
"0.66348267",
"0.66283137",
"0.66009",
"0.65918416",
"0.6589843",
"0.65460575",
"0.6536768",
"0.652677",
"0.6516068",
"0.6510334... | 0.6955222 | 2 |
Notify that a booking has been confirmed | def send_booking_confirmation_notifications
notify_manager_confirmation
notify_customer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirmation(booking)\n @booking = booking\n mail(to: booking.user.email, subject: \"You have been confirmed!\")\n end",
"def confirm\n if status == :pending_confirmation and\n not charges.select { |charge| charge.status == :done }.empty?\n transaction do\n self.status... | [
"0.7824383",
"0.7661112",
"0.7630363",
"0.7590151",
"0.74990815",
"0.74844605",
"0.7454309",
"0.7424065",
"0.7356704",
"0.728971",
"0.725532",
"0.7187085",
"0.70948106",
"0.70543724",
"0.70438325",
"0.69897443",
"0.6925513",
"0.6871741",
"0.68680906",
"0.6831888",
"0.68303454... | 0.73429084 | 9 |
SUPPLEMENTS SUMMARY Total summary | def total_summary
products = {}
products.store(:item_cost, item_cost)
products.store(:extras_cost, extras_cost)
supplements = {}
supplements.store(:pick_up_place, pickup_place_cost)
supplements.store(:return_place, return_place_cost)
supplements.store(:time_from_cost, time_from_cost)
supplements.store(:time_to_cost, time_to_cost)
supplements.store(:driver_age_cost, driver_age_cost)
supplements.store(:category_supplement_1, category_supplement_1_cost)
supplements.store(:category_supplement_2, category_supplement_2_cost)
supplements.store(:category_supplement_3, category_supplement_3_cost)
supplements.store(:supplement_1, supplement_1_cost)
supplements.store(:supplement_2, supplement_2_cost)
supplements.store(:supplement_3, supplement_3_cost)
deposit = {}
deposit.store(:product_deposit_cost, product_deposit_cost)
totals = {}
totals.store(:total_cost, total_cost)
totals.store(:total_paid, total_paid)
totals.store(:total_pending, total_pending)
summary = {products: products,
supplements: supplements,
deposit: deposit,
totals: totals }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summary\n \n end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary\n end",
"def summary\n end",
"def summary\n # TODO\n end",
"def product_summary\n cell(CardProduct::Cell::Summary, card_product)\n end",
"def summary\n {}\n... | [
"0.65217954",
"0.64695597",
"0.64695597",
"0.64695597",
"0.64695597",
"0.6441944",
"0.6441944",
"0.641073",
"0.62980616",
"0.62752295",
"0.62259245",
"0.6189717",
"0.6189717",
"0.6167211",
"0.6131053",
"0.61240464",
"0.60512584",
"0.60227007",
"0.6010383",
"0.5976836",
"0.596... | 0.7099747 | 0 |
BOOKING LINES Add a booking line to the reservation == Parameters:: item_id:: The item id quantity:: The quantity | def add_booking_line(item_id, quantity)
# Check if the booking includes the item_id
product_lines = self.booking_lines.select do |booking_line|
booking_line.item_id == item_id
end
if product_lines.empty?
if product = ::Yito::Model::Booking::BookingCategory.get(item_id)
product_customer_translation = product.translate(customer_language)
product_unit_cost = product_item_cost_base = product.unit_price(self.date_from, self.days, nil, self.sales_channel_code).round(0)
product_deposit_cost = product.deposit
## Apply promotion code and offers
rates_promotion_code = if !self.promotion_code.nil? and !self.promotion.code.empty?
::Yito::Model::Rates::PromotionCode.first(promotion_code: self.promotion_code)
else
nil
end
discount = ::Yito::Model::Booking::BookingCategory.discount(product_unit_cost, item_id, self.date_from, self.date_to, rates_promotion_code) || 0
product_unit_cost = (product_unit_cost - discount).round(0) if discount > 0
## End apply offers
## Category supplements
product_supplement_1_unit_cost = product.category_supplement_1_cost || 0
product_supplement_2_unit_cost = product.category_supplement_2_cost || 0
product_supplement_3_unit_cost = product.category_supplement_3_cost || 0
if sales_channel_code
if bcsc = Yito::Model::Booking::BookingCategoriesSalesChannel.first(conditions: {'sales_channel.code': sales_channel_code, booking_category_code: product.code })
product_supplement_1_unit_cost = bcsc.category_supplement_1_cost || 0
product_supplement_2_unit_cost = bcsc.category_supplement_2_cost || 0
product_supplement_3_unit_cost = bcsc.category_supplement_3_cost || 0
end
end
## End of category supplements
transaction do
# Create booking line
booking_line = BookingDataSystem::BookingLine.new
booking_line.booking = self
booking_line.item_id = item_id
booking_line.item_description = product.name
booking_line.item_description_customer_translation = (product_customer_translation.nil? ? product.name : product_customer_translation.name)
booking_line.item_unit_cost_base = product_item_cost_base
booking_line.item_unit_cost = product_unit_cost
booking_line.item_cost = product_unit_cost * quantity
booking_line.quantity = quantity
booking_line.product_deposit_unit_cost = product_deposit_cost
booking_line.product_deposit_cost = product_deposit_cost * quantity
booking_line.category_supplement_1_unit_cost = product_supplement_1_unit_cost
booking_line.category_supplement_1_cost = product_supplement_1_unit_cost * quantity
booking_line.category_supplement_2_unit_cost = product_supplement_2_unit_cost
booking_line.category_supplement_2_cost = product_supplement_2_unit_cost * quantity
booking_line.category_supplement_3_unit_cost = product_supplement_3_unit_cost
booking_line.category_supplement_3_cost = product_supplement_3_unit_cost * quantity
booking_line.save
# Create booking line resources
(1..quantity).each do |resource_number|
booking_line_resource = BookingDataSystem::BookingLineResource.new
booking_line_resource.booking_line = booking_line
booking_line_resource.save
end
# Update booking cost
self.item_cost += (product_unit_cost * quantity)
self.product_deposit_cost += (product_deposit_cost * quantity)
self.category_supplement_1_cost += (product_supplement_1_unit_cost * quantity)
self.category_supplement_2_cost += (product_supplement_2_unit_cost * quantity)
self.category_supplement_3_cost += (product_supplement_3_unit_cost * quantity)
self.calculate_cost(false, false)
self.save
# Assign available stock
if status == :pending_confirmation
if created_by_manager
assign_available_stock if SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation_on_backoffice_request').to_bool
else
assign_available_stock if SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation_on_web_request').to_bool
end
elsif status == :confirmed
if SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool
assign_available_stock
end
end
# Create newsfeed
::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',
action: 'add_booking_line',
identifier: self.id.to_s,
description: BookingDataSystem.r18n.t.booking_news_feed.created_booking_line(item_id, quantity),
attributes_updated: {item_id: item_id, quantity: quantity}.merge({booking: newsfeed_summary}).to_json)
end
self.reload
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(item_id)\n self.add_or_create_line_item(item_id)\n end",
"def add_or_create_line_item(item_id)\n if line_item = self.line_items.find_by(item_id: item_id)\n line_item.increment\n line_item\n else\n LineItem.new(cart_id: self.id, item_id: item_id)\n end\n end",
"def crea... | [
"0.70234257",
"0.6709108",
"0.6615346",
"0.6529793",
"0.652385",
"0.6486162",
"0.6461691",
"0.64134544",
"0.6339395",
"0.63042945",
"0.6229814",
"0.62192285",
"0.61691827",
"0.61633277",
"0.6157244",
"0.61517674",
"0.6099156",
"0.60345",
"0.59978914",
"0.5993501",
"0.59846437... | 0.69256365 | 1 |
Destroy a booking line == Parameters:: item_id:: The item line id | def destroy_booking_line(item_id)
product_lines = self.booking_lines.select do |booking_line|
booking_line.item_id == item_id
end
if booking_line = product_lines.first
transaction do
self.item_cost -= booking_line.item_cost
self.product_deposit_cost -= booking_line.product_deposit_cost
self.category_supplement_1_cost -= booking_line.category_supplement_1_cost
self.category_supplement_2_cost -= booking_line.category_supplement_2_cost
self.category_supplement_3_cost -= booking_line.category_supplement_3_cost
self.calculate_cost(false, false)
self.save
booking_line.destroy
# Create newsfeed
::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',
action: 'destroy_booking_line',
identifier: self.id.to_s,
description: BookingDataSystem.r18n.t.booking_news_feed.destroyed_booking_line(item_id),
attributes_updated: {item_id: item_id}.merge({booking: newsfeed_summary}).to_json)
end
self.reload
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @line_item.destroy\n destroy_line_item_response\n end",
"def destroy\n @line_item = line_items.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n end\n end",
"def destroy\n @item_line = ItemLine.find(params[... | [
"0.75655544",
"0.7203878",
"0.72035444",
"0.71088207",
"0.70940477",
"0.7078435",
"0.7065822",
"0.7036312",
"0.7036312",
"0.7036312",
"0.7036312",
"0.6995786",
"0.69885296",
"0.69773275",
"0.68693906",
"0.68693906",
"0.68693906",
"0.68693906",
"0.68693906",
"0.68693906",
"0.6... | 0.7337309 | 1 |
EXTRAS Add a booking extra to the reservation | def add_booking_extra(extra_id, quantity)
booking_extras = self.booking_extras.select do |booking_extra|
booking_extra.extra_id == extra_id
end
if booking_extras.empty?
if extra = ::Yito::Model::Booking::BookingExtra.get(extra_id)
extra_translation = extra.translate(customer_language)
booking_deposit = SystemConfiguration::Variable.get_value('booking.deposit', 0).to_i
extra_unit_cost = extra.unit_price(self.date_from, self.days)
transaction do
# Create the booking extra line
booking_extra = BookingDataSystem::BookingExtra.new
booking_extra.booking = self
booking_extra.extra_id = extra_id
booking_extra.extra_description = extra.name
booking_extra.extra_description_customer_translation = extra_translation.nil? ? extra.name : extra_translation.name
booking_extra.quantity = quantity
booking_extra.extra_unit_cost = extra_unit_cost
booking_extra.extra_cost = extra_unit_cost * quantity
booking_extra.save
# Updates the booking
self.extras_cost += (extra_unit_cost * quantity)
self.calculate_cost(false, false)
self.save
# Create newsfeed
::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',
action: 'add_booking_extra',
identifier: self.id.to_s,
description: BookingDataSystem.r18n.t.booking_news_feed.created_booking_extra(extra_id, quantity),
attributes_updated: {extra_id: extra_id, quantity: quantity}.merge({booking: newsfeed_summary}).to_json)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_extra(extra)\n @extras.merge!(extra)\n end",
"def add_extra(key, value)\n @extras[key] = value\n end",
"def add_reservation(start_date, end_date)\n @bookings << [start_date, end_date]\n end",
"def extra; @extra; end",
"def set_reservation\n @extra_reservation = ExtraReservation.f... | [
"0.6635611",
"0.59817415",
"0.59312916",
"0.54091024",
"0.5391078",
"0.5381175",
"0.537835",
"0.5361979",
"0.53195685",
"0.53176796",
"0.53095484",
"0.52653044",
"0.5236827",
"0.52123994",
"0.5208371",
"0.5140492",
"0.51366997",
"0.5130116",
"0.51078737",
"0.5099543",
"0.5073... | 0.6530423 | 1 |
Destroy a booking extra | def destroy_booking_extra(extra_id)
booking_extras = self.booking_extras.select do |booking_extra|
booking_extra.extra_id == extra_id
end
if booking_extra = booking_extras.first
transaction do
self.extras_cost -= booking_extra.extra_cost
self.calculate_cost(false, false)
self.save
booking_extra.destroy
# Create newsfeed
::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',
action: 'destroy_booking_extra',
identifier: self.id.to_s,
description: BookingDataSystem.r18n.t.booking_news_feed.destroyed_booking_extra(extra_id),
attributes_updated: {extra_id: item_id}.merge({booking: newsfeed_summary}).to_json)
end
self.reload
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @booking.destroy\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: \"Booking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n Booking.create(user_id: 1, datareserva: @booking.datares... | [
"0.7617159",
"0.72829074",
"0.72303444",
"0.7117501",
"0.708527",
"0.70264083",
"0.6953831",
"0.69485754",
"0.6944781",
"0.6917499",
"0.68850356",
"0.6866629",
"0.6849843",
"0.6849694",
"0.6847072",
"0.6839478",
"0.68375856",
"0.6819433",
"0.6813726",
"0.67899597",
"0.6775812... | 0.72223777 | 3 |
BOOKING CHARGE Add a booking charge | def add_booking_charge(date, amount, payment_method_id)
transaction do
charge = Payments::Charge.new
charge.date = date
charge.amount = amount
charge.payment_method_id = payment_method_id
charge.status = :pending
charge.currency = SystemConfiguration::Variable.get_value('payments.default_currency', 'EUR')
charge.save
booking_charge = BookingDataSystem::BookingCharge.new
booking_charge.booking = self
booking_charge.charge = charge
booking_charge.save
charge.update(:status => :done)
self.reload
# Create newsfeed
::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',
action: 'add_booking_charge',
identifier: self.id.to_s,
description: BookingDataSystem.r18n.t.booking_news_feed.added_booking_charge(".2f" % amount, payment_method_id),
attributes_updated: {date: date, amount: amount, payment_method_id: payment_method_id}.merge({booking: newsfeed_summary}).to_json)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_charge(desc, bond)\n self[:charges] << {\n :desc => desc.to_s.strip,\n :bond => bond.to_s.gsub('$', '').strip.to_i\n \t}\n Log.d(\"Adding charge: #{self[:charges].last[:desc]}, #{self[:charges].last[:bond]}\")\n end",
"def book_hotel\r\n # prices in stripe are defined in cents, ... | [
"0.6776659",
"0.6752922",
"0.6468963",
"0.6260624",
"0.6252942",
"0.6193788",
"0.6115227",
"0.6086412",
"0.6001376",
"0.5934734",
"0.59116423",
"0.59038943",
"0.5888044",
"0.58800834",
"0.5854628",
"0.58421224",
"0.5821806",
"0.57947856",
"0.5766759",
"0.5712016",
"0.57005435... | 0.6776325 | 1 |
Destroy a booking charge | def destroy_booking_charge(charge_id)
if booking_charge = BookingDataSystem::BookingCharge.first(:booking_id => self.id,
:charge_id => charge_id)
charge = booking_charge.charge
transaction do
if charge.status == :done
self.total_paid -= charge.amount
self.total_pending += charge.amount
self.save
end
charge.destroy
booking_charge.destroy
# Create newsfeed
::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',
action: 'destroy_booking_charge',
identifier: self.id.to_s,
description: BookingDataSystem.r18n.t.booking_news_feed.destroyed_booking_charge(".2f" % charge.amount, charge.payment_method_id),
attributes_updated: {amount: charge.amount, payment_method_id: charge.payment_method_id}.to_json)
end
self.reload
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @booking.destroy\n end",
"def destroy\n @charge = Charge.find(params[:id])\n @charge.destroy\n redirect_to charges_url\n end",
"def destroy\n if @accommodation_charge.destroy\n redirect_to company_accommodation_charges_path( @company ), notice: t('notice.destroy', model_name... | [
"0.7612688",
"0.756157",
"0.73435915",
"0.73131484",
"0.73122597",
"0.725401",
"0.7248786",
"0.7183744",
"0.7160358",
"0.71502894",
"0.71502894",
"0.71502894",
"0.71302",
"0.7123444",
"0.70675886",
"0.7038702",
"0.70113933",
"0.7006071",
"0.7005511",
"0.69715285",
"0.6955649"... | 0.7798823 | 0 |
Check if the reservation is confirmed | def confirmed?
[:confirmed, :in_progress, :done].include?(self.status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_confirmed?\n return self.status == Erp::Reservations::Reservation::STATUS_CONFIRMED\n end",
"def confirm\n # can't confirma reservation in the past!\n render false && return unless @reservation.start_datetime > Time.current\n if @reservation.confirm && @reservation.save\n flash[:noti... | [
"0.8291122",
"0.73338926",
"0.71549207",
"0.71349776",
"0.71134984",
"0.7082503",
"0.7082503",
"0.7059964",
"0.7027459",
"0.6999295",
"0.69947946",
"0.6984182",
"0.6947228",
"0.6938345",
"0.6937434",
"0.69253707",
"0.68681365",
"0.68465877",
"0.6824019",
"0.67967594",
"0.6773... | 0.6851745 | 17 |
Get the category of the reserved items | def category
booking_lines and booking_lines.size > 0 ? ::Yito::Model::Booking::BookingCategory.get(booking_lines[0].item_id) : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category_string\n return Item::ITEM_CATEGORIES[self.category_id] if self.category_id\n return \"\"\n end",
"def categories_for(item)\n return [] unless @items[item]\n\n @items[item].categories\n end",
"def category()\n if (order_in_lines.length == 1)\n cat = order_in_lines[0].book... | [
"0.6429407",
"0.6404427",
"0.6327857",
"0.62652206",
"0.6214743",
"0.60485834",
"0.6032046",
"0.59918",
"0.5979594",
"0.5950983",
"0.59153354",
"0.5911013",
"0.59006417",
"0.58686054",
"0.58564585",
"0.58378357",
"0.58368444",
"0.58351094",
"0.5823416",
"0.5814765",
"0.581476... | 0.6604788 | 0 |
Check if the reservation has expired | def expired?
conf_item_hold_time = SystemConfiguration::Variable.get_value('booking.item_hold_time', '0').to_i
hold_time_diff_in_hours = ((DateTime.now.to_time - self.creation_date.to_time).to_f * 24).to_i
expired = (hold_time_diff_in_hours > conf_item_hold_time)
expired && !force_allow_payment
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_expiration\n reservation = Reservation.find(params[:id])\n return unless reservation.booking_request_expired?\n\n flash[:danger] = 'Booking request has expired.'\n redirect_to your_reservations_path\n end",
"def check_expiration\n return unless @reservation.booking_request_expired?\n\n ... | [
"0.777241",
"0.75869465",
"0.751782",
"0.741412",
"0.7363432",
"0.7353949",
"0.7293808",
"0.7286341",
"0.7278613",
"0.72442675",
"0.7242252",
"0.72048765",
"0.71852326",
"0.7176915",
"0.717167",
"0.7164792",
"0.71593654",
"0.7147379",
"0.71185625",
"0.71035016",
"0.70497924",... | 0.7438555 | 3 |
Check the payment cadence is allowed | def payment_cadence_allowed?
begin
config_payment_cadence = SystemConfiguration::Variable.get_value('booking.payment_cadence').to_i
_date_from_str = "#{self.date_from.strftime('%Y-%m-%d')}T#{self.time_from}:00#{self.date_from.strftime("%:z")}"
_date_from = DateTime.strptime(_date_from_str,'%Y-%m-%dT%H:%M:%S%:z')
diff_in_hours = ((_date_from.to_time - self.creation_date.to_time).to_f * 24).to_i
allowed = diff_in_hours > 0 && (diff_in_hours >= config_payment_cadence)
allowed || force_allow_payment
rescue => error
p "Error #{id} #{date_from} #{time_from} #{date_to} #{time_to} #{driver_date_of_birth} #{driver_driving_license_date}"
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def charge_is_allowed?\n\t\tif not customer_has_authorized_payment?\n\t\t\terrors.add :base, I18n.t('views.customer_file.new_charge.you_are_not_authorized')\n\t\t\tfalse\n\t\telsif valid? and charge_amount.present? and authorized_amount and charge_amount.to_i <= authorized_amount\n\t\t\ttrue\n\t\telse\n\t\t\terror... | [
"0.75447243",
"0.7347513",
"0.7347513",
"0.73074293",
"0.71527463",
"0.71349007",
"0.7123488",
"0.7101144",
"0.70804197",
"0.70804197",
"0.68784773",
"0.6834908",
"0.68171525",
"0.68162286",
"0.6789596",
"0.6780398",
"0.67728525",
"0.67522043",
"0.67319894",
"0.66976804",
"0.... | 0.8120673 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.