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 |
|---|---|---|---|---|---|---|
Get a limit object. | def limit(headers = {})
Resources::Limit.new(self, get_limit(headers).body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(klass, default_limit = Float::INFINITY)\n key = normalize_class(klass)\n\n begin\n @limits.fetch(key)\n rescue\n return default_limit\n end\n end",
"def limit\n self[:limit]\n end",
"def rate_limit\n response = self.class.get('/rate_limit', opti... | [
"0.7285583",
"0.6915179",
"0.679817",
"0.67906106",
"0.6644299",
"0.65510404",
"0.6540216",
"0.649758",
"0.64767784",
"0.6436184",
"0.640531",
"0.64030266",
"0.63351715",
"0.6327187",
"0.62644297",
"0.62577266",
"0.6234903",
"0.62039423",
"0.618182",
"0.61778426",
"0.6170941"... | 0.6448352 | 9 |
We need to keep flipping pairs of right handed digits (lower weight digits) until we get a net big number Example for 144 iteration 1 Flip digit index 1 and index 2 Results in 144 which is still not greater than the input Flip digit index 2 and index 3 Results in 414 which is greater than the input When choosing right digits to flip, we need to choose digits that are higher than the one we are flipping. Eg: Input 7890 Iteration 1: tail = 0, next_tail= 9 Notice that if all digits are the same then we can't get any bigger with permutations. | def next_bigger(input)
puts "input = #{input}"
puts '------------------'
puts
puts
digits = input.to_s.chars.map(&:to_i)
return -1 if all_digits_are_the_same?(digits)
result = input
tail = -1
next_tail = -1
next_tail_digit = nil
puts 'Starting iterations to find the bigger number by permutating digits from right to left...'
puts
while(tail.abs < digits.length && result <= input)
next_tail = tail -1
tail_digit = digits[tail]
next_tail_digit = digits[next_tail]
if to_number(next_tail_digit, tail_digit) > to_number(tail_digit, next_tail_digit)
puts "SKIPPING flipping since #{next_tail_digit}#{tail_digit} > #{tail_digit}#{next_tail_digit}"
else
puts "FLIPPING digits..."
puts "digits before = #{digits}"
digits[tail] = next_tail_digit
digits[next_tail] = tail_digit
puts "digits after = #{digits}"
result = digits.join.to_i
puts "tail = #{tail} digit = #{tail_digit}"
puts "next_tail = #{next_tail} digit = #{next_tail_digit}"
puts "result = #{result}"
end
tail -= 1
puts "new_tail = #{tail}"
puts '--'
puts ''
end
return -1 if result == input
replaced_digit = next_tail_digit
winning_digit = digits[next_tail]
puts
puts "Iterations Completed and Bigger number found: #{result}"
puts " - Digit that won was: #{winning_digit}."
puts " - It replaced the digit: #{replaced_digit} from input: #{input} at index #{next_tail}."
puts
puts "Let see if we can make the number smaller by sorting the numbers to the right from bigger to smaller"
digits_before = digits.slice(0..next_tail)
digits_after = digits.slice((next_tail+1)..-1)
sorted_digits_after = sort_desc(digits_after)
puts
puts "digits_before: #{digits_before}, digits_after: #{digits_after}"
puts "Sorting digits after: #{sorted_digits_after}"
puts "Resulting Number: #{array_to_number(digits_before + sorted_digits_after)}"
puts
puts "Now let see if we can find any number to the right of the winning position that" \
" is smaller than the number that won #{winning_digit} but bigger than the replaced digit #{replaced_digit}..."
index_of_digit_smaller_than_winner = sorted_digits_after.find_index { |d| d < winning_digit && d > replaced_digit }
if index_of_digit_smaller_than_winner
digit_smaller_than_the_winner = sorted_digits_after[index_of_digit_smaller_than_winner]
puts
puts "We found it one! Since the array was already sorted we can trust that the one we found is the smalles one."
puts "Index: #{index_of_digit_smaller_than_winner} and number: #{digit_smaller_than_the_winner}"
puts "Lets switch the winning number by this one now."
puts "Before: #{digits_before} + #{sorted_digits_after}"
digits_before[-1] = digit_smaller_than_the_winner
sorted_digits_after[index_of_digit_smaller_than_winner] = winning_digit
puts "After: #{digits_before} + #{sorted_digits_after}"
puts
puts "We now have to sort the digits again because they may be out of order:"
sorted_digits_after = sort_desc(sorted_digits_after)
puts "After Re-Sorting: #{digits_before} + #{sorted_digits_after}"
puts
end
result = digits_before + sorted_digits_after
result.join.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_permutation(base_two_num)\n if has_dynamic_one?(base_two_num)\n shift_final_dynamic_one_right(base_two_num)\n else\n nil\n end\nend",
"def permuted_nums()\r\n\t# *2...*6 must have the same digits (and length) as the original.\r\n\t# That's why the first character must be 1.\r\n\t# And the secon... | [
"0.6296871",
"0.6258146",
"0.6184225",
"0.6143546",
"0.6032066",
"0.6024654",
"0.595173",
"0.5880662",
"0.58781",
"0.58739847",
"0.58723515",
"0.5839862",
"0.5827098",
"0.582495",
"0.5812143",
"0.5776322",
"0.5770169",
"0.57680273",
"0.5763032",
"0.57508713",
"0.57406664",
... | 0.7155519 | 0 |
if all the digits are the same we dont need to compute since the number cant get bigger with permutations | def all_digits_are_the_same?(digits)
digits.uniq.length == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permuted_nums()\r\n\t# *2...*6 must have the same digits (and length) as the original.\r\n\t# That's why the first character must be 1.\r\n\t# And the second character must be less that 7.\r\n\trunner = 123455\r\n\tmax = 170000\r\n\twhile runner < max\r\n\t\trunner += 1\r\n\t\t\r\n\t\tmult_count = 1\r\n\t\t... | [
"0.75402224",
"0.700527",
"0.6970922",
"0.69567573",
"0.6949266",
"0.6896659",
"0.68623435",
"0.6803344",
"0.6782188",
"0.6712885",
"0.6709224",
"0.6632845",
"0.6614503",
"0.6580868",
"0.6553198",
"0.6552078",
"0.6533141",
"0.65062344",
"0.64961547",
"0.64924717",
"0.64579296... | 0.7354844 | 1 |
returns hash of total_aptc, aptc_breakdown_by_member and csr_value | def fetch_available_eligibility
available_eligibility_hash = fetch_enrolling_available_aptcs.merge(fetch_csr)
total_aptc = float_fix(available_eligibility_hash[:aptc].values.inject(0, :+))
available_eligibility_hash.merge({:total_available_aptc => total_aptc})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def med_stats_hash(_assessed_data); end",
"def hash\n [lac, cid, radio, mcc, mnc, signal, psc, asu, ta].hash\n end",
"def hash\n [access_complexity, access_vector, authentication, availability_impact, confidentiality_impact, exploit_score, impact_score, integrity_impact, score, vector].hash\n e... | [
"0.61103517",
"0.6028404",
"0.5946738",
"0.59230816",
"0.58952934",
"0.58165",
"0.575394",
"0.5753174",
"0.5719117",
"0.5714976",
"0.56981397",
"0.5681456",
"0.56467706",
"0.56389415",
"0.56295276",
"0.56115544",
"0.56114024",
"0.56056833",
"0.56047285",
"0.56016624",
"0.5594... | 0.0 | -1 |
returns hash of product_id to applicable_aptc mappings | def fetch_applicable_aptcs
raise "Cannot process without selected_aptc: #{@selected_aptc} and product_ids: #{@product_ids}" if @selected_aptc.nil? || @product_ids.empty?
@available_aptc ||= fetch_available_eligibility[:total_available_aptc]
# TODO: Return a has of plan_id, applicable aptcs.
@product_ids.inject({}) do |products_aptcs_hash, product_id|
product_aptc = applicable_aptc_hash(product_id)
products_aptcs_hash.merge!(product_aptc) unless product_aptc.empty?
products_aptcs_hash
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_product_hash\n hash = {}\n items = @all_products\n for prod in items\n hash[prod] = {}\n end\n return hash\n end",
"def product_attributes\n {:name => 'cute pants', :set_keywords => 'test,one,two,three', :product_type_id => 1, :prototype_id => nil, :shipping_category_id => 1, :per... | [
"0.6114954",
"0.6021619",
"0.60075164",
"0.59829146",
"0.5925083",
"0.58695465",
"0.5729365",
"0.5707065",
"0.5676723",
"0.56283903",
"0.56198275",
"0.5571299",
"0.5568204",
"0.554091",
"0.55207896",
"0.5483079",
"0.5442803",
"0.54305035",
"0.54273766",
"0.54226065",
"0.54206... | 0.6416084 | 0 |
Transform Markdown string `source` into an HTML string. On failure returns nil. | def markdown(source)
Open3.popen2('pandoc', '-s', '-f', 'markdown', '-t', 'html') do |stdin, stdout, wait_thr|
stdin.puts(source)
stdin.close
stdout.read
end
rescue => e
STDERR.puts e
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html source=nil\n to_html text(source)\n end",
"def to_html source=nil\n require 'md2man/html/engine'\n Md2Man::HTML::ENGINE.render(read(source))\n rescue LoadError\n raise 'Run `gem install md2man` to use BinMan::html().'\n end",
"def markdown_to_html(src)\n render_options = {\n ... | [
"0.7158338",
"0.6606907",
"0.64599794",
"0.63539785",
"0.59991515",
"0.59097975",
"0.5873133",
"0.5861906",
"0.5855692",
"0.5835587",
"0.5768386",
"0.57580364",
"0.57243866",
"0.5704142",
"0.56734926",
"0.56430054",
"0.56282634",
"0.5610653",
"0.56013703",
"0.56013703",
"0.55... | 0.6501447 | 2 |
Trims the "!m" marker string from the beginning or end of the input. Returns true if the input was trimmed. | def trim_markdown_markers!(input)
trimmed = !!input.sub!(MARKDOWN_MARKER_AT_START, '')
!!input.sub!(MARKDOWN_MARKER_AT_END, '') || trimmed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auto_trim?; end",
"def cold_shoulder? remark\n '' == remark.strip\n end",
"def auto_trim!; end",
"def trim\n self.fetch(:trim, self.skipInitialSpace ? 'start' : false)\n end",
"def leading_trailing_whitespace?(str)\n str != str.strip\n end",
"def no_auto_trim!; end",
"def taken?(inp... | [
"0.62608933",
"0.6187141",
"0.6173325",
"0.6136211",
"0.6021527",
"0.60069543",
"0.5990441",
"0.5850213",
"0.58095753",
"0.57933456",
"0.57933456",
"0.57933456",
"0.577272",
"0.5708971",
"0.5690624",
"0.5685352",
"0.5675662",
"0.5655361",
"0.5650545",
"0.5584211",
"0.55837584... | 0.61045 | 4 |
Render a partial, treating it as a template, and any code in the block argument will impact how the template renders My overridden Step 2 | | Anonymous Step 4 Step 1 | Step 2 | Step 3 Options: [+partial+] The partial to render as a template [+block+] An optional block with code that affects how the template renders | def render_template(partial, variable=nil, &block)
render_options = global_options.clone
render_options[:captured_block] = view.capture(self, &block) if block_given?
render_options[:options] = render_options
variable ||= render_options.delete(:variable) || :template
render_options[variable] = self
view.render partial, render_options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_partial(context, options, &block); end",
"def block_to_partial(partial_name, options = {}, &block)\n options.merge!(:body => capture(&block))\n concat(render(:partial => partial_name, :locals => options))\n end",
"def block_to_partial(partial_name, options = {}, &block)\n options.merge!(:b... | [
"0.823321",
"0.76840794",
"0.76840794",
"0.7642173",
"0.764209",
"0.764209",
"0.764209",
"0.7587539",
"0.75383174",
"0.7429004",
"0.7384051",
"0.7044608",
"0.70195866",
"0.6927301",
"0.68987596",
"0.6840831",
"0.6840831",
"0.6822521",
"0.6789249",
"0.6735243",
"0.67296773",
... | 0.6532389 | 27 |
Queue a block for later rendering, such as within a template. My overridden Step 2 | | Anonymous Step 4 Step 1 | Step 2 | Step 3 Options: [+args+] The options to pass in when this block is rendered. These will override any options provided to the actual block definition. Any or all of these options may be overriden by whoever calls "blocks.render" on this block. Usually the first of these args will be the name of the block being queued (either a string or a symbol) [+block+] The optional block definition to render when the queued block is rendered | def queue(*args, &block)
self.queued_blocks << self.define_block_container(*args, &block)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue(*args, &block)\n @queue << [block, args]\n end",
"def render_block(block, options = {})\n render partial: partial_name_for(block, options), object: block, as: :block\n end",
"def queue( name, &block )\n destination( name, :queue, @queues, &block )\n end",
"def queue(cls, arg... | [
"0.6648659",
"0.5926518",
"0.5844823",
"0.5758021",
"0.5703705",
"0.5556514",
"0.544405",
"0.53941107",
"0.53938216",
"0.5380421",
"0.535426",
"0.534299",
"0.5342282",
"0.53134775",
"0.5243458",
"0.52186733",
"0.5210667",
"0.5175211",
"0.5163711",
"0.5163711",
"0.51481503",
... | 0.7304012 | 0 |
Return a distance (cosine similarity) between a new vector, and all the clusters (columns) used in the original matrix. Returns a sorted list of indexes and distances, | def classify_vector(values)
raise "Unsupported vector length" unless values.size == @u.row_size || values.size == @v.row_size
vector = Matrix.row_vector(values)
mult_matrix = (values.size == @u.row_size ? @u : @v)
comp_matrix = (values.size == @u.row_size ? @v : @u)
position = vector * Matrix[*mult_matrix] * @s.inverse
x = position[0,0]
y = position[0,1]
results = []
comp_matrix.row_size.times do |index|
results << [index, cosine_similarity(x, y, comp_matrix[index, 0], comp_matrix[index, 1])]
end
results.sort {|a, b| b[1] <=> a[1]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_cluster_distance dmatrix, cluster\n n = dmatrix.length\n nc = cluster.length\n pcdmatrix = Array.new(n) { Array.new(nc, 0) }\n for i in (0..n-1) \n for j in (0..nc-1)\n # pcdmatrix[i] records the distances from point i to all clusters\n pcdmatrix[i][j] = cluster[j].reduce(0) {|sum, ci| s... | [
"0.6711567",
"0.5966219",
"0.59216285",
"0.58421034",
"0.5731925",
"0.57192457",
"0.56634724",
"0.5553912",
"0.55416536",
"0.5470456",
"0.5470184",
"0.5386134",
"0.5371363",
"0.5330838",
"0.5325879",
"0.53007805",
"0.52390206",
"0.51921326",
"0.51797557",
"0.517023",
"0.51576... | 0.5420591 | 11 |
Determines the cosine similarity between two 2D points | def cosine_similarity(x1, y1, x2, y2)
dp = (x1 * x2) + (y1 * y2)
mag1 = Math.sqrt((x1 ** 2) + (y1 ** 2))
mag2 = Math.sqrt((x2 ** 2) + (y2 ** 2))
return 0 if mag1 == 0 || mag2 == 0
return (dp / (mag1 * mag2))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end",
"def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end",
"def similarity(m1, m2)\n if m1.is_a?(SparseVector) && m2.is_a?(SparseVector)\n m1.cosine(m2)\n elsif m2.size... | [
"0.8034275",
"0.7986059",
"0.77400726",
"0.6768125",
"0.6572465",
"0.6499431",
"0.6405404",
"0.6400117",
"0.6396458",
"0.62918776",
"0.6283614",
"0.62747246",
"0.6256415",
"0.62494326",
"0.62181467",
"0.61797374",
"0.61274666",
"0.6113292",
"0.60792285",
"0.6063917",
"0.60317... | 0.84118295 | 0 |
Retorna el class segun el estado | def class_timeline
if self.state==0
return "info"
elsif self.state==4
return "success"
elsif self.state==2
return "success"
elsif self.state==6
return "danger"
elsif self.state==5
return "danger-circle"
elsif self.state >= 10
return "info"
else
return "warning"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class\n __getobj__.class\n end",
"def current_class( class_code )\n self.classes.select{|c| c.class_code == class_code }.first\n end",
"def class_obj\n self.class\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class(... | [
"0.73913074",
"0.7387113",
"0.73621756",
"0.7295128",
"0.7295128",
"0.7290967",
"0.71477413",
"0.7115823",
"0.7087669",
"0.7069623",
"0.7069623",
"0.70640236",
"0.70640236",
"0.7062654",
"0.7045187",
"0.70182216",
"0.6996126",
"0.6996126",
"0.6996126",
"0.6996126",
"0.6996126... | 0.0 | -1 |
Retorna el class del glyphicons segun el estado | def class_glyphicon
if self.state==0
return "plus"
elsif self.state==4
return "usd"
elsif self.state==2
return "ok"
elsif self.state==6
return "remove"
elsif self.state==5
return "ban-circle"
elsif self.state >= 10
return "repeat"
else
return "refresh"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def icon_class\n icon_name = options[:name].to_s.gsub(\"_\",\"-\")\n %(glyphicon glyphicon-#{icon_name})\n end",
"def glyph(*names)\n content_tag :i, nil, :class => names.map{|name| \"icon-#{name.to_s.gsub('_','-')}\" }\n end",
"def glyph(*names)\n names.map! { |name| name.to_s.... | [
"0.7206846",
"0.6664937",
"0.65353954",
"0.65198654",
"0.6465797",
"0.6355318",
"0.6295455",
"0.62533677",
"0.62533677",
"0.62043613",
"0.616539",
"0.6163922",
"0.61540806",
"0.6143081",
"0.6136291",
"0.6088974",
"0.60736835",
"0.60709745",
"0.60358864",
"0.5956385",
"0.59470... | 0.7217255 | 0 |
Calculate the geometric mean of an array of numbers | def geomean x
sum = 0.0
x.each{ |v| sum += Math.log(v) }
sum /= x.size
Math.exp sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geom_mean(array)\n array.reduce(:*).abs ** (1.0 / array.size)\nend",
"def mean array\n array.inject(:+).to_f / array.length.to_f\n end",
"def mean(array)\n array.inject(:+).to_f / array.size\nend",
"def mean(array)\n array.sum(0.0) / array.size\nend",
"def mean(array)\n total = array.inject... | [
"0.84416455",
"0.7987463",
"0.7951219",
"0.7724808",
"0.7680489",
"0.7679669",
"0.7675712",
"0.7673323",
"0.76593035",
"0.7635466",
"0.7496038",
"0.74436504",
"0.741943",
"0.739735",
"0.7333158",
"0.7327972",
"0.7318561",
"0.7302518",
"0.72825575",
"0.7212815",
"0.7205441",
... | 0.0 | -1 |
GET /projects GET /projects.xml | def index
#@projects = Project.all
projectids = []
allprojects = Role.find_by_sql(["select id, authorizable_id from roles join roles_users on roles.id = roles_users.role_id where roles.authorizable_type = 'Project' and roles_users.user_id = ?", current_user])
projectids = allprojects.collect{|p| p.authorizable_id}
@projects = Project.find(:all, :conditions => {:id => projectids})
@adminrole = []
@userrole = []
@projects.each do |project|
if current_user.is?("admin", project) or current_user.is?("manager", project) or current_user.is?("editor", project) or current_user.is?("owner", project)
@adminrole << project
elsif current_user.is?("user", project)
@userrole << project
end
end
p "admin"
p @adminrole
alltargetlists = Role.find_by_sql(["select id, authorizable_id from roles join roles_users on roles.id = roles_users.role_id where roles.authorizable_type = 'TargetList' and roles_users.user_id = ?", current_user])
targetlistids = alltargetlists.collect{|t| t.authorizable_id}
@target_lists = TargetList.find(:all, :conditions => {:id => targetlistids})
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @projects }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def projects\n request(method: 'getAllProjects')\n end",
"def list\n get 'projects'\n end",
"def listprojects\n get('listprojects.json')['projects']\n end",
"def index\n @projects = @client.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { rend... | [
"0.7811896",
"0.7745333",
"0.76649976",
"0.7631026",
"0.7551874",
"0.7520125",
"0.73800766",
"0.73786414",
"0.73786414",
"0.7363121",
"0.73413455",
"0.73203945",
"0.731012",
"0.7292836",
"0.722775",
"0.7208506",
"0.7176241",
"0.71331584",
"0.70861965",
"0.70469946",
"0.704518... | 0.0 | -1 |
GET /projects/1 GET /projects/1.xml | def show
@project = Project.find(params[:id])
@project_items = @project.project_items
@available_groups = Group.available_items(@project)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html\n format.xml { render xml: @projects } # index.html.erb\n end\n end",
"def index\n @projects = @client.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @p... | [
"0.7413227",
"0.7349132",
"0.7223439",
"0.7223439",
"0.72199285",
"0.7193906",
"0.7157614",
"0.7023897",
"0.70230466",
"0.7021735",
"0.7011579",
"0.69437915",
"0.69343835",
"0.69343835",
"0.69343835",
"0.69343835",
"0.69343835",
"0.69343835",
"0.69343835",
"0.69343835",
"0.69... | 0.0 | -1 |
GET /projects/new GET /projects/new.xml | def new
@project = Project.new
@source = params[:source]
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @new_project = Project.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @new_project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proj... | [
"0.80596024",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.7871155",
"0.78048503",
"0.77742684",
"0.77675897",
"0.7767397",
"0.7708527",... | 0.71315396 | 55 |
POST /projects POST /projects.xml | def create
params[:project][:user_id] = current_user.id
@project = Project.new(params[:project])
@source = params[:source]
allowed_hash = {:allow_anonymous => params[:allow_anonymous], :allow_turk => params[:allow_turk], :allow_interstitial => params[:allow_interstitial]}
@project.meta = allowed_hash.to_json
@project.accepts_role!(:owner, current_user)
respond_to do |format|
if @project.save
flash[:notice] = 'Project was successfully created.'
format.html { redirect_to(:back) }
format.xml { head :ok }
else
format.html { render :action => "new" }
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_create_project_via_API_XML\r\n get \"/logout\"\r\n post \"/projects.xml\", :api_key=>'testapikey',\r\n :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Pr... | [
"0.7630163",
"0.69148767",
"0.6624904",
"0.6560758",
"0.65486205",
"0.6548502",
"0.65337515",
"0.64739347",
"0.64728314",
"0.6443158",
"0.6436239",
"0.6436239",
"0.6436239",
"0.6424931",
"0.64003783",
"0.63883847",
"0.63883847",
"0.6335075",
"0.63076264",
"0.6296561",
"0.6287... | 0.0 | -1 |
PUT /projects/1 PUT /projects/1.xml | def update
@project = Project.find(params[:id])
@source = params[:source]
allowed_hash = {:allow_anonymous => params[:allow_anonymous], :allow_turk => params[:allow_turk], :allow_interstitial => params[:allow_interstitial]}
params[:project][:meta] = allowed_hash.to_json
respond_to do |format|
if @project.update_attributes(params[:project])
flash[:notice] = 'Project was successfully updated.'
format.html { redirect_to(:back) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :descrip... | [
"0.76527995",
"0.6737529",
"0.673667",
"0.6611518",
"0.6590981",
"0.6581627",
"0.65656114",
"0.65600145",
"0.65600145",
"0.6558703",
"0.6558067",
"0.6545517",
"0.6545517",
"0.6545517",
"0.6545517",
"0.6545517",
"0.6545517",
"0.6534732",
"0.6529585",
"0.652178",
"0.6484922",
... | 0.0 | -1 |
DELETE /projects/1 DELETE /projects/1.xml | def destroy
@project = Project.find(params[:id])
@source = params[:source]
ProjectItem.destroy_all(:project_id => @project.id)
Branch.destroy_all(:project_id => @project.id)
@project.destroy
respond_to do |format|
if @source == "dialog_index"
format.html { redirect_to(:back) }
format.xml { head :ok }
else
format.html { redirect_to(projects_url) }
format.xml { head :ok }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n \n\n respond_to do |... | [
"0.7358072",
"0.7261855",
"0.7243686",
"0.7241906",
"0.7214553",
"0.7205152",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"0.7174226",
"... | 0.0 | -1 |
Method displays the user view of the project | def display
@project = Project.find(params[:id])
# Grabbing any config info we need to make decisions
meta_hash = ActiveSupport::JSON.decode(@project.meta)
complete_flag = false
next_flag = false
interstitial_flag = object_to_boolean(meta_hash["allow_interstitial"])
@code = @project.current_code(request.session_options[:id])
# If the page was submitted save answers and complete locks
unless params[:commit].blank?
# Grab current code and save parameters if page was committed.
@save_hash = save_answers(@code, params)
@group = Group.find(params[:group])
@branch = Branch.find(params[:branch]) unless params[:branch].blank?
UserLock.lock(@project, @group, @code, request.session_options[:id]).complete
@selected_branch = select_branch(params, @project.id, @group.id)
end
if @code.nil?
# Behavior is different if the project includes targets
if @project.targets?
# Are there any targets left? If not we will complete the project
if @project.remaining_targets(request.session_options[:id]) > 0
@code = @project.gen_code(request.session_options[:id])
else
complete_flag = true
end
else
# If project doesnt contain targets and we have already completed one, we will finish
if @project.completed_count(request.session_options[:id]) > 0
complete_flag = true
else
@code = @project.gen_code(request.session_options[:id])
end
end
end
if complete_flag == false
# The following identifies what group "page" and individual should be on.
# This will either be the branch, or the next logical group
# Full branch logic
if !@selected_branch.blank?
if @selected_branch[0].destination_group_id == nil
@group = ""
else
@group = Group.find(@selected_branch[0].destination_group_id)
end
else
if !@branch.blank?
# if there is no return group id go to the next group in order, if the return group id is 0, complete script, if there is a return group id, go to that group.
if @branch.return_group_id.blank?
@group = @project.current_group(@code)
elsif @branch.return_group_id == 0
@group = ""
else
@group = Group.find(@selected_branch.return_group_id)
end
else
@group = @project.current_group(@code)
end
end
# END branch logic
if @group.blank?
@code.update_attribute(:completed, true)
next_flag = true
else
#@group = @project.current_group(@code, current_user)
@questions = @group.questions.find(:all, :conditions => {"group_items.active" => true})
@nancode = "NANCODE-#{@project.id}-#{@group.id}"
# Is current group locked? If not then lock.
@user_lock = UserLock.lock(@project, @group, @code, request.session_options[:id])
end
end
#Redirection block, redirect or display group
if next_flag
if interstitial_flag
redirect_to :controller => :projects, :action => :completed, :id => @project.id
else
redirect_to display_project_path(@project)
end
elsif complete_flag
redirect_to :controller => :projects, :action => :completed, :id => @project.id
else
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @project }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n #Este es un caso especial: el archivo routes establece que User es un recurso, así que cuando llega a la ruta del\n # proyecto, por ejemplo, /project/15, es el perfil del proyecto con id 15, entonces como es un recurso, el controlador\n # automáticamente carga el usuario en la variable @project... | [
"0.7266292",
"0.72378004",
"0.72349215",
"0.69609576",
"0.6890094",
"0.6774104",
"0.6720055",
"0.6718536",
"0.67168987",
"0.6666164",
"0.6647733",
"0.6609189",
"0.6606581",
"0.65959173",
"0.65939236",
"0.65922433",
"0.65915847",
"0.6587098",
"0.6580363",
"0.6556408",
"0.65564... | 0.0 | -1 |
Method displays an inactive view of a project | def display_preview
@project = Project.find(params[:id])
@code = @project.current_code(request.session_options[:id])
@groups = ProjectItem.find(:all, :conditions => {:project_id => params[:id]}, :order => "position")
#@nancode = "NANCODE-#{@project.id}-#{@group.id}"
# Is current group locked? If not then lock.
#@user_lock = UserLock.lock(@project, @group, request.session_options[:id])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n set_project_stat\n end",
"def show\n set_project_stat\n end",
"def index\n prepare_projects_display\n \n end",
"def show\n unless can?(:view, @project)\n redirect_to(\n root_path,\n notice: \"this project has not been shared with you yet. \"\\\n ... | [
"0.66393346",
"0.66393346",
"0.6456088",
"0.641426",
"0.63998663",
"0.6374917",
"0.63485426",
"0.6311867",
"0.627389",
"0.62712115",
"0.6258559",
"0.6258395",
"0.6238982",
"0.6210404",
"0.62008476",
"0.6191936",
"0.6184021",
"0.617638",
"0.6157483",
"0.6152623",
"0.6152089",
... | 0.62940675 | 8 |
GET /ingest_responses GET /ingest_responses.json | def index
@ingest_responses = IngestResponse.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ingest_response\n @ingest_response = IngestResponse.find(params[:id])\n end",
"def index\n \t @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def index\n @responses = Response.all\n end",
"def i... | [
"0.6515588",
"0.60847807",
"0.60614514",
"0.60614514",
"0.60614514",
"0.60614514",
"0.60614514",
"0.5902247",
"0.5891604",
"0.582929",
"0.56824917",
"0.56651634",
"0.557289",
"0.5526349",
"0.5506483",
"0.54971033",
"0.5465042",
"0.5457023",
"0.5453789",
"0.5446981",
"0.542826... | 0.81750965 | 0 |
GET /ingest_responses/1 GET /ingest_responses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @ingest_responses = IngestResponse.all\n end",
"def set_ingest_response\n @ingest_response = IngestResponse.find(params[:id])\n end",
"def create\n @ingest_response = IngestResponse.new(ingest_response_params)\n\n respond_to do |format|\n if @ingest_response.save\n for... | [
"0.77471787",
"0.6627262",
"0.5846507",
"0.56416816",
"0.56318885",
"0.5596837",
"0.5562072",
"0.5562072",
"0.5562072",
"0.5562072",
"0.5562072",
"0.55443215",
"0.5407013",
"0.5406451",
"0.5406137",
"0.53794193",
"0.5359652",
"0.533979",
"0.5326241",
"0.53060365",
"0.53003526... | 0.0 | -1 |
POST /ingest_responses POST /ingest_responses.json | def create
@ingest_response = IngestResponse.new(ingest_response_params)
respond_to do |format|
if @ingest_response.save
format.html { redirect_to @ingest_response, notice: 'Ingest response was successfully created.' }
format.json { render :show, status: :created, location: @ingest_response }
else
format.html { render :new }
format.json { render json: @ingest_response.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @ingest_responses = IngestResponse.all\n end",
"def set_ingest_response\n @ingest_response = IngestResponse.find(params[:id])\n end",
"def ingest_response_params\n params.require(:ingest_response).permit(:as_text, :status, :response_time, :staging_key, :medusa_key, :uuid)\n end"... | [
"0.7223385",
"0.6324191",
"0.6312431",
"0.552291",
"0.552291",
"0.5518179",
"0.530941",
"0.5275091",
"0.52131504",
"0.518487",
"0.5158459",
"0.5145443",
"0.51450044",
"0.51450044",
"0.51450044",
"0.51450044",
"0.51450044",
"0.51211786",
"0.5107418",
"0.5050699",
"0.5036456",
... | 0.69198775 | 1 |
PATCH/PUT /ingest_responses/1 PATCH/PUT /ingest_responses/1.json | def update
respond_to do |format|
if @ingest_response.update(ingest_response_params)
format.html { redirect_to @ingest_response, notice: 'Ingest response was successfully updated.' }
format.json { render :show, status: :ok, location: @ingest_response }
else
format.html { render :edit }
format.json { render json: @ingest_response.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n do_patch { return } # check if patch and do submission ... | [
"0.6083744",
"0.5950145",
"0.5934527",
"0.59344417",
"0.58723164",
"0.5792061",
"0.5656362",
"0.5656362",
"0.5656362",
"0.5656362",
"0.5606245",
"0.5606245",
"0.5606245",
"0.55593866",
"0.55476916",
"0.5492757",
"0.54772055",
"0.5461109",
"0.5461109",
"0.5461109",
"0.54610384... | 0.67990434 | 0 |
DELETE /ingest_responses/1 DELETE /ingest_responses/1.json | def destroy
@ingest_response.destroy
respond_to do |format|
format.html { redirect_to ingest_responses_url, notice: 'Ingest response was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.... | [
"0.6731728",
"0.6626552",
"0.64880794",
"0.6423129",
"0.6399173",
"0.62966645",
"0.6229124",
"0.61818004",
"0.6180125",
"0.6163293",
"0.6163293",
"0.6163293",
"0.6156403",
"0.6150439",
"0.6148755",
"0.61337453",
"0.61186403",
"0.6112589",
"0.61070114",
"0.61032355",
"0.609237... | 0.73371166 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_ingest_response
@ingest_response = IngestResponse.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 ingest_response_params
params.require(:ingest_response).permit(:as_text, :status, :response_time, :staging_key, :medusa_key, :uuid)
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.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
Logs a fatal error using RDFMapper::Logger | def fatal(message)
log(4, message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fatal(msg); @logger.fatal(msg); end",
"def fatal?; @logger.fatal? end",
"def fatal(msg)\n logger.fatal msg\n end",
"def fatal(*args)\n log(*args)\n fail_now\n end",
"def fatal(msg)\n log.fatal msg\n end",
"def fatal; end",
"def error(msg); @logger.error(msg); end",
"d... | [
"0.7680758",
"0.71440595",
"0.69749916",
"0.69331485",
"0.69312525",
"0.69252884",
"0.6899284",
"0.68334866",
"0.67719156",
"0.67286104",
"0.67157686",
"0.67023796",
"0.6685675",
"0.6587619",
"0.6548778",
"0.6538559",
"0.65017617",
"0.641779",
"0.6417295",
"0.64170223",
"0.64... | 0.6848076 | 7 |
Logs a warning message using RDFMapper::Logger | def warn(message)
log(2, message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(msg) log(4, msg); end",
"def warn(msg); @logger.warn(msg); end",
"def warn(msg)\r\n logger.warn(msg)\r\n end",
"def warn(msg)\n log.warn msg\n end",
"def log_warning(message)\n log(message, DebugType::WARNING)\n end",
"def warning(message)\n log.warn(message.to_s.... | [
"0.7902952",
"0.7628199",
"0.7261509",
"0.72223914",
"0.7189192",
"0.71220994",
"0.70900375",
"0.7071072",
"0.70680785",
"0.70609707",
"0.703598",
"0.7021692",
"0.6960248",
"0.69097996",
"0.6903477",
"0.6900538",
"0.6883142",
"0.68797517",
"0.6872564",
"0.6821342",
"0.6806993... | 0.6906335 | 14 |
Logs a debug message using RDFMapper::Logger | def debug(message)
log(0, message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(msg); @logger.debug(msg); end",
"def debug(msg) log(7, msg); end",
"def debug(msg)\n log.debug msg\n end",
"def debug(message) ; @log.debug(message) ; end",
"def debug(msg)\n @logger.debug(msg)\n end",
"def debug(msg)\n @logger.debug(msg)\n end",
"def log_debug(lo... | [
"0.79123384",
"0.7568327",
"0.7520986",
"0.7508135",
"0.74280024",
"0.74280024",
"0.7354606",
"0.7289977",
"0.7289977",
"0.7278019",
"0.71407014",
"0.7109454",
"0.7088561",
"0.7079713",
"0.70436895",
"0.70415443",
"0.7040856",
"0.70351946",
"0.69995296",
"0.69924253",
"0.6986... | 0.73554575 | 6 |
Logs a message using RDFMapper::Logger | def log(severity, message)
timestamp = Time.now.strftime('%m-%d %H:%M:%S')
formatted = "[%s] %s | %s" % [timestamp, self.class.name, message]
RDFMapper::Logger::Configuration.target.add(severity, formatted)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log(message); logger.info(message); end",
"def log_message(message)\r\n @log.log_message(message)\r\n end",
"def log(message)\n @logger.info message\n end",
"def log(msg)\n @logger.write(msg) if @logger\n end",
"def do_log( msg )\n log( msg )\n end",
"def log(msg)\n ... | [
"0.7080732",
"0.67737305",
"0.674578",
"0.6687699",
"0.6651415",
"0.66322875",
"0.66228396",
"0.6581298",
"0.6540793",
"0.6519941",
"0.6499634",
"0.6468031",
"0.6461623",
"0.6452612",
"0.6447722",
"0.64401096",
"0.64187324",
"0.6415404",
"0.6411733",
"0.637741",
"0.63615495",... | 0.71645135 | 0 |
get test tweet with given tweet ids | def get_test_tweet(tweet_ids)
data = Tweet.where(id: tweet_ids)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tweet(postids)\n handle_response(get(\"/content/tweet.json\", :query => {:postids => postids}))\n end",
"def retweeters_of(id, options={})\n ids_only = !!(options.delete(:ids_only))\n perform_get(\"statuses/#{id}/retweeted_by#{\"/ids\" if ids_only}.#{Twitter.format}\", options)\n end",
... | [
"0.7020693",
"0.6747889",
"0.66181135",
"0.64552146",
"0.6424763",
"0.6413869",
"0.6283739",
"0.62591636",
"0.62306535",
"0.62152284",
"0.61893",
"0.6187976",
"0.61733675",
"0.6167148",
"0.6132367",
"0.61268806",
"0.61173344",
"0.60308075",
"0.60113484",
"0.60032547",
"0.5980... | 0.8826714 | 0 |
Case 1: Check Profile menu item visible in User dropdown | def test_00010_profilepage_profile_option
@profile_page.user_dropdown.when_present.click
assert @profile_page.profile_link.present?
ensure
# close up the context menu
@profile_page.user_dropdown.click if @profile_page.profile_link.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_profile_menu\n id(\"profile_menu_btn\").wait_until(&:present?)\n id(\"profile_menu_btn\").click\n @browser.nav(css: \".drop_menu_nav.active\").wait_until(&:present?)\n sleep 1\n end",
"def check_own_page(u)\n login_as(u, scope: :user)\n check_profile_enab... | [
"0.66012824",
"0.6420858",
"0.6390645",
"0.63868964",
"0.6378446",
"0.6376455",
"0.6352999",
"0.6343482",
"0.6328269",
"0.619763",
"0.6178944",
"0.6178439",
"0.6163682",
"0.6160614",
"0.6154906",
"0.6148201",
"0.61347455",
"0.61069334",
"0.61069334",
"0.6082732",
"0.6080188",... | 0.66955787 | 0 |
Case 2: Check look and feel for Profile page | def test_00020_profilepage_profile_page
@profile_page.goto_profile
@browser.wait_until { @profile_page.profile_activity_item.present? }
assert_all_keys({
:profile_page => @profile_page.profile_page.present?,
:profile_username_match => @c.users[user_for_test].name == @profile_page.user_name,
:work_info => @profile_page.profile_workinfo_line.present?,
:profile_img => @profile_page.profile_img.present?,
:profile_edit_button => @profile_page.profile_edit_button.present?,
:profile_activity_item => @profile_page.profile_activity_item.present?,
:topnav_home => @profile_page.topnav_home.present?,
:topnav_topic => @profile_page.topnav_topic.present?,
:topnav_product => @profile_page.topnav_product.present?,
:topnav_about => @profile_page.topnav_about.present?,
:topnav_search => @profile_page.topnav_search.present?,
:topnav_logo => @profile_page.topnav_logo.present?,
# :browser_title => (@browser.title == "#{@c.users[user_for_test].name}'s Profile"),
})
#TODO
@profile_page.profile_avatar_img.when_present.hover
@profile_page.profile_avatar_camera.when_present
assert @profile_page.profile_avatar_camera.present?
# comment below assert since it is invisible when no bio
# assert @profile_page.profile_bioinfo_line.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_show_page?\n controller_name == \"profiles\"\n end",
"def profile_show_page?\n controller_name == \"profiles\"\n end",
"def check_profile_enabled(u)\n fn = u.first_name\n ln = u.last_name\n un = u.username\n e = u.email\n visit user_path(u)\n assert page.has_css?('title', ... | [
"0.6695823",
"0.6694643",
"0.6587368",
"0.6502402",
"0.6256385",
"0.6242666",
"0.6223234",
"0.6223234",
"0.620751",
"0.6192889",
"0.6176971",
"0.61722904",
"0.6148568",
"0.6096605",
"0.6062726",
"0.6050626",
"0.60418177",
"0.60418177",
"0.60418177",
"0.60418177",
"0.60418177"... | 0.57540625 | 41 |
============ ADMIN USER PROFILE FEILD TESTS ========================== | def test_00070_add_feild_as_show_feild
first_name = @c.users[user_for_test].name.split(' ')[0]
# set first name feild as not show
@admin_profile_page.navigate_in
@admin_profile_page.custom_profile_feild "First Name", {0 => false }
# admin can't see first name feild
@profile_page.goto_profile
url = @browser.url
@browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }
assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)
# user2 can't see first name feild
@login_page.about_login("regular_user2", "logged")
@browser.goto url
@browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }
assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)
# set first name feild as show
@login_page.about_login("network_admin","logged")
@admin_profile_page.navigate_in
@admin_profile_page.custom_profile_feild "First Name", {0 => true, 2 => false }
# admin can't see first name feild]
@browser.goto url
@browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }
assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)
# user2 can't see first name feild
@login_page.about_login("regular_user2", "logged")
@browser.goto url
@browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }
assert (!@profile_page.profile_page_author_name_betaon.text.include? first_name)
# set first name feild as public
@login_page.about_login("network_admin","logged")
@admin_profile_page.navigate_in
@admin_profile_page.custom_profile_feild "First Name", {0 => true, 2 => true }
# admin can see first name feild
@browser.goto url
@browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }
assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)
# user2 can see first name feild
@browser.goto url
@browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }
assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)
ensure
# set first name feild as public
@login_page.about_login("network_admin","logged")
@admin_profile_page.navigate_in
@admin_profile_page.custom_profile_feild "First Name", {2 => true }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_user_profile\n\n # Get the Current App\n @app = MailfunnelsUtil.get_app\n\n # If the User is not an admin redirect to error page\n if !@app.is_admin or @app.is_admin === 0\n redirect_to '/error_page'\n end\n\n # Get User from DB\n @user = User.find(params[:user_id])\n\n # Get... | [
"0.6697282",
"0.66837656",
"0.6680589",
"0.66439736",
"0.6575091",
"0.654461",
"0.65170854",
"0.64440066",
"0.64037865",
"0.635303",
"0.635303",
"0.63437724",
"0.63131416",
"0.6312261",
"0.6304417",
"0.6304417",
"0.62786245",
"0.62638956",
"0.625678",
"0.6247448",
"0.62380755... | 0.7181815 | 0 |
Case 3: Check newly created question appears in Profile page as activity | def test_00120_profilepage_check_new_activity_feed
@topicdetail_page = @topiclist_page.go_to_topic("A Watir Topic")
title = "Test q created by Watir - #{get_timestamp}"
@topicdetail_page.create_conversation(type: :question,
title: title,
details: [{type: :text, content: "Watir test description"}])
@profile_page.goto_profile
@browser.wait_until { !@profile_page.question_list_in_activity_pane.activity_at_title(title).nil? }
activity_card = @profile_page.question_list_in_activity_pane.activity_at_title(title)
activity_card.click_conv_link
@browser.wait_until { @convdetail_page.convdetail.present? }
assert @convdetail_page.root_post_title.text =~ /#{title}/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_00130_profilepage_check_activity_feed_link\n @profile_page.goto_profile\n @browser.wait_until { @profile_page.profile_activity_item.present? }\n\n @browser.wait_until { @profile_page.question_list_in_activity_pane.activity_list.size > 0 }\n activity_card = @profile_page.question_list_in_activi... | [
"0.629241",
"0.61136794",
"0.61099684",
"0.608267",
"0.59902734",
"0.595141",
"0.5930556",
"0.59250474",
"0.5861138",
"0.58571285",
"0.5845736",
"0.58255875",
"0.58255875",
"0.5823767",
"0.5821826",
"0.5807265",
"0.57772523",
"0.57772523",
"0.57761955",
"0.57707685",
"0.57658... | 0.67543834 | 0 |
Case 4: Check conversation link text in activity tab is the correct title. | def test_00130_profilepage_check_activity_feed_link
@profile_page.goto_profile
@browser.wait_until { @profile_page.profile_activity_item.present? }
@browser.wait_until { @profile_page.question_list_in_activity_pane.activity_list.size > 0 }
activity_card = @profile_page.question_list_in_activity_pane.activity_list[0]
conv = activity_card.conv_title
activity_card.click_conv_link
@browser.wait_until { @convdetail_page.convdetail.present? }
assert @convdetail_page.convdetail.text.include? conv
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end",
"def test_00120_profilepage_check_new_activity_feed\n @topicdetail_page = @... | [
"0.6332013",
"0.60098773",
"0.57994413",
"0.57971084",
"0.5736216",
"0.57176596",
"0.56669134",
"0.5641956",
"0.5579777",
"0.5548925",
"0.55159205",
"0.54990965",
"0.54861456",
"0.5474683",
"0.5472574",
"0.546487",
"0.5450934",
"0.5438192",
"0.54363656",
"0.5431333",
"0.54282... | 0.63846993 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_task
@task = Task.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 task_params
params.require(:task).permit(:content, :status)
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 |
Create a new message and send an SMS text. | def create
@message = Message.new(message_params)
if @message.save
@message.action = 'SEND'
@message.save
# Send SMS text
boot_twilio
sms = @client.messages.create(
body: @message.text,
from: Rails.application.secrets.twilio_number,
to: @message.number,
)
redirect_to @message, alert: "SMS Text sent."
else
render 'new'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def twilio_send_text_message!(client,phone_num,msg)\n begin\n sms = client.account.sms.messages.create(\n :from => TWILIO_PHONE,\n :to => phone_num,\n :body => msg)\n rescue Exception => e\n ... | [
"0.8168052",
"0.8104239",
"0.8043112",
"0.797992",
"0.7815659",
"0.75667125",
"0.7514859",
"0.75081027",
"0.75081027",
"0.74867016",
"0.7483985",
"0.73952705",
"0.73885745",
"0.73453254",
"0.73058844",
"0.7283449",
"0.7258611",
"0.7229281",
"0.71881044",
"0.7187127",
"0.71710... | 0.83327514 | 0 |
Webhook for Twilio to forward replies. Store any replies in the db and send back a a simple reply. | def reply
message_body = params["Body"]
from_number = params["From"]
@recent_msg = Message.where(number: from_number).last # Get the name of this user if possible
# Some random schmoe not in our db is trying to text me.
if @recent_msg.blank?
head 200, "content_type" => 'text/html'
return
end
user = @recent_msg.user
# Store reply in db and send back a simple text.
@message = Message.new(user: user, number: from_number, text: message_body, action: 'REPLY')
if @message.save
boot_twilio
sms = @client.messages.create(
from: Rails.application.secrets.twilio_number,
to: from_number,
body: "Hello from the other side! Your number is #{from_number}."
)
end
head 200, "content_type" => 'text/html'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reply # acts as endpoint\n \tmessage_body = params[\"Body\"] # grab params from Twilio's request\n \tfrom_number = params[\"From\"]\n \tboot_twilio\n \tsms = @client.messages.create( # send to inbound number made by end user\n from: Rails.application.secrets.twilio_from_number,\n to: from_number,... | [
"0.68369275",
"0.6497675",
"0.6397914",
"0.6032224",
"0.6014355",
"0.5987166",
"0.59555733",
"0.59529823",
"0.59413064",
"0.59219164",
"0.5912246",
"0.591011",
"0.5907606",
"0.588859",
"0.5840116",
"0.5835873",
"0.5798903",
"0.5788026",
"0.57879084",
"0.5768142",
"0.57342446"... | 0.7083581 | 0 |
GET /parkings GET /parkings.json | def index
@parking = Parking.all
render_default_format(@parking,true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @parkings = Parking.all\n end",
"def index\n @parkings = Parking.all\n end",
"def index\n @parks = Park.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parks }\n end\n end",
"def index\n @parkers = Parker.all\n\t\trespond_... | [
"0.75433546",
"0.75433546",
"0.71869123",
"0.7128103",
"0.70768285",
"0.68660986",
"0.6721263",
"0.6721263",
"0.6720346",
"0.6677762",
"0.66270834",
"0.6560818",
"0.6548017",
"0.6512579",
"0.6426348",
"0.635459",
"0.635459",
"0.6348812",
"0.6333269",
"0.6326114",
"0.63237953"... | 0.65394 | 13 |
GET /parkings/1 GET /parkings/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @parkings = Parking.all\n end",
"def index\n @parkings = Parking.all\n end",
"def show\n\t\t\t\tparking = Parking.where(plate: params[:id])\n\t\t\t\trender json: {status: 'SUCCESS', message:'Loaded parking', data:parking},status: :ok\n\t\t\tend",
"def index\n @parks = Park.all\n\n r... | [
"0.7297584",
"0.7297584",
"0.7143603",
"0.7088768",
"0.6819119",
"0.6799518",
"0.66917336",
"0.656221",
"0.656221",
"0.6561918",
"0.6561348",
"0.64943594",
"0.64920753",
"0.64908165",
"0.6464314",
"0.6464314",
"0.6464314",
"0.6444182",
"0.64098",
"0.6334966",
"0.6320834",
"... | 0.0 | -1 |
POST /parkings POST /parkings.json | def create
@parking = Parking.new(parking_params)
if @parking.save
render_success_format('parking created correctly', @parking)
end
rescue Exception => e
render_default_error e, 401
e.inspect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @parking = Parking.new(parking_params)\n\n if @parking.save\n render :show, status: :created, location: @parking\n else\n render json: @parking.errors, status: :unprocessable_entity\n end\n end",
"def create\n @park = Park.new(params[:park])\n\n respond_to do |format|\n ... | [
"0.72410816",
"0.6844884",
"0.6804215",
"0.67680234",
"0.6766409",
"0.66605103",
"0.64655405",
"0.6420037",
"0.63950205",
"0.63653034",
"0.6332165",
"0.6318542",
"0.6293447",
"0.6293447",
"0.6281778",
"0.62654734",
"0.62414163",
"0.62053674",
"0.61876696",
"0.6131424",
"0.611... | 0.62670946 | 15 |
PATCH/PUT /parkings/1 PATCH/PUT /parkings/1.json | def update
if @parking.update(@parking_params)
render_success_format("correctly edited parking", @parking)
end
rescue StandardError => e
Airbrake.notify(e)
raise e
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @parking.update(parking_params)\n format.html { redirect_to @parking, notice: 'Parking was successfully updated.' }\n format.json { render :show, status: :ok, location: @parking }\n else\n format.html { render :edit }\n format.json {... | [
"0.69329345",
"0.6884731",
"0.67918414",
"0.6750798",
"0.66994107",
"0.6688655",
"0.6688655",
"0.6604631",
"0.6565727",
"0.64296055",
"0.64269423",
"0.6417735",
"0.63649464",
"0.6337622",
"0.63290346",
"0.6297221",
"0.6262193",
"0.62013125",
"0.61526704",
"0.61175025",
"0.610... | 0.6342272 | 13 |
DELETE /parkings/1 DELETE /parkings/1.json | def destroy
@parking.destroy
render_destroy_format("parking removed")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @park = Park.find(params[:id])\n @park.destroy\n\n respond_to do |format|\n format.html { redirect_to parks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @park.destroy\n respond_to do |format|\n format.html { redirect_to parks_url }\n f... | [
"0.74208194",
"0.7415782",
"0.7190771",
"0.7190237",
"0.71882445",
"0.7092268",
"0.7092268",
"0.70178413",
"0.7010613",
"0.7003925",
"0.6997028",
"0.6917855",
"0.6899268",
"0.6876851",
"0.6868347",
"0.68671685",
"0.68505186",
"0.68375194",
"0.68144566",
"0.6770695",
"0.671972... | 0.68843526 | 13 |
Use callbacks to share common setup or constraints between actions. | def set_parking
@parking = Parking.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def parking_params
params.permit(:name, :addres, :phone, :quota)
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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Only grab the interviews from the returned Solr documents. A collection level description is included so we want to exclude that. | def response
@response ||= datasource_response['docs']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interviews\n @interviews ||= solr_documents.find_all do |solr_document|\n # it is beard_interview because this is how the collection is known\n # in the drupal site\n solr_document['bundle'] == 'beard_interview'\n end\n end",
"def solr_resp_doc_ids_on... | [
"0.7864076",
"0.57509524",
"0.5744941",
"0.5679993",
"0.56425303",
"0.5617472",
"0.54913825",
"0.54817975",
"0.5469443",
"0.5459046",
"0.54196674",
"0.541526",
"0.53456146",
"0.53418726",
"0.5316076",
"0.5299571",
"0.5265537",
"0.52649087",
"0.52627337",
"0.5252254",
"0.52351... | 0.0 | -1 |
Params to send with the request to the JSON API | def datasource_params
{
rows: dataset_size
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_params; end",
"def params\n @json['params']\n end",
"def params() request.params end",
"def http_params\n {}\n end",
"def request_params( params = {} )\n params\n end",
"def request_params(method)\n @request_params = {\n :api_key =... | [
"0.7073567",
"0.70065796",
"0.6957568",
"0.6924443",
"0.6894717",
"0.687987",
"0.68589234",
"0.6797238",
"0.67865026",
"0.67561084",
"0.66818464",
"0.6663053",
"0.65790004",
"0.6554719",
"0.6532011",
"0.6521297",
"0.6498317",
"0.64866304",
"0.64845306",
"0.64601845",
"0.64526... | 0.0 | -1 |
Connect to collection JSON API | def datasource
@datasource ||= endpoint_connection.get(endpoint_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection(options={})\n response = client.get(api_path, options)\n\n if response.success?\n collection = []\n\n response.body.each do |json|\n collection << new(json)\n end\n\n collection\n else\n []\n end\n end",
"def ... | [
"0.67710626",
"0.67182624",
"0.66410667",
"0.6596116",
"0.6452761",
"0.63444006",
"0.62407297",
"0.6161838",
"0.6150071",
"0.6118352",
"0.6108818",
"0.6087364",
"0.6057323",
"0.60356045",
"0.6016457",
"0.5990206",
"0.5983593",
"0.5980945",
"0.5980667",
"0.594701",
"0.59242797... | 0.0 | -1 |
Use Faraday to connect to the collection's JSON API | def endpoint_connection
@endpoint_connection ||= Faraday.new(url: endpoint_url) do |faraday|
faraday.request :basic_auth, user, password
faraday.params = datasource_params
faraday.adapter :net_http
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection\n @connection ||= Faraday.new(api_endpoint) do |http|\n http.headers[:accept] = \"application/json, */*\"\n http.headers[:user_agent] = user_agent\n\n http.request :authorization, :Bearer, -> { token_store.get_token }\n http.request :json\n\n http.... | [
"0.7234193",
"0.7130193",
"0.7059596",
"0.7059596",
"0.6866371",
"0.68513054",
"0.6843171",
"0.6783695",
"0.67773294",
"0.67689437",
"0.67536277",
"0.67476207",
"0.674754",
"0.6731471",
"0.6709002",
"0.66859764",
"0.66702354",
"0.66602033",
"0.6655382",
"0.6629673",
"0.659528... | 0.6362299 | 37 |
check if we need password to update user data ie if password or email was changed extend this as needed | def needs_password?(user, params)
user.email != params[:user][:email] ||
!params[:user][:password].blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def needs_update_password? user, params\n user.email != params[:user][:email] ||\n params[:user][:password].present? ||\n params[:user][:password_confirmation].present?\n end",
"def need_change_password?\n password_change_requested? || password_too_old?\n end",
"def check_password... | [
"0.78474206",
"0.7633188",
"0.7595944",
"0.7529853",
"0.74996895",
"0.74826044",
"0.74752384",
"0.7472026",
"0.74320877",
"0.73250824",
"0.72857994",
"0.7284436",
"0.72496825",
"0.7151641",
"0.714748",
"0.7134663",
"0.7134663",
"0.7133602",
"0.71250427",
"0.711971",
"0.711645... | 0.67794055 | 91 |
I worked on this challenge by myself. shortest_string is a method that takes an array of strings as its input and returns the shortest string +list_of_words+ is an array of strings shortest_string(array) should return the shortest string in the +list_of_words+ If +list_of_words+ is empty the method should return nil Your Solution Below | def shortest_string(list_of_words)
shortest = list_of_words[0]
for word in 1...list_of_words.length
if shortest.length > list_of_words[word].length then
shortest = list_of_words[word]
end
end
return shortest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_string(list_of_words)\n\n#If presented with an array of mixed objects, maybe not all strings\n# strings = []\n# list_of_words.each do |i|\n# if i.is_a? String\n# strings.push(i)\n# end\n# end\n\n\n\n if list_of_words.length ==0\n return nil\n else\n i=0\n shorty = list_o... | [
"0.88458776",
"0.88090134",
"0.8795479",
"0.8773666",
"0.8736561",
"0.8684509",
"0.8656812",
"0.86467165",
"0.86414707",
"0.8640535",
"0.8617546",
"0.85798335",
"0.8575435",
"0.85634476",
"0.85560733",
"0.85401434",
"0.8524985",
"0.8493026",
"0.84599406",
"0.83987236",
"0.838... | 0.85023737 | 17 |
GET /profiles GET /profiles.json | def index
@profiles = Profile.all
@user = current_user
if current_user.profile
@profile = current_user.profile
@explores = @profile.explore_categories.uniq
@guides = @profile.guide_categories.uniq
@projects = @profile.projects.includes(:categories).sort_by_created_desc
@explore_ratings = @profile.explore_ratings.includes(:category).sort_by_created_desc.group_by(&:category)
@guide_ratings = @profile.guide_ratings.includes(:category).sort_by_created_desc.group_by(&:category)
@new_profile = false
else
@new_profile = true
@profile = Profile.new
@explores = []
@guides = []
end
@filterrific = initialize_filterrific(
Category,
params[:filterrific]
) or return
@categories = @filterrific.find.page(params[:page])
respond_to do |format|
format.html
format.js
end
@list = current_user.profile.explore_categories.pluck(:id).uniq
@listg = current_user.profile.guide_categories.pluck(:id).uniq
@category = Category.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n authorize Profile\n @profiles = ProfilePolicy::Scope.new(current_user, @user.profiles).resolve\n render json: @profiles\n end",
"def get_default_profile \n get(\"/profiles.json/default\")\nend",
"def profiles \n personid = params[:id]\n @response = JSON.parse(current_user.access... | [
"0.7720244",
"0.7511753",
"0.7511205",
"0.7474065",
"0.747391",
"0.7429771",
"0.7368022",
"0.7368022",
"0.7277252",
"0.72754085",
"0.72646606",
"0.7194632",
"0.71890444",
"0.7109752",
"0.7068873",
"0.7061951",
"0.7061951",
"0.7061951",
"0.7036681",
"0.70242476",
"0.699903",
... | 0.0 | -1 |
GET /profiles/1 GET /profiles/1.json | def show
@profile = Profile.includes(:user).friendly.find(params[:id])
@user = @profile.user
@explores = @profile.explore_categories.uniq
@guides = @profile.guide_categories.uniq
@explore_categories = @profile.explore_categories.uniq
@guide_categories = @profile.guide_categories.uniq
@projects = @profile.projects
@explore_ratings = @profile.explore_ratings.includes(:category).sort_by_created_desc.group_by(&:category)
@guide_ratings = @profile.guide_ratings.includes(:category).sort_by_created_desc.group_by(&:category)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_profile \n get(\"/profiles.json/default\")\nend",
"def my_profiles\n @user = User.find(params[:user_id])\n @profiles = @user.profiles\n end",
"def show\n profile = Profile.find(params[:id])\n render status: 200, json: profile\n end",
"def index\n authorize Profile\n @profi... | [
"0.7775649",
"0.74931335",
"0.74876684",
"0.736598",
"0.7305961",
"0.7302657",
"0.7301793",
"0.72450936",
"0.72319347",
"0.72319347",
"0.72319347",
"0.72181976",
"0.72181976",
"0.71651715",
"0.71410364",
"0.7114219",
"0.70800215",
"0.7046293",
"0.70175827",
"0.69905627",
"0.6... | 0.0 | -1 |
POST /profiles POST /profiles.json | def create
@params = profile_params
if @params["country"]
@params["country"] = CS.get[profile_params[:country].to_sym]
end
if @params["state"].size==2
@states = CS.get profile_params[:country].to_sym
@params["state"] = @states[profile_params[:state].to_sym]
end
if current_user.profile #if Profile already exists
@profile = current_user.profile
@projects = @profile.projects
if !params["edit-profile-languages"].empty?
@lan_array = JSON.parse(params["edit-profile-languages"])
@params["languages"] = @lan_array
end
if !@profile.profile_photo.nil? & params["profile_photo"].empty?
@params["profile_photo"] = @profile.profile_photo
else
@params["profile_photo"] = params["profile_photo"].empty? ? nil : params["profile_photo"]
end
if !@profile.banner_photo.nil? & params["banner_photo"].empty?
@params["banner_photo"] = @profile.banner_photo
else
@params["banner_photo"] = params["banner_photo"].empty? ? nil : params["banner_photo"]
end
respond_to do |format|
if @profile.update(@params)
format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' }
format.json { render :show, status: :ok, location: @profile }
else
format.html { render :edit }
format.json { render json: @profile.errors, status: :unprocessable_entity }
end
end
else
if(params[:first_signup] == "true")
@user = current_user
@profile = Profile.new() #create new Profile
@user.profile = @profile
@lan_array = JSON.parse(params["languages"])
@params["languages"] = @lan_array
coordinates = Geocoder.search(profile_params[:city]).first.coordinates
latitude = coordinates[0]
longitude = coordinates[1]
@params["time_zone"] = Timezone.lookup(latitude,longitude).name
respond_to do |format|
if @profile.update(@params)
format.html { redirect_to '/profile/explores', notice: 'Profile was successfully updated.' }
format.json { render :show, status: :ok, location: @profile }
else
format.html { render :edit }
format.json { render json: @profile.errors, status: :unprocessable_entity }
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @profile = current_user.profiles.build(profile_params)\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render action: 'show', status: :created, location: @profile }\n else\n ... | [
"0.73701555",
"0.7367171",
"0.72288865",
"0.71786684",
"0.7172963",
"0.7170674",
"0.71145105",
"0.7096289",
"0.707034",
"0.7002038",
"0.7002038",
"0.7002038",
"0.7002038",
"0.7002038",
"0.7002038",
"0.7002038",
"0.6997514",
"0.69700205",
"0.69617796",
"0.6937631",
"0.6937631"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_profile
@profile = Profile.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 profile_params
params.permit(:state,:country,:profile_photo,:banner_photo,:time_zone,:bio,:contact_no,:birth_date,:city,:state,:languages)
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.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def user_params
params.require(:user).permit(:id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
END BASIC CRUD OPS | def trips
flight = Flight.where("id = ?", params[:id]).take
if flight.nil?
render :json => {errors: "404"}, :status => 404
else
respond_with( flight.trips )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crud\n # TODO: The `Array` below has the four letters that make up the `CRUD`\n # acronym. Update each element of the array so that you write out the\n # four verbs that describe the CRUD actions.\n\n ['C', 'R', 'U', 'D']\nend",
"def crud *args\n @crud = args.first if args.size > 0\n end",
"def... | [
"0.62493694",
"0.61987364",
"0.610377",
"0.60733473",
"0.60461336",
"0.59714407",
"0.59521455",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633",
"0.5862633"... | 0.0 | -1 |
Event action. Remove self from the checkout, and record the time. | def run
SoopaStore.checkout.cashier = nil
@cashier.checkout = nil
@cashier.departure_time = SoopaStore.current_time
puts "Time #{SoopaStore.current_time} : Cashier #{@cashier.eid} "\
"leaves checkout (worked #{@cashier.time_in_store} time units)"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @clock_event.destroy\n end",
"def checkout!\n self.checked_out_at = Time.now\n self.save\n end",
"def checkout!\n self.checked_out_at = Time.now\n self.save\n end",
"def destroy\n self.current_checkin.touch :checked_out_at\n redirect_to :root\n end",
"def remove_time\... | [
"0.6223422",
"0.6219592",
"0.6219592",
"0.619138",
"0.59102166",
"0.58904576",
"0.585432",
"0.5829561",
"0.58119524",
"0.57798094",
"0.5726265",
"0.5681949",
"0.5680118",
"0.56780183",
"0.56663454",
"0.5659712",
"0.5649149",
"0.56422913",
"0.563562",
"0.56333905",
"0.56256807... | 0.5787445 | 9 |
Find one object directly by id. | def find_by_id(id, options = {})
if item = Dynamoid::Adapter.read(self.table_name, id, options)
obj = self.new(item)
obj.new_record = false
return obj
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(id)\n find(id)\n end",
"def find_by_id(id)\n find_by_attributes(:id => id).first\n end",
"def find(id)\n where({'id' => \"#{id}\"}).first\n end",
"def find(id)\n first(\"Id = '#{id}'\")\n end",
"def find(id)\n @objects[id]\n ... | [
"0.8567452",
"0.8541385",
"0.84857833",
"0.8484026",
"0.8480626",
"0.84501445",
"0.83997905",
"0.8369125",
"0.8369125",
"0.8344392",
"0.8245107",
"0.82404196",
"0.823217",
"0.81917626",
"0.8190428",
"0.8175505",
"0.8166819",
"0.8126466",
"0.80978024",
"0.80978024",
"0.8083095... | 0.74249655 | 64 |
Find using exciting method_missing finders attributes. Uses criteria chains under the hood to accomplish this neatness. | def method_missing(method, *args)
if method =~ /find/
finder = method.to_s.split('_by_').first
attributes = method.to_s.split('_by_').last.split('_and_')
chain = Dynamoid::Criteria::Chain.new(self)
chain.query = Hash.new.tap {|h| attributes.each_with_index {|attr, index| h[attr.to_sym] = args[index]}}
if finder =~ /all/
return chain.all
else
return chain.first
end
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(method_id, *arguments)\n if match = /find_(all_by|by)_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n finder = determine_finder(match)\n\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n #Overrride facets to... | [
"0.6754671",
"0.6716648",
"0.6532506",
"0.6513471",
"0.64139366",
"0.63808244",
"0.6316885",
"0.62967867",
"0.620881",
"0.6196353",
"0.6181094",
"0.61756027",
"0.61300695",
"0.6127275",
"0.6070119",
"0.60488373",
"0.6042691",
"0.5993591",
"0.5946261",
"0.5920781",
"0.5919341"... | 0.72799927 | 0 |
Constructor def initialize(t_factura, t_recibo, view) | def initialize(cliente_ruc_o_cedula, tarifa_servicio)
super()
unless cliente_ruc_o_cedula.blank?
if cliente_ruc_o_cedula.include?"RUC"
@t_cliente = TEmpresa.find_by_rif(cliente_ruc_o_cedula).t_cliente
else
@t_cliente = TPersona.find_by_cedula(cliente_ruc_o_cedula).t_cliente
end
end
@tarifa_servicio = TTarifaServicio.find_by_codigo(tarifa_servicio) unless tarifa_servicio.blank?
@cliente_ruc_o_cedula = cliente_ruc_o_cedula
@tarifa_servicio = tarifa_servicio
@i = 1
# @t_recibo = t_recibo
# @t_factura = t_factura
# @t_resolucion = @t_factura.t_resolucion
# @t_cliente = t_cliente
# @t_empresa = @t_cliente.persona.try(:rif) ? @t_cliente.persona : nil
# @t_persona = @t_cliente.persona.try(:cedula) ? @t_cliente.persona : nil
# @t_otro = @t_cliente.persona.try(:identificacion) ? @t_cliente.persona : nil
@meses = [1 => "Enero", 2 => "Febrero", 3 => "Marzo", 4 => "Abril", 5 => "Mayo", 6 => "Junio", 7 => "Julio", 8 => "Agosto", 9 => "Septiembre", 10 => "Octubre", 11 => "Noviembre", 12 => "Diciembre"]
font_size 10
document_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(t_factura)\n super()\n # @t_recibo = t_recibo\n @t_factura = t_factura\n @t_resolucion = @t_factura.t_resolucion\n @t_cliente = @t_resolucion.try(:t_cliente) || @t_factura.try(:t_cliente)\n @t_empresa = @t_cliente.persona.try(:rif) ? @t_cliente.persona : nil... | [
"0.84371054",
"0.83809894",
"0.6828498",
"0.67954695",
"0.67552066",
"0.67105955",
"0.66711086",
"0.6579698",
"0.65033406",
"0.6383523",
"0.635105",
"0.6343063",
"0.6333825",
"0.6320653",
"0.63152415",
"0.6300322",
"0.6290269",
"0.6268496",
"0.62665874",
"0.6225277",
"0.62233... | 0.7237831 | 2 |
Create a new +FulltextWriter+. You can pass the path option to write the full text field information to a file, otherwise the path will be nil and the +FulltextWriter+ will use an in memory buffer. In windows/dos, the file will be written to in binary mode. Valid options: [:path] The file that the full text field information will be written to. | def initialize(options = {})
@path = options[:path]
if @path
@io = File.open(@path, "wb")
else
initialize_in_memory_buffer
@io = @memory_io
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(options = {})\n validate_options(options, :force_generation, :linebreak_encoding, :path)\n\n path = options[:path].nil? ? @path : to_pathname(options[:path])\n\n raise ArgumentError, 'No path given' unless path\n\n options.delete(:path)\n\n path.open('w') do |file|\n ... | [
"0.5409733",
"0.5188577",
"0.5081961",
"0.5070599",
"0.50676554",
"0.4984266",
"0.49804834",
"0.49491066",
"0.4943897",
"0.49392042",
"0.49186707",
"0.4901392",
"0.48653877",
"0.48615876",
"0.48493212",
"0.48480272",
"0.4845966",
"0.4845966",
"0.48289117",
"0.48174334",
"0.48... | 0.0 | -1 |
Use a full text reader to initialize the data in this writer. This operation can happen before or after records have been added to the writer. | def merge(fulltext_reader)
fulltext_reader.dump_data do |data|
@io.write data
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(reader)\n @reader = reader\n end",
"def initializing_reader(key); end",
"def initialize(structured_reader,&block)\n @reader = structured_reader\n instance_eval( &block ) if block\n end",
"def initialize(line_reader, cleanse_header: true, **args)\n @tabular = IO... | [
"0.5739674",
"0.5406079",
"0.5326524",
"0.5278126",
"0.52205515",
"0.521685",
"0.5180182",
"0.5159452",
"0.5142232",
"0.51300263",
"0.5109225",
"0.50970906",
"0.5070527",
"0.50679934",
"0.5049411",
"0.5046865",
"0.50230974",
"0.49947837",
"0.49904034",
"0.49236354",
"0.490808... | 0.54918605 | 1 |
Add the field information for an entry to the fulltext data file. The +id+ uniquely identifies this entry and correlates the to identifier used in the fragment, suffix and map writers. The +field_hash+ contains a hash of the fields and values that will be stored for the record. The key for each field in the hash should match the key used when creating fields in the field_infos. | def add(primary_key, fields, analyzers, suffix_array_writer)
base_offset = @io.pos
write_header(primary_key, fields)
fields.each_with_index {|field,index|
data = field || ''
suffix_offset = store_field(data)
suffix_array_writer.append_suffixes(analyzers[index], data, suffix_offset, base_offset, index)
}
write_footer((@io.pos-base_offset)+5)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_field(identifier, value = nil)\n @fields << build_field(identifier, value)\n end",
"def add_doc(doc_id, fields, opts = {})\n call(ft_add(doc_id, fields, opts))\n end",
"def update_field(id, params = {})\n put(\"/fields/#{id}\", params)\n end",
"def add_hash(id, hash, source)\n... | [
"0.54879373",
"0.5239529",
"0.5218971",
"0.5156283",
"0.50362796",
"0.4996911",
"0.4991659",
"0.49304727",
"0.4926735",
"0.4878728",
"0.48391256",
"0.48348498",
"0.48231858",
"0.48231858",
"0.47769153",
"0.47769153",
"0.47769153",
"0.4756484",
"0.47367236",
"0.47358698",
"0.4... | 0.47299322 | 20 |
Write a trailing null character and close the file. | def finish!
@io.write "\0"
if (@path)
@io.fsync
@io.close
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null_finish\n file.write(\"\\r\" + ' ' * @last_printed_length + \"\\r\")\n end",
"def newline()\n @file.write(\"\\n\")\n end",
"def write_footer(file)\n Record.new(GRT_ENDSTR).write(file)\n end",
"def write_nil\n end",
"def ensure_trailing_newline(file_text)\n count_trailing... | [
"0.7680361",
"0.6606603",
"0.61468923",
"0.6121093",
"0.6026801",
"0.6022459",
"0.5989168",
"0.5989168",
"0.5989168",
"0.5807444",
"0.58068985",
"0.57245106",
"0.57088774",
"0.5562351",
"0.5518954",
"0.55150175",
"0.54587936",
"0.54335076",
"0.5419411",
"0.54042494",
"0.53878... | 0.6050468 | 4 |
Write the total size of the record (for seeking) as a single long. To calculate the total size, select all of the fields from the fields array and sum the field data size and field header size. Also write the +primary_key+ for lookups later | def write_header(primary_key, fields)
# 5 == field_header + field_footer size
total_size = fields.inject(0){|sum,field| sum += (field || '').size + 5}
# 13 == record header + record footer
total_size += 13
@io.write [total_size, primary_key].pack("VV")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_record_size\n File.open(File.join(@root + ['size']),'w+') do |f|\n Marshal.dump(@records_size,f)\n end\n end",
"def byte_size()\n if @record and RECORD_INFO[@record.type].size > 0 then\n RECORD_INFO[@record.type].size * @value.length\n else\n ... | [
"0.7237358",
"0.6444148",
"0.630865",
"0.6305491",
"0.6273946",
"0.6184604",
"0.61776",
"0.6101791",
"0.60695064",
"0.6056409",
"0.6010986",
"0.5936996",
"0.5936996",
"0.59357893",
"0.5926518",
"0.5912054",
"0.5851281",
"0.5851281",
"0.5837606",
"0.58316123",
"0.58316123",
... | 0.60943544 | 8 |
Write a leading null and the size of the record (for seeking) as a single long. | def write_footer(size)
@io.write [size].pack("V")
@io.write "\0"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_long(*n); end",
"def write_long(file, long, md)\n long = [long].pack('q>')\n md << long\n file.write(long)\n end",
"def write_null\n\t\twrite_byte(5)\n\tend",
"def write_int64(*n); end",
"def null_finish\n file.write(\"\\r\" + ' ' * @last_printed_length + \"\\r\")\n end"... | [
"0.6568011",
"0.61199415",
"0.5792194",
"0.5734087",
"0.5707356",
"0.5671999",
"0.56147814",
"0.5583096",
"0.5545582",
"0.5538073",
"0.5530865",
"0.5412038",
"0.5356997",
"0.5332332",
"0.5332332",
"0.5332332",
"0.5332332",
"0.5320529",
"0.5288124",
"0.52708125",
"0.5251532",
... | 0.0 | -1 |
Write the field to the current input/output stream. Each field will be stored with a header that contains the field size (as longs) followed by the +data+ for the field (the actual text or value) and a trailing \0. This function returns the offset to the start of the offset of the field header in the input/output stream. | def store_field(data)
@io.write [data.size].pack("V")
offset = @io.pos
@io.write data
@io.write "\0"
offset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offset\n fil_header[:offset]\n end",
"def write_hdr(field, value)\n @header_data.write_int(field, value)\n @header_modified = true\n end",
"def write_header(primary_key, fields)\n # 5 == field_header + field_footer size\n total_size = fields.inject(0){|sum,field| sum += (field || '').s... | [
"0.6046741",
"0.56584203",
"0.56548214",
"0.54105955",
"0.53932565",
"0.5211581",
"0.5184494",
"0.5178961",
"0.5177128",
"0.5155409",
"0.5146067",
"0.51132095",
"0.5107737",
"0.5037094",
"0.50356054",
"0.5032459",
"0.50075847",
"0.49992645",
"0.49942446",
"0.4993951",
"0.4978... | 0.71350044 | 0 |
this function searches for the port with fiber_in_id=0, considering this to be the first port in a connection trace | def get_first_port
flist = Fiberstrand.where("connection_id = " + self.id.to_s)
fportid=0
# binding.pry
flist.each do |fiber|
fport = Devport.find_by_id(fiber.porta)
fportid=fport.id
break if (fport.fiber_in_id==0)
fportid=0
end
fportid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_port(port)\n port += 1 while port_bound?('127.0.0.1', port)\n port\nend",
"def search_peers_by_port (port)\r\n $peers.length.times do |i|\r\n return $peers[i] if ($peers[i].port == port.to_i)\r\n end\r\n return -1\r\nend",
"def get_last_port\n flist = Fiberstrand.where(\"connectio... | [
"0.5997649",
"0.59651273",
"0.59253156",
"0.5897701",
"0.57866263",
"0.56884354",
"0.54501754",
"0.5445254",
"0.5331614",
"0.5327624",
"0.5290758",
"0.525217",
"0.5224758",
"0.5183297",
"0.5160699",
"0.51462764",
"0.51011467",
"0.5093354",
"0.50456524",
"0.5045396",
"0.504362... | 0.7092491 | 0 |
this function searches for the port with fiber_out_id=0, considering this to be the last port in a connection trace...so to get the destination | def get_last_port
flist = Fiberstrand.where("connection_id = " + self.id.to_s)
#binding.pry
fportid=0
# binding.pry
flist.each do |fiber|
fport = Devport.find_by_id(fiber.portb)
fportid=fport.id
break if (fport.fiber_out_id==0)
fportid=0
end
fportid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_first_port\n flist = Fiberstrand.where(\"connection_id = \" + self.id.to_s)\n \n fportid=0\n # binding.pry\n flist.each do |fiber|\n fport = Devport.find_by_id(fiber.porta)\n fportid=fport.id\n break if (fport.fiber_in_id==0)\n fportid=0\n end\n \n fportid\n \n ... | [
"0.61608636",
"0.58700716",
"0.5798319",
"0.57637346",
"0.5757455",
"0.56814474",
"0.56172824",
"0.56128216",
"0.55285764",
"0.5462376",
"0.5435647",
"0.5417723",
"0.5411878",
"0.5399129",
"0.5215265",
"0.5209555",
"0.52052194",
"0.5194207",
"0.51633036",
"0.5160503",
"0.5144... | 0.6652175 | 0 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.contact_mailer.send_mail_confirm.subject | def send_mail_confirm(data)
@name = data[:name]
@body = data[:body]
address = ['tt.tanishi100@gmail.com']
address += ['hajiming@gmail.com', 'aki030402@gmail.com'] if Rails.env.production?
mail(
:subject => "Pornfolio お問い合わせ",
:to => address.join(',')
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def message_subject=(value)\n ... | [
"0.7067568",
"0.6903146",
"0.6863302",
"0.674731",
"0.6746214",
"0.6744638",
"0.6742499",
"0.6704213",
"0.66874933",
"0.6649958",
"0.6508337",
"0.649907",
"0.6447707",
"0.64423084",
"0.64100206",
"0.63815856",
"0.6353013",
"0.63528043",
"0.63468367",
"0.63397557",
"0.6326576"... | 0.0 | -1 |
Use strong_parameters for attribute whitelisting Be sure to update your create() and update() controller methods. | def user_params
params.require(:user).permit(:avatar, :name, :phone_number, :phone_num, :email, :image_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_parameters\n\t\t\tattrs = self.attribute_names - [\"created_at\", \"updated_at\", \"id\"]\n\t\t\tattrs.push(:_color) if colored? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\tif is_encrypted? # add the color attribute to the permitted attributes if the object is... | [
"0.7362868",
"0.72757727",
"0.690314",
"0.6902138",
"0.6887883",
"0.6829281",
"0.6829281",
"0.6822533",
"0.6821213",
"0.6746019",
"0.67150944",
"0.66879386",
"0.6681827",
"0.6663225",
"0.66562396",
"0.6641877",
"0.66383517",
"0.66281205",
"0.66217595",
"0.65725005",
"0.656038... | 0.0 | -1 |
Time complexity: O(N) Space complexity: O(N) | def reverse_sentence(my_sentence)
if my_sentence == nil
return nil
else
my_arr = my_sentence.split(/(\s+)(?=(?:[^"]*"[^"]*")*[^"]*$)/) #regex expression from https://stackoverflow.com/questions/8162444/ruby-regex-extracting-words
p my_arr
joined = []
my_arr.each do |word|
joined.prepend word
end
p joined
string = joined.join
my_sentence.replace string
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.6782381",
"0.6526273",
"0.6196229",
"0.6084543",
"0.60635185",
"0.6063145",
"0.60258675",
"0.600365",
"0.59738576",
"0.5952783",
"0.59242845",
"0.5919271",
"0.59159523",
"0.5913817",
"0.5894634",
"0.5882974",
"0.58575696",
"0.58535403",
"0.5851849",
"0.58217794",
"0.581950... | 0.0 | -1 |
Validates the size of an uploaded prescription picture. | def image_size
if prescription.size > 5.megabytes
errors.add(:prescription, "should be less than 5MB")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def picture_size\n if picture.size > 5.megabytes\n errors.add(:picture, \"should be less than 5MB\")\n end\n end",
"def picture_size\n if picture.size > 5.megabytes\n errors.add(:picture, \"should be less than 5MB\")\n end\n end",
"def picture_size\n if picture.size > ... | [
"0.78779805",
"0.787309",
"0.78702503",
"0.7866202",
"0.78362525",
"0.78334844",
"0.78303653",
"0.78068",
"0.77948046",
"0.7790744",
"0.77865064",
"0.7782475",
"0.7765085",
"0.77393216",
"0.77343756",
"0.7732566",
"0.7732566",
"0.7732566",
"0.7732566",
"0.7732566",
"0.7732566... | 0.81014836 | 0 |
First Attempt def multiply_list(array1, array2) multiplication_total_array = [] array1.each_with_index do |current_integer, index| multiplication_total_array << current_integer array2[index] end multiplication_total_array end | def multiply_list(array1, array2)
array1.each_with_index.map do |current_integer, index|
current_integer * array2[index]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiply_list(array_1, array_2)\n results = []\n array_1.each_with_index {|num,idx| results << (num * array_2[idx])}\n results\nend",
"def multiply_list(array1, array2)\n result = []\n array1.each_with_index do |num, index|\n result.push(num * array2[index])\n end\n \nresult\n \n \n \nend",
"de... | [
"0.8810432",
"0.8810243",
"0.87529737",
"0.8707791",
"0.8669664",
"0.8626501",
"0.85885245",
"0.85733336",
"0.8522588",
"0.84809464",
"0.8445109",
"0.8442174",
"0.8421399",
"0.8393572",
"0.83912617",
"0.838643",
"0.83421296",
"0.83421296",
"0.8293464",
"0.82765555",
"0.827094... | 0.86792284 | 4 |
Returns error message or nil | def file_error(file_path)
unless File.exists?(file_path)
file = File.basename(file_path)
session[:message] = "#{file} does not exist."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message; end",
"def error_message\n error.message\n end",
"def message\n @errormsg\n end",
"def error\n valid? ? nil : @error_message\n end",
"def error_message\n return @error_message\n end",
"def message\n @error['message']\n end",
"... | [
"0.7964506",
"0.78919375",
"0.7849072",
"0.7843912",
"0.7781908",
"0.77647305",
"0.77640015",
"0.7659836",
"0.76070124",
"0.7531982",
"0.7511595",
"0.7433925",
"0.7430564",
"0.7382721",
"0.7377619",
"0.735521",
"0.72645944",
"0.72392696",
"0.7230165",
"0.7223519",
"0.7193848"... | 0.0 | -1 |
string with all five or more letter words reversed. Each string will consist of only letters and spaces. Spaces should be included only when more than one word is present.Click to review the original problem. | def reverse_words(string)
result = []
string.split.each do |word|
word.reverse! if word.size >= 5
result.push(word)
end
result.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_words(string)\n words = string.split\n words.each { |word| word.reverse! if word.length >= 5 }\n words.join(' ')\nend",
"def reverse_words(str)\n str.split.each { |word| word.reverse! if word.length >= 5 }.join(' ')\nend",
"def reverse_words(string)\n words_array = string.split\n words_array.... | [
"0.829271",
"0.8291577",
"0.82796854",
"0.82458425",
"0.8240648",
"0.8239745",
"0.82345587",
"0.82345587",
"0.82338905",
"0.820631",
"0.8123324",
"0.81135625",
"0.8112097",
"0.8098875",
"0.8082535",
"0.8082339",
"0.8079653",
"0.80787814",
"0.8076213",
"0.8075725",
"0.80733776... | 0.8069702 | 21 |
returns difference of two numbers | def subtract(num1, num2)
num1 - num2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference(number1, number2)\n return number1 - number2\nend",
"def subtract(number1, number2)\n number1 - number2\n end",
"def subtract(first_number, second_number)\n return first_number - second_number\nend",
"def subtract (number1, number2)\n number1 - number2\n end",
"def subtract(first_n... | [
"0.844563",
"0.78843164",
"0.7864327",
"0.78546816",
"0.78391165",
"0.78353256",
"0.78226477",
"0.78127265",
"0.77701885",
"0.7757798",
"0.7710702",
"0.77089",
"0.7687394",
"0.76720893",
"0.76516396",
"0.7641608",
"0.7628266",
"0.7608181",
"0.7591254",
"0.75136316",
"0.750434... | 0.7488719 | 22 |
returns sum of numbers in array | def sum(arr)
arr.empty? ? 0 : arr.reduce(&:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend",
"def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend",
"def sum(array)\n array.inject(0){|sum, n| sum + n}\n end",
"def sum... | [
"0.87592405",
"0.86930937",
"0.86035407",
"0.8557096",
"0.85392725",
"0.8516142",
"0.8505711",
"0.8498472",
"0.8496768",
"0.8496255",
"0.8482838",
"0.848086",
"0.84735775",
"0.8467235",
"0.84639096",
"0.846301",
"0.84606487",
"0.8458689",
"0.8457714",
"0.84519464",
"0.8450128... | 0.0 | -1 |
returns product of numbers passed in | def multiply(*nums)
nums.reduce(1, :*)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(numbers)\n result = 1\n numbers.each do |number|\n result *= number\n end\n result\nend",
"def product(numbers)\n numbers.inject(1) { |result, num| num.is_a?(Numeric) ? result * num : result }\n end",
"def product(numbers)\n product = 1;\n numbers.each do |x|\n product = product * x... | [
"0.84593344",
"0.8453491",
"0.8307706",
"0.8204107",
"0.806454",
"0.7963848",
"0.78451234",
"0.77834404",
"0.77391857",
"0.7686939",
"0.7665564",
"0.7649279",
"0.76201755",
"0.7584121",
"0.75637156",
"0.75433654",
"0.75245214",
"0.7478661",
"0.74473727",
"0.7446784",
"0.74180... | 0.6989019 | 60 |
returns exponential product of base and power | def power(base, exponent)
result = 1
exponent.times { result *= base }
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(base, exp)\n return base ** exp\nend",
"def exp(base, power)\n return 1 if power == 0\n return base if power == 1\n base * exp(base, (power-1))\nend",
"def exp(base, exponent)\n return base if exponent == 1\n base * exp(base, exponent-1)\nend",
"def power(base,exponent)\n\n return ba... | [
"0.8246812",
"0.811795",
"0.8108488",
"0.8068912",
"0.8012629",
"0.80014575",
"0.7999692",
"0.791936",
"0.7867885",
"0.78599733",
"0.7794353",
"0.7705711",
"0.7683976",
"0.76806265",
"0.7679429",
"0.75972545",
"0.7586324",
"0.7586295",
"0.7576932",
"0.7551793",
"0.7551791",
... | 0.7700766 | 12 |
GET /rooms GET /rooms.json | def index
@rooms = Room.all
@rooms = @rooms.search(params[:search]) if params[:search].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def get_rooms\n # DO NOT DELETE. Condition used for load testing\n @user_id = (params.has_key? :user_id) ? params[:user_id] : session[:u... | [
"0.788489",
"0.78231525",
"0.7690326",
"0.76826984",
"0.76242465",
"0.7573095",
"0.75299007",
"0.737599",
"0.7297831",
"0.72899485",
"0.7252718",
"0.7222336",
"0.7193262",
"0.71638155",
"0.7132772",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",... | 0.64201057 | 76 |
GET /rooms/1 GET /rooms/1.json | def show
@room = Room.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @rooms ... | [
"0.7478712",
"0.7469242",
"0.74576104",
"0.7417066",
"0.73393553",
"0.7338305",
"0.7338305",
"0.7338305",
"0.7294765",
"0.71324414",
"0.7078154",
"0.7032473",
"0.70132256",
"0.69495285",
"0.6913364",
"0.6889503",
"0.6889295",
"0.6889295",
"0.6889295",
"0.6889295",
"0.6889295"... | 0.6728404 | 49 |
POST /rooms POST /rooms.json | def create
@room = Room.new(room_params)
@room = Room.new(room_params)
if @room.save
redirect_to @room
else
render 'new'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @room = Room.new(params[:room])\n\n if @room.save\n render :json => @room, :status => :created, :location => @room\n else\n render :json => @room.errors, :status => :unprocessable_entity\n end\n end",
"def create\n @user=User.find(params[:user_id])\n @room = @user.rooms.... | [
"0.7205094",
"0.7079678",
"0.6965091",
"0.6931828",
"0.6896531",
"0.6896531",
"0.6835706",
"0.6807692",
"0.6762218",
"0.6762218",
"0.6762218",
"0.67154557",
"0.6680471",
"0.66675544",
"0.6650434",
"0.66451526",
"0.6636018",
"0.6628381",
"0.65890825",
"0.6562031",
"0.65547556"... | 0.61109084 | 64 |
PATCH/PUT /rooms/1 PATCH/PUT /rooms/1.json | def update
@room = Room.find(params[:id])
if @room.update(room_params)
redirect_to @room
else
render 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @room = Room.find(params[:id])\n\n if @room.update_attributes(params[:room])\n head :ok\n else\n render :json => @room.errors, :status => :unprocessable_entity \n end\n end",
"def update\n if @room.update(room_params)\n render json: @room, status: :ok, serializer: Room... | [
"0.71675444",
"0.7049212",
"0.7000274",
"0.6996011",
"0.69671804",
"0.6927408",
"0.6926342",
"0.6926342",
"0.690636",
"0.68662703",
"0.68121725",
"0.6795969",
"0.6792735",
"0.6773955",
"0.674421",
"0.674305",
"0.67349285",
"0.6731771",
"0.67010766",
"0.67010766",
"0.67010766"... | 0.6255521 | 49 |
DELETE /rooms/1 DELETE /rooms/1.json | def destroy
@room = Room.find(params[:id])
@room.destroy
redirect_to rooms_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { re... | [
"0.7635934",
"0.7620118",
"0.761992",
"0.7589228",
"0.7583094",
"0.7565785",
"0.7555699",
"0.75015026",
"0.7446661",
"0.7445735",
"0.7438515",
"0.73450273",
"0.7341036",
"0.7299027",
"0.7295218",
"0.72534937",
"0.72534937",
"0.725146",
"0.72336674",
"0.72336674",
"0.72336674"... | 0.72453046 | 18 |
Use callbacks to share common setup or constraints between actions. | def set_room
@room = Room.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def room_params
params.require(:room).permit(:room_no, :size, :lib_name, :status)
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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Send colored logs to the logger. Will only colorize output sent to STDOUT and will call the regular info method when writing to file. | def colorized_info(message, color)
unless @logdev.filename
return info("\e[#{color}m#{message}\e[0m")
end
info(message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colorize_logging; end",
"def log(msg, color: \"default\", io: $stdout, &block)\n io.puts \"#{Time.now.strftime('%Y/%m/%d %H:%M:%S').colorize(:light_black)} #{msg.to_s.colorize(color.to_sym)}\"\nend",
"def log_green(message, newline = true)\n log @logger.green(message), newline\n end",
"def log( ... | [
"0.65499085",
"0.62453103",
"0.62424576",
"0.60473865",
"0.60316986",
"0.5799149",
"0.5762426",
"0.5756164",
"0.57115597",
"0.56845164",
"0.5676923",
"0.56659114",
"0.56658316",
"0.56478107",
"0.56343395",
"0.56226414",
"0.557555",
"0.5566307",
"0.55640715",
"0.5411988",
"0.5... | 0.65888923 | 0 |
Consolidate trays of the same phase | def consolidate_phase_trays(plans)
tray_plans = []
plans.each do |p|
tp = tray_plans.detect { |x| x[:phase] == p[:phase] }
if tp.present?
tp[:quantity] += p[:quantity]
tp[:trays] += p[:trays]
else
tray_plans << p
end
end
tray_plans
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tidy_up!\n antecedence.each_key do |entry|\n antecedence[entry].uniq!\n end\n end",
"def project_phase_deliverables\n project_phase_deliverables = []\n stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n project_phase_deliverables << d\n ... | [
"0.5377887",
"0.51905435",
"0.51615506",
"0.5076793",
"0.50539786",
"0.5052658",
"0.50282943",
"0.4958624",
"0.49293447",
"0.49135512",
"0.48869434",
"0.4864298",
"0.48549494",
"0.482563",
"0.481043",
"0.47877073",
"0.47665086",
"0.47517738",
"0.47472188",
"0.47305468",
"0.47... | 0.6625904 | 0 |
GET /user_accounts_groups GET /user_accounts_groups.json | def index
@user_accounts_groups = UserAccountsGroup.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def list_groups\n groups = CanvasSpaces.GroupCategory.groups.active.order(:name)\n # filter out non-publ... | [
"0.80552924",
"0.77280676",
"0.7624073",
"0.7521203",
"0.74605554",
"0.7453929",
"0.73110676",
"0.71863365",
"0.71125764",
"0.71125764",
"0.70784354",
"0.70531493",
"0.705243",
"0.7021311",
"0.7014614",
"0.7007453",
"0.69902885",
"0.6988232",
"0.6986542",
"0.6969432",
"0.6943... | 0.727968 | 7 |
GET /user_accounts_groups/1 GET /user_accounts_groups/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def index\n @groups = current_user.groups\n render json: @groups\n end",
"def list_groups()\n ... | [
"0.79251564",
"0.7594681",
"0.752881",
"0.73465323",
"0.73040295",
"0.7296547",
"0.7204787",
"0.71404636",
"0.71138084",
"0.7050299",
"0.700905",
"0.6998873",
"0.6980665",
"0.6963889",
"0.69493914",
"0.6943283",
"0.6930095",
"0.6912433",
"0.6861536",
"0.68532526",
"0.6851156"... | 0.0 | -1 |
POST /user_accounts_groups POST /user_accounts_groups.json | def create
@user_accounts_group = UserAccountsGroup.new(user_accounts_group_params)
respond_to do |format|
if @user_accounts_group.save
format.html { redirect_to @user_accounts_group, notice: 'User accounts group was successfully created.' }
format.json { render :show, status: :created, location: @user_accounts_group }
else
format.html { render :new }
format.json { render json: @user_accounts_group.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration], owner: current_user)\n if @group.save\n @group.memberships.create!(user: current_user, admin: true)\n if params[:group][:users]\n params[:gro... | [
"0.74226165",
"0.73680514",
"0.7174148",
"0.70906186",
"0.7046947",
"0.6980149",
"0.6980149",
"0.69399935",
"0.6907915",
"0.6907915",
"0.6898547",
"0.68582433",
"0.68555725",
"0.68551975",
"0.68493336",
"0.68402857",
"0.68396103",
"0.68238103",
"0.67827797",
"0.67663157",
"0.... | 0.73983836 | 1 |
PATCH/PUT /user_accounts_groups/1 PATCH/PUT /user_accounts_groups/1.json | def update
respond_to do |format|
if @user_accounts_group.update(user_accounts_group_params)
format.html { redirect_to @user_accounts_group, notice: 'User accounts group was successfully updated.' }
format.json { render :show, status: :ok, location: @user_accounts_group }
else
format.html { render :edit }
format.json { render json: @user_accounts_group.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n group_ids = params[:group_id]\n org_id = params[:organization_id]\n @user = User.find_by_id(params[:user_id])\n current_group_ids = @user.user_group_i... | [
"0.71314126",
"0.70363176",
"0.69258267",
"0.6909519",
"0.6853393",
"0.6837801",
"0.6829154",
"0.67907864",
"0.67828876",
"0.6736119",
"0.67357504",
"0.67305255",
"0.6725956",
"0.6620783",
"0.65972036",
"0.65972036",
"0.6573337",
"0.6572118",
"0.65649754",
"0.6541842",
"0.648... | 0.70150155 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.