query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Checks if it is time to purge connections that correspond to EMSs that no longer exist in the database. | def purge?
Time.current - @purge_time > @purge_interval
end | [
"def check_connections\n t = Time.now.utc\n if @last_check_connections.nil? || @last_check_connections + 15.minutes < t\n @last_check_connections = t\n\n # Find all EMSes and Hosts to which we could have connections.\n connections = self.class.emses_and_hosts_to_monitor.collect { |e| [e.address... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the settings of the connection manager. | def settings
::Settings.ems.ems_ovirt.connection_manager
end | [
"def settings\n @settings_manager\n end",
"def settings\n return @settings\n end",
"def connection_options\n CONNECTION_OPTIONS\n end",
"def connection_configs\n BunnyManager.configuration.connection_configs\n end",
"def connection_manager\n self.cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /construction_expenses GET /construction_expenses.json | def index
@construction_expenses = ConstructionExpense.all.order("created_at DESC")
end | [
"def get_expenses(constructions)\n information = {expenses: 0, paid: 0}\n constructions.each do |construction|\n information[:expenses] += construction.expenses\n information[:paid] += construction.paid\n end\n information\n end",
"def index\n @api_v1_initiative_expenses = Api::V1::Initi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /construction_expenses POST /construction_expenses.json | def create
@construction_expense = ConstructionExpense.new(construction_expense_params)
respond_to do |format|
if @construction_expense.save
format.html { redirect_to root_path, notice: 'Construction expense was successfully created.' }
format.json { render :show, status: :created, locati... | [
"def create\n @expense = Expense.new(expense_params)\n\n if @expense.save\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end",
"def create\n @estimated_expense = EstimatedExpense.new(estimated_expense_params)\n\n respond_to do |for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /construction_expenses/1 DELETE /construction_expenses/1.json | def destroy
@construction_expense.destroy
respond_to do |format|
format.html { redirect_to construction_expenses_url, notice: 'Construction expense was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @api_v1_initiative_expense.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_initiative_expenses_url, notice: 'Initiative expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_expense.destroy\n resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /everydays GET /everydays.json | def index
@everydays = Everyday.all
end | [
"def all\n @days = Day.where(\"date >= ?\", Date.today).all\n respond_to do |format|\n format.json { render json: @days }\n end\n end",
"def index\n @everyday_events = EverydayEvent.all\n end",
"def get_calendar(url, duration_in_days)\n today = DateTime.now\n # Treats recurring events... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /everydays POST /everydays.json | def create
@everyday = Everyday.new(everyday_params)
respond_to do |format|
if @everyday.save
format.html { redirect_to :back, notice: 'Everyday was successfully created.' }
format.json { render :show, status: :created, location: :back }
else
format.html { render :new }
... | [
"def addDates()\n\tdates = JSON.parse(params[:dates_array])\n\tfor day in dates do \n\t\t@event.days.push(Day.create(:event_id => @event.id, :cal_day => Date.strptime(day, \"%m/%d/%Y\")))\n\tend\nend",
"def create\n @train_schedule = TrainSchedule.new(train_schedule_params)\n @train_schedule.days = params[:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /everydays/1 PATCH/PUT /everydays/1.json | def update
respond_to do |format|
if @everyday.update(everyday_params)
format.html { redirect_to :back, notice: 'Everyday was successfully updated.' }
format.json { render :show, status: :ok, location: :back }
else
format.html { render :edit }
format.json { render json: @... | [
"def update\n respond_to do |format|\n if @everyday_event.update(everyday_event_params)\n format.html { redirect_to @everyday_event, notice: 'Everyday event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /everydays/1 DELETE /everydays/1.json | def destroy
@everyday.destroy
respond_to do |format|
format.html { redirect_to everydays_url, notice: 'Everyday was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_all(date = Date.today)\n delete(date.strftime(@request_path))\n end",
"def destroy\n @everyday_event.destroy\n respond_to do |format|\n format.html { redirect_to everyday_events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_day.destroy... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /resource_import_files GET /resource_import_files.json | def index
@resource_import_files = ResourceImportFile.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end | [
"def index\n authorize ResourceImportFile\n @resource_import_files = ResourceImportFile.page(params[:page])\n end",
"def index\n @resource_import_files = ResourceImportFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @resourc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /resource_import_files POST /resource_import_files.json | def create
@resource_import_file = ResourceImportFile.new(resource_import_file_params)
@resource_import_file.user = current_user
respond_to do |format|
if @resource_import_file.save
if @resource_import_file.mode == 'import'
ResourceImportFileJob.perform_later(@resource_import_file)
... | [
"def create\n @resource_import_file = ResourceImportFile.new(params[:resource_import_file])\n @resource_import_file.user = current_user\n\n respond_to do |format|\n if @resource_import_file.save\n format.html { redirect_to @resource_import_file, :notice => t('controller.successfully_created', :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /resource_import_files/1 PUT /resource_import_files/1.json | def update
respond_to do |format|
if @resource_import_file.update(resource_import_file_params)
if @resource_import_file.mode == 'import'
ResourceImportFileJob.perform_later(@resource_import_file)
end
format.html { redirect_to @resource_import_file, notice: t('controller.succe... | [
"def update\n respond_to do |format|\n if @resource_import_file.update_attributes(params[:resource_import_file])\n format.html { redirect_to @resource_import_file, :notice => t('controller.successfully_updated', :model => t('activerecord.models.resource_import_file')) }\n format.json { head :n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /resource_import_files/1 DELETE /resource_import_files/1.json | def destroy
@resource_import_file.destroy
respond_to do |format|
format.html { redirect_to resource_import_files_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.resource_import_file')) }
format.json { head :no_content }
end
end | [
"def destroy\n @resource_import_file.destroy\n\n respond_to do |format|\n format.html { redirect_to resource_import_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @file_import = FileImport.find(params[:id])\n @file_import.destroy\n\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return the new version and the reasons | def new_version
%w(major minor patch).each do |level|
changes = git_changelog.select(&"#{level}?".to_sym)
return [ last_release.send("#{level}!"), changes ] if changes.size > 0
end
raise "No commit since last release (#{last_release})"
end | [
"def new_warnings\n diff[:new]\n end",
"def full_version_string; end",
"def changed\n @version_string = nil\n end",
"def version_description\n VERSIONS[version]\n end",
"def version_mismatch_detected\n end",
"def old_version\n new_version.previous\n end",
"def upda... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This confirmation method saves user's accont details | def confirm
@profiles=@current_user.user_profile.update_attributes(params[:body])
end | [
"def after_confirmation\n get_profile = self.profile\n if get_profile.present? && (get_profile.deleted == nil && get_profile.membership == nil)\n profile_params = { bio: \"Coinmitted investor\", language: \"en\", deleted: false, membership: 0 }\n get_profile.update_attributes(profile_params)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 ... | 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 permutatin... | [
"def next_bigger(input)\n puts \"input = #{input}\"\n puts '------------------'\n puts\n puts\n\n digits = input.to_s.chars.map(&:to_i)\n\n return -1 if all_digits_are_the_same?(digits)\n\n result = input\n tail = -1\n next_tail = -1\n\n while(tail.abs < digits.length && result <= input)\n next_tail = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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.
@p... | [
"def cartAsMapOfProductsAndQuantities\r\n aMap = @products.sort.each_with_object(Hash.new) {|i, m| m[i]+=1 rescue m[i]=1}\r\n #print([\"-cartAsMap=\",aMap.inspect,\"\\n\"].join)\r\n aMap\r\n end",
"def auctions_hash_for_product_help()\n a_hash = {\"\" => \"(空白)\"}\n # auction except those ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 ... | def queue(*args, &block)
self.queued_blocks << self.define_block_container(*args, &block)
nil
end | [
"def render_block(name_or_container, *args, &block)\n options = args.extract_options!\n\n buffer = ActiveSupport::SafeBuffer.new\n\n block_options = {}\n if (name_or_container.is_a?(BuildingBlocks::Container))\n name = name_or_container.name.to_sym\n block_options = name_or_contain... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def cosineSimilarity(obj1, obj2)\r\n\tcos = dotProduct(obj1, obj2)/(magnitude(obj1) * magnitude(obj2))\r\n\t(1.0 + cos)/2.0\r\nend",
"def cosine_similarity(vector1,vector2) \n\t\tpenalty = [vector1.size,8].min/8\n\t\tnumerator = dot_product(vector1,vector2)\n\t\tdenominator1 = dot_product(vector1,vector1)\n\t\td... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 "refres... | [
"def icon_class\n icon_name = options[:name].to_s.gsub(\"_\",\"-\")\n %(glyphicon glyphicon-#{icon_name})\n end",
"def css_class\n Icon.find_by_id(self.badge_type).css_class\n end",
"def glyphicon\n case category\n when 'penalty'\n return 'glyphicon-usd'\n when 'law'\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ingest_responses GET /ingest_responses.json | def index
@ingest_responses = IngestResponse.all
end | [
"def index\n render json: @responses\n end",
"def index\n @event_responses = EventResponse.all\n end",
"def index\n @responses = Response.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @responses }\n end\n end",
"def index\n \t @response... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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_respon... | [
"def index\n @ingest_responses = IngestResponse.all\n end",
"def index\n @event_responses = EventResponse.all\n end",
"def index\n render json: @responses\n end",
"def save_and_ingest\n authorize! :create, resource_class\n respond_to do |f|\n f.json do\n render json: IngestFolder... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 :... | [
"def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def destroy\n @medusa_ingest.destroy\n respond_to do |format|\n format.html { redirect_to medusa_ingests_url, notice: 'Medusa ingest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @congestion = Congestion.find(params[:id])\n @congestion.de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def log(message); end",
"def log(msg) self.class.log(msg) end",
"def log message\n logger.info(\"[linguara] #{message}\") if logging?\n end",
"def log message\n logger.info(\"[Pdftk] #{message}\") if logging?\n end",
"def log(msg)\n send_log(resource[:loglevel], msg)\n end",
"def log(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get test tweet with given tweet ids | def get_test_tweet(tweet_ids)
data = Tweet.where(id: tweet_ids)
end | [
"def get_tweet_for_tweet_ids(tweet_ids)\n @select_tweet_query ||= @session.prepare(\"SELECT * FROM tweets WHERE tweet_id=?\")\n \n tweets = []\n tweet_ids.each do |tweet_id|\n result = @session.execute(@select_tweet_query, arguments: [tweet_id]).first\n\n if result == nil\n raise \"Twee... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def manage_profile\n choice = PROMPT.select(\"#{@@user.name}, you can:\", [\"Change username\", \"Change password\", \"View Performance\"])\n if choice == \"Change username\"\n change_username\n elsif choice == \"Change password\"\n change_password\n elsif choice =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
============ 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
... | [
"def atest_ID_25885_profile_page_user_vitals\n # this test is covered by test_ID_25875_user_profile_additional_fields\n end",
"def atest_ID_25880_profile_page_user_stats\n # this test covered by test_ID_25875_user_profile_additional_fields\n end",
"def admin\n return get_profile('admin')\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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,
... | [
"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... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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.ac... | [
"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 link?(name)\n links_title.include? name\n end",
"def test_00120... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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,
... | [
"def message_create(params={})\n MESSAGE.new(request(:post, \"sms/create/\", params.merge({})))\n end",
"def send_text_message\n number_to_send_to = params[:number_to_send_to]\n \n twilio_sid = 'ACef0d534bb53901be6964325064522086'\n twilio_token = '358346907479ae440807d8af52658c31'\n twili... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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'
retur... | [
"def replies(&block)\n bot.register_handler(:replies, block)\n end",
"def reply token, api_message, api_step\n Message.find(api_message.id).replies.create(:step_id => api_step.id, :user => current_user)\n end",
"def sms_reply\n logger.post(\"tegu.app\", log_data.merge({event: 'twilio.sms.reply', ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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|... | [
"def method_missing(method, *args)\n if method =~ /find/\n finder = method.to_s.split('_by_').first\n attributes = method.to_s.split('_by_').last.split('_and_')\n\n chain = Dynamo::Criteria::Chain.new(self)\n chain.where(Hash.new.tap {|h| attributes.each_with_index {|attr,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def rewind\n reader.rewind\n end",
"def init_ReaderBufferImpl\n @position = 0\n end",
"def initialize(structured_reader,&block)\n @reader = structured_reader\n instance_eval( &block ) if block\n end",
"def reader=(reader)\n @reader = reader\n end",
"def new\n @fulltext... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 strea... | def store_field(data)
@io.write [data.size].pack("V")
offset = @io.pos
@io.write data
@io.write "\0"
offset
end | [
"def offset\n fil_header[:offset]\n end",
"def header\n _, @count, @stringOffset = @bytes[0, 6].unpack('nnn')\n end",
"def write_hdr(field, value)\n @header_data.write_int(field, value)\n @header_modified = true\n end",
"def write_hdr(field, value)\n BlockFile.write_int(@header_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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(\"connection_id = \" + self.id.to_s)\n #binding.pry\n fportid=0\n # binding.pry\n flist.ea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def find_port(name)\n find_output_port(name.to_str) || find_input_port(name.to_str)\n end",
"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(f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def picture_size\n errors.add(:image, 'should be less than 1MB') if image.size > 1.megabytes\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 > 5.megabytes\n erro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def colorize_logging; end",
"def log_green(message, newline = true)\n log @logger.green(message), newline\n end",
"def colorize_logging=(_arg0); end",
"def log_red(message, newline = true)\n log @logger.red(message), newline\n end",
"def cprint (msg = \"\", color = \"\")\n\n # Identify... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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
... | [
"def consolidate events_per_source\n events_sorted_by_source = events_by_prio(events_per_source)\n \n # find first non-empty batch of events in the order of prio\n begin \n consolidated = events_sorted_by_source.shift\n end while consolidated.blank?\n \n events_sorted_by_sour... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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, l... | [
"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... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
must yield a valid route as defined below == SCOPES returns the ActionDispatch::Routing::Route for this role_route | def route
@route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}
end | [
"def get_route\n self.route\n end",
"def route\n @route\n end",
"def roles_for_path(*args)\n \n hash = args_to_hash(*args)\n \n # find the permission (and associated roles)\n permission = Permission.find(:first, :include => :roles, :conditions => {\n :controller_action =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=> Hubspot destroy => This needs to be implemented into admin area => Destroys hubspot listings from hubspot_id | def hubspot_destroy
true
end | [
"def destroy\n @hub_list.destroy\n respond_to do |format|\n format.html { redirect_to hub_lists_url, notice: 'Hub list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_listing = Listing.find(params[:id])\n @admin_listing.destroy\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a new generateduid | def new_generateduid
CFUUIDCreateString(nil, CFUUIDCreate(nil))
end | [
"def generate_uid\n begin\n # .uuid or .hex? both seem to do the same job\n self.uid = SecureRandom.uuid.gsub(/[-]/, '')\n end while self.class.exists?(uid: self.uid)\n end",
"def generate_new_id\n Util::UUID.generate\n end",
"def new_uuid\n UUIDTools::UUID.timestamp_create.hex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load the computer object Returns an NSDictionary representation of the the user.plist if it exists If it doesn't, it will return nil | def get_computer(name)
@file = "/private/var/db/dslocal/nodes//#{resource[:dslocal_node]}/computers/#{name}.plist"
NSMutableDictionary.dictionaryWithContentsOfFile(@file)
end | [
"def get_user(name)\n file = \"#{@@path_to_user_plists}/#{name}.plist\"\n user = NSMutableDictionary.dictionaryWithContentsOfFile(file)\n end",
"def get_user(name)\n @file = \"/private/var/db/dslocal/nodes//#{resource[:dslocal_node]}/users/#{name}.plist\"\n NSMutableDictionary.dictionaryWithContentsO... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
/update_version_select/1 Get the versions for the current product Then render the small versions drop down partial for index search This is used for searches on index pages with a product. Ex. see assignments and and results (execute) index page | def update_version_select
versions = Version.where(:product_id => params[:id]).order(:version) unless params[:id].blank?
render :partial => "versions", :locals => { :versions => versions }
end | [
"def update_version_select\n # Verify user can view items for this product. Must be in his product\n authorize_product!(Product.find(params[:id]))\n\n versions = Version.where(product_id: params[:id]).order(:version) unless params[:id].blank?\n render partial: 'versions', locals: { versions: versions }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Authorize product raises an exception if user tries to a access a product that they do not have access to This is used in controller. The check for views is in the application helper | def authorize_product!(product)
unless product.nil?
unless current_user.products.include?(product)
raise Exceptions::ProductAccessDenied
end
end
end | [
"def verify_ownership\n\t\tif @current_user.id != Cart.find(params[:id]).user.id\n\t\t\tflash.now[:error] = \"Oops! You do not have permission to view this page.\"\n\t\t\trender :file => File.join(Rails.root, 'public', '403.html'), \n \t :status => 403\n\t\tend\n\tend",
"def authorize_access\n # ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
token considered a multimatch if contains wildcard | def is_multimatch(s)
return s.match(/[*?]/)
end | [
"def wildcard?\n tokens.last == WILDCARD\n end",
"def token_matcher; end",
"def complex_token_matches?(token) # :nodoc:\n Matchers.matchers.any? {|matcher| matcher.matches?(token) }\n end",
"def scan strOrRegexp\n @in.scan /\\s*/ # Skip whitespace\n @match = @in.scan strOrRegexp\n @last_mat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build a coll structure that matches conditions in a Hash | def make_coll_filters(values)
coll = Xmms::Collection.universe
unless values.empty?
values.each do |field, val|
matchop = make_coll_operator(field, val)
matchop.operands << coll
coll = matchop
end
end
return coll
end | [
"def build_hash\n hash = {}\n @conditions.each_key {|key| hash[key] = {}}\n hash\n end",
"def build\n criteria_fields.inject({}) do |criteria_hash, field|\n value = field_value field \n set_criteria(criteria_hash, field, value) unless skip?(field, value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /comments/1.xml PUT /comments/1.json | def update
@comment = Comment.find(params[:id])
respond_to do |format|
if @comment.update_attributes(params[:comment])
format.xml { head :ok }
format.json { head :ok }
else
format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
for... | [
"def update\n json_update_and_sanitize(comment, comment_params, Comment)\n end",
"def update\n @api_v1_comment = @post.comments.find(params[:id])\n params[:comment].delete :created_at\n params[:comment].delete :updated_at\n respond_to do |format|\n if @api_v1_comment.update_attributes(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /comments/1.xml DELETE /comments/1.json | def destroy
@comment = Comment.find(params[:id])
@comment.destroy
respond_to do |format|
format.xml { head :ok }
format.json { head :ok }
end
end | [
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @rb_comment.destroy\n respond_to do |format|\n format.html { redirect_to rb_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /comments/exists.xml POST /comments/exists.json | def exists
@record = Record.new
comment = Comment.find_by_app_id_and_authorId(params[:app_id], params[:authorId], :select => :id)
if comment.nil?
@record.exists = false
else
@record.id = comment.id
@record.exists = true
end
respond_to do |format|
format.xml {render :xml... | [
"def is_comment_creation?\n request.post? && request.request_parameters['comment'].present?\n end",
"def add_comment\n 'add_comment_ok' == @xml['status'] ? true : false\n end",
"def delete_comment\n 'delete_comment_ok' == @xml['status'] ? true : false\n end",
"def exists_posting(posting)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
append to a prevous message | def append(msg="")
print "\r#{ONE_UP}#{ERASE}"
fmt_msg("#{@last_msg} #{msg.to_s.strip}", @last_lvl)
end | [
"def write(message)\n @messages.unshift(message)\n end",
"def append_to_log(message)\n self.output = '' if output.nil?\n self.output += message unless message.nil?\n broadcast_message property: :output,\n value: self.output\n end",
"def msg_add(c)\n\t@msg_buf << c\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUBLIC METHODS RecipHeading gives the heading for the recipient | def recip_heading
identity.name.titleize.pluralize
end | [
"def heading\r\n altitude_valid? unless @heading # Run the validator to populate @heading.\r\n @heading\r\n end",
"def heading\n render_citation(@document)\n end",
"def heading()\n @pid_heading.update(@heading_deg)\n \n end",
"def heading\n @invoice.project.account.account_setting.l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recip identity that is being judged | def recip
self.identity
end | [
"def claimed_id; end",
"def identity_name\n return @identity_name\n end",
"def target_identity\n return @target_identity\n end",
"def resident_key; end",
"def name\n \"identity\"\n end",
"def original_id; end",
"def local_id; end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the raw key in byte format | def to_bytes; @key; end | [
"def key_bytes\n self.class.key_bytes\n end",
"def key_bytes\n KEYBYTES\n end",
"def key64\n return Base64.encode64(@key)\n end",
"def data\n raw_key.to_pem\n end",
"def to_s()#:String\n return key_str()\n end",
"def to_der_hex_s\n @key.to_der.unpack('H*').fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
render html sourcecode with images | def render(content = 'No template provided')
# get Nokogiri object with html source
html = Nokogiri::HTML(htmlbody)
# pick image tags from source and inject the right images
mailskinassets.each do |mailskinasset|
html.css('img').each do |image|
# do we have the filename of our mailskinass... | [
"def render\n response = Net::HTTP.post_form(URI.parse(WSD_URL), 'style' => @style, 'message' => @code)\n if response.body =~ /img: \"(.+)\"/\n url = \"http://www.websequencediagrams.com/#{$1}\"\n @tag = \"<img src=\\\"#{url}\\\" />\"\n else\n puts response.body\n @tag =\"Sorry, unable ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /family_histories GET /family_histories.json | def index
@family_histories = FamilyHistory.all
end | [
"def index\n @patient=Patient.find_by_user_id(current_user.id)\n @family_histories = @patient.family_histories.all\n end",
"def show\n @family_history = FamilyHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @family_history }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /family_histories POST /family_histories.json | def create
@family_history = FamilyHistory.new(family_history_params)
respond_to do |format|
if @family_history.save
format.html { redirect_to patient_path(@family_history.patient), notice: 'Family history was successfully created.' }
format.json { render :show, status: :created, location... | [
"def create\n #@family_history = FamilyHistory.new(family_history_params)\n @family_history = @patient.family_histories.new(family_history_params)\n respond_to do |format|\n if @family_history.save\n format.html { redirect_to @patient, notice: 'Family history was successfully created.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /family_histories/1 PATCH/PUT /family_histories/1.json | def update
respond_to do |format|
if @family_history.update(family_history_params)
format.html { redirect_to patient_path(@family_history.patient), notice: 'Family history was successfully updated.' }
format.json { render :show, status: :ok, location: @family_history }
else
forma... | [
"def update\n respond_to do |format|\n if @family_history.update(family_history_params)\n format.html { redirect_to @family_history, notice: 'Family history was successfully updated.' }\n format.json { render :show, status: :ok, location: @family_history }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /family_histories/1 DELETE /family_histories/1.json | def destroy
@family_history.destroy
respond_to do |format|
format.html { redirect_to family_histories_url, notice: 'Family history was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @family_history = FamilyHistory.find(params[:id])\n @family_history.destroy\n\n respond_to do |format|\n format.html { redirect_to family_histories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @family_history.destroy\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of routes, ignoring exceptions | def my_routes
my_routes = []
exceptions = %w(Login Signin)
self.class.routes['GET'].each do |r|
route = r.first.to_s.gsub(/\W+|mix/,'').capitalize
my_routes << route unless exceptions.include?(route)
end
return my_routes
end | [
"def get_routes\n raise \"Method not implemented\"\n end",
"def routes\n @routes ||= []\n end",
"def all_routes\n matching_routes\n end",
"def routeprovider_routes\n inspected_routes.select { |r| r[:verb] == \"GET\" || r[:name] == \"root\" }\n end",
"def routes\n raise N... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new user Requires: user_name, type, first_name, last_name Optional: section_name, grace_credits | def create
if has_missing_params?([:user_name, :type, :first_name, :last_name])
# incomplete/invalid HTTP params
render 'shared/http_status', locals: { code: '422', message:
HttpStatusHelper::ERROR_CODE['message']['422'] }, status: :unprocessable_entity
return
end
# ... | [
"def new_user(user_name, first, last, password, quota=nil)\n set_values suspended: 'false', username: user_name, password: password, first_name: first, last_name: last, quota: quota\n \t\tend",
"def create\n if has_missing_params?([:user_name, :type, :first_name, :last_name])\n # incomplete/in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Do not make AutotestUser users visible | def visible_users
User.where.not(type: :AutotestUser)
end | [
"def missingUser\n end",
"def exclude_guests_or_external_users=(value)\n @exclude_guests_or_external_users = value\n end",
"def viewable_users\n @viewable_users ||= (controllable_users + request_applicants + controllable_users.map{|uu|uu.request_applicants}).flatten.uniq\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Average Revenue Per Order | def get_average_revenue_per_order(order_type=nil, start_date=nil, end_date=nil)
orders_count = get_orders_count(order_type, start_date, end_date)
return (get_revenue(order_type, start_date, end_date)/orders_count).round(2)
end | [
"def get_average_revenue_per_order_item(order_type=nil, start_date=nil, end_date=nil)\n (get_revenue(order_type, start_date, end_date)/get_items_sold_count(order_type, start_date, end_date)).round(2)\n end",
"def average_amount_per_order\n @po.sum(:amount)/past_orders.size\n end",
"def calculate_aver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Average Revenue Per Order Item | def get_average_revenue_per_order_item(order_type=nil, start_date=nil, end_date=nil)
(get_revenue(order_type, start_date, end_date)/get_items_sold_count(order_type, start_date, end_date)).round(2)
end | [
"def get_average_revenue_per_order(order_type=nil, start_date=nil, end_date=nil)\n orders_count = get_orders_count(order_type, start_date, end_date)\n return (get_revenue(order_type, start_date, end_date)/orders_count).round(2)\n end",
"def average_amount_per_order\n @po.sum(:amount)/past_orders.size\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Average Orders Per Customer | def get_average_orders_per_customer(customer_type=nil)
(get_orders_count(customer_type, nil, nil)/get_customers_count(customer_type, nil, nil)).round(0)
end | [
"def get_average_order_items_per_customer(customer_type=nil)\n (get_items_sold_count(customer_type, nil, nil)/get_customers_count(customer_type, nil, nil)).round(0)\n end",
"def average_amount_per_order\n @po.sum(:amount)/past_orders.size\n end",
"def calculate_average_order_cost(orders)\n # sets ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Average Order Items Per Customer | def get_average_order_items_per_customer(customer_type=nil)
(get_items_sold_count(customer_type, nil, nil)/get_customers_count(customer_type, nil, nil)).round(0)
end | [
"def get_average_orders_per_customer(customer_type=nil)\n (get_orders_count(customer_type, nil, nil)/get_customers_count(customer_type, nil, nil)).round(0)\n end",
"def average_amount_per_order\n @po.sum(:amount)/past_orders.size\n end",
"def calculate_average_order_cost(orders)\n # sets the total... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Average Items Per Order | def get_average_items_per_order(order_type=nil, start_date=nil, end_date=nil)
if get_orders_count(order_type, start_date, end_date) > 0
(get_items_sold_count(order_type, start_date, end_date)/get_orders_count(order_type, start_date, end_date)).round(0)
else
0
end
end | [
"def average_amount_per_order\n @po.sum(:amount)/past_orders.size\n end",
"def average_products\n @items.inject(0) do |total, items|\n total += items.gross_price/@items.count\n\n end\n end",
"def get_average_order_items_per_customer(customer_type=nil)\n (get_items_sold_count(customer_type,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return true if tracks have only one value for 'parameter_name' | def unique?( tracks, parameter_name )
values = []
tracks.each do |track|
values << track.send( parameter_name )
end
return values.uniq.length == 1
end | [
"def valid_parameter?(name)\n @attributes.include?(name) || METAPARAMSET.include?(name)\n end",
"def parameters?\n parameters.values.all?\n end",
"def has_param(name) \n return (@params.has_key? name)\n end",
"def has_param?(name)\n\n end",
"def parameter?(var_name)\n @@... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /categories/new GET /categories/new.xml | def new
@category = Category.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @category }
end
end | [
"def new\n @categories = Category.all\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.xml\n end\n end",
"def n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is the controller method responsible for displaying all the reviews for a share | def index
@reviews = @share.reviews.order(priority: :asc)
@reviewToAlter = @share.reviews.new
end | [
"def index\n @provider_reviews = ProviderReview.all\n end",
"def index\n @reviewses = Reviewse.all\n end",
"def index\n @item_reviews = ItemReview.all\n end",
"def index\n @market_reviews = MarketReview.all\n end",
"def index\n @personal_reviews = PersonalReview.all\n end",
"def index\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
edit is the method which takes care of editing a review | def edit
@reviews = @share.reviews.order(priority: :asc)
@reviewToAlter = Review.find(params[:id])
end | [
"def edit\n @review = Review.find(params[:id])\n end",
"def edit_review\n clear_console\n display_title\n selection = @@prompt.select(\"Select the review you would like to Change\", @current_user.map_reviews, active_color: :magenta)\n selected_review = Review.find_by(content: selec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate the constraint with the given name, which should have been added previously with NOT VALID. | def validate_constraint(name)
@operations << {:op => :validate_constraint, :name => name}
end | [
"def validate_constraint(table_name, constraint_name); end",
"def validator_defined_for?(constraint_name)\n !!validator_for(constraint_name)\n end",
"def check_valid_name\n if Vertical.where(name: name).exists?\n errors.add(:name, 'is already taken By Vertical')\n throw(:abort)\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assumes hash partitioning, sets the modulus for this parition. | def modulus(v)
@modulus = v
end | [
"def modulus; end",
"def modulus\n private_key ? private_key.modulus : public_key.modulus\n end",
"def modulo(p0) end",
"def shear_modulus\n convert(material, :modulus) / (2 * (1 + material.poisson))\n end",
"def divmod(p0) end",
"def runterholen(p,q,dividend)\r\n\tp[q.deg-1] = dividend[q.deg-... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The from and to values of this partition for a range partition. | def range
[@from, @to]
end | [
"def ranges\n @ranges\n end",
"def ranges\n return @ranges\n end",
"def value_source_range; end",
"def values(range = nil)\n result_unflatten = if !::RANGES_JRUBY_BUG\n map { |x| x.v }\n else\n self.v\n end\n result = result_unflatten.flatten... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine the appropriate partition type for this partition by which methods were called on it. | def partition_type
raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1
if @from || @to
raise Error, "must call both from and to when creating a partition of a table if c... | [
"def partition_for(document)\n if options[:partition_strategy]\n options[:partition_strategy].call(document)\n else\n 'default'\n end\n end",
"def get_partition_fs_type(part)\n post_message(\"Retrieving '#{part}' partition filesystem type...\")\n @logger.debug \"g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set a conversion proc for the given oid. The callable can be passed either as a argument or a block. | def add_conversion_proc(oid, callable=nil, &block)
conversion_procs[oid] = callable || block
end | [
"def add_object_conversion( oid, conversion=nil )\n\t\tconversion = Proc.new if block_given?\n\t\t@object_conversions[ oid ] = conversion\n\tend",
"def cast_proc(&proc)\n @cast_proc = proc if proc\n @cast_proc\n end",
"def cast_proc=(proc)\n raise ArgumentError unless Proc === proc or NilClass... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a conversion proc for a named type, using the given block. This should be used for types without fixed OIDs, which includes all types that are not included in a default PostgreSQL installation. | def add_named_conversion_proc(name, &block)
unless oid = from(:pg_type).where(:typtype=>['b', 'e'], :typname=>name.to_s).get(:oid)
raise Error, "No matching type in pg_type for #{name.inspect}"
end
add_conversion_proc(oid, block)
end | [
"def define_type_convert(type, &block)\n @conversions ||= {}\n @conversions[type] = block\n end",
"def block_type_map(&block)\n each { |b| b.name = yield b.name.to_sym }\n end",
"def add_conversion_proc(oid, callable=nil, &block)\n conversion_procs[oid] = callable || block\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A hash of metadata for CHECK constraints on the table. Keys are CHECK constraint name symbols. Values are hashes with the following keys: :definition :: An SQL fragment for the definition of the constraint :columns :: An array of column symbols for the columns referenced in the constraint, can be an empty array if the ... | def check_constraints(table)
m = output_identifier_meth
hash = {}
_check_constraints_ds.where_each(:conrelid=>regclass_oid(table)) do |row|
constraint = m.call(row[:constraint])
entry = hash[constraint] ||= {:definition=>row[:definition], :columns=>[]}
entry[:colum... | [
"def constraint_definition_sql(constraint)\n sql = String.new\n sql << \"CONSTRAINT #{quote_identifier(constraint[:name])} \" if constraint[:name] \n case constraint[:type]\n when :check\n check = constraint[:check]\n check = check.first if check.is_a?(Array) && check.length == 1\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert the first primary key column in the +table+ from being a serial column to being an identity column. If the column is already an identity column, assume it was already converted and make no changes. Only supported on PostgreSQL 10.2+, since on those versions Sequel will use identity columns instead of serial col... | def convert_serial_to_identity(table, opts=OPTS)
raise Error, "convert_serial_to_identity is only supported on PostgreSQL 10.2+" unless server_version >= 100002
server = opts[:server]
server_hash = server ? {:server=>server} : OPTS
ds = dataset
ds = ds.server(server) if server
... | [
"def reset_primary_key_sequence(table)\n return unless seq = primary_key_sequence(table)\n pk = SQL::Identifier.new(primary_key(table))\n db = self\n s, t = schema_and_table(table)\n table = Sequel.qualify(s, t) if s\n\n if server_version >= 100000\n seq_ds = metad... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates the function in the database. Arguments: name :: name of the function to create definition :: string definition of the function, or object file for a dynamically loaded C function. opts :: options hash: :args :: function arguments, can be either a symbol or string specifying a type or an array of 13 elements: 1... | def create_function(name, definition, opts=OPTS)
self << create_function_sql(name, definition, opts)
end | [
"def create_function_sql(name, definition, opts=OPTS)\n args = opts[:args]\n if !opts[:args].is_a?(Array) || !opts[:args].any?{|a| Array(a).length == 3 and %w'OUT INOUT'.include?(a[2].to_s)}\n returns = opts[:returns] || 'void'\n end\n language = opts[:language] || 'SQL'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create the procedural language in the database. Arguments: name :: Name of the procedural language (e.g. plpgsql) opts :: options hash: :handler :: The name of a previously registered function used as a call handler for this language. :replace :: Replace the installed language if it already exists (on PostgreSQL 9.0+).... | def create_language(name, opts=OPTS)
self << create_language_sql(name, opts)
end | [
"def create_language_sql(name, opts=OPTS)\n \"CREATE#{' OR REPLACE' if opts[:replace] && server_version >= 90000}#{' TRUSTED' if opts[:trusted]} LANGUAGE #{name}#{\" HANDLER #{opts[:handler]}\" if opts[:handler]}#{\" VALIDATOR #{opts[:validator]}\" if opts[:validator]}\"\n end",
"def create_proc(name,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a trigger in the database. Arguments: table :: the table on which this trigger operates name :: the name of this trigger function :: the function to call for this trigger, which should return type trigger. opts :: options hash: :after :: Calls the trigger after execution instead of before. :args :: An argument o... | def create_trigger(table, name, function, opts=OPTS)
self << create_trigger_sql(table, name, function, opts)
end | [
"def add_trigger(table, events, options={})\n events += [:row] if options.delete(:row)\n events += [:before] if options.delete(:before)\n trigger = TriggerDefinition.new(0, table, options[:name], events, options[:function])\n execute trigger.to_sql_create\n end",
"def create_tr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use PostgreSQL's DO syntax to execute an anonymous code block. The code should be the literal code string to use in the underlying procedural language. Options: :language :: The procedural language the code is written in. The PostgreSQL default is plpgsql. Can be specified as a string or a symbol. | def do(code, opts=OPTS)
language = opts[:language]
run "DO #{"LANGUAGE #{literal(language.to_s)} " if language}#{literal(code)}"
end | [
"def block_code(code, language)\n Pygments.highlight(code, :lexer => language)\n end",
"def exec(code)\n instance_exec(code)\n end",
"def run(code)\n eval(code, binding)\n end",
"def create_proc(name, columns=[], options={}, &block)\n if select_value(\"SELECT count(oid) FROM pg_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Drops a procedural language from the database. Arguments: name :: name of the procedural language to drop opts :: options hash: :cascade :: Drop other objects depending on this function. :if_exists :: Don't raise an error if the function doesn't exist. | def drop_language(name, opts=OPTS)
self << drop_language_sql(name, opts)
end | [
"def drop_language_sql(name, opts=OPTS)\n \"DROP LANGUAGE#{' IF EXISTS' if opts[:if_exists]} #{name}#{' CASCADE' if opts[:cascade]}\"\n end",
"def drop_language(language, options = {})\n sql = 'DROP PROCEDURAL LANGUAGE '\n sql << 'IF EXISTS ' if options[:if_exists]\n sql << quote_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return full foreign key information using the pg system tables, including :name, :on_delete, :on_update, and :deferrable entries in the hashes. Supports additional options: :reverse :: Instead of returning foreign keys in the current table, return foreign keys in other tables that reference the current table. :schema :... | def foreign_key_list(table, opts=OPTS)
m = output_identifier_meth
schema, _ = opts.fetch(:schema, schema_and_table(table))
h = {}
fklod_map = FOREIGN_KEY_LIST_ON_DELETE_MAP
reverse = opts[:reverse]
(reverse ? _reverse_foreign_key_list_ds : _foreign_key_list_ds).where_e... | [
"def dump_table_foreign_keys(table, options=OPTS)\n if supports_foreign_key_parsing?\n fks = foreign_key_list(table, options).sort_by{|fk| fk[:columns]}\n end\n\n if fks.nil? || fks.empty?\n ''\n else\n dump_add_fk_constraints(table, fks)\n end\n end",
"def foreign... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dataset containing all current database locks | def locks
dataset.from(:pg_class).join(:pg_locks, :relation=>:relfilenode).select{[pg_class[:relname], Sequel::SQL::ColumnAll.new(:pg_locks)]}
end | [
"def locks\n query_column = self.query_column\n pid_column = self.pid_column\n sql = %Q(\n SELECT\n pg_stat_activity.#{pid_column} AS pid,\n pg_class.relname,\n pg_locks.transactionid,\n pg_locks.granted,\n pg_stat_activity.#{query_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Notifies the given channel. See the PostgreSQL NOTIFY documentation. Options: :payload :: The payload string to use for the NOTIFY statement. Only supported in PostgreSQL 9.0+. :server :: The server to which to send the NOTIFY statement, if the sharding support is being used. | def notify(channel, opts=OPTS)
sql = String.new
sql << "NOTIFY "
dataset.send(:identifier_append, sql, channel)
if payload = opts[:payload]
sql << ", "
dataset.literal_append(sql, payload.to_s)
end
execute_ddl(sql, opts)
end | [
"def notify_channel(connection, channel, payload)\n connection.execute(\"NOTIFY #{channel}, #{payload}\")\n end",
"def push_notification channel, message\n @notifiers[channel.to_sym].push(message) if @notifiers[channel.to_sym]\n end",
"def send_notification *args, &block\n if args.length == 1 ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Refresh the materialized view with the given name. DB.refresh_view(:items_view) REFRESH MATERIALIZED VIEW items_view DB.refresh_view(:items_view, concurrently: true) REFRESH MATERIALIZED VIEW CONCURRENTLY items_view | def refresh_view(name, opts=OPTS)
run "REFRESH MATERIALIZED VIEW#{' CONCURRENTLY' if opts[:concurrently]} #{quote_schema_table(name)}"
end | [
"def refresh_materialized_view(name)\n execute \"REFRESH MATERIALIZED VIEW #{name};\"\n end",
"def refresh_materialized_view(name, options = {})\n options = {\n :with_data => true\n }.merge(options)\n\n sql = \"REFRESH MATERIALIZED VIEW #{quote_view_name(name)}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset the primary key sequence for the given table, basing it on the maximum current value of the table's primary key. | def reset_primary_key_sequence(table)
return unless seq = primary_key_sequence(table)
pk = SQL::Identifier.new(primary_key(table))
db = self
s, t = schema_and_table(table)
table = Sequel.qualify(s, t) if s
if server_version >= 100000
seq_ds = metadata_dataset.f... | [
"def reset_pk_sequence!(table, pk = nil, sequence = nil)\n parent = parent_table(table)\n if parent\n reset_pk_sequence!(parent, pk, sequence)\n else\n unless pk and sequence\n default_pk, default_sequence = pk_and_sequence_for(table)\n pk |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PostgreSQL supports deferrable foreign key constraints. | def supports_deferrable_foreign_key_constraints?
true
end | [
"def supports_deferrable_foreign_key_constraints?\n sqlite_version >= 30619\n end",
"def foreign_key_drops; end",
"def supports_foreign_keys?; end",
"def supports_foreign_tables?; end",
"def foreign_key_adds; end",
"def composite_foreign_key(columns, opts)\n constraints << {:type => :fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PostgreSQL supports DROP TABLE IF EXISTS | def supports_drop_table_if_exists?
true
end | [
"def supports_drop_table_if_exists?\n true\n end",
"def supports_drop_table_if_exists?\n supports_create_table_if_not_exists?\n end",
"def drop_table(*args)\n options = args.extract_options!\n args.flatten!\n\n sql = 'DROP TABLE '\n sql << 'IF EXISTS ' if opti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PostgreSQL supports partial indexes. | def supports_partial_indexes?
true
end | [
"def supports_partial_indexes?\n false\n end",
"def supports_partial_indexes?\n false\n end",
"def supports_partial_index?; end",
"def supports_partial_indexes?\n sqlite_version >= 30800\n end",
"def unmatched_actual_indexes; end",
"def example_index_problem\n # This q... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PostgreSQL supports prepared transactions (twophase commit) if max_prepared_transactions is greater than 0. | def supports_prepared_transactions?
return @supports_prepared_transactions if defined?(@supports_prepared_transactions)
@supports_prepared_transactions = self['SHOW max_prepared_transactions'].get.to_i > 0
end | [
"def supports_prepared_transactions?\n false\n end",
"def commit_prepared_transaction(transaction_id, opts=OPTS)\n run(\"COMMIT TRANSACTION #{transaction_id}\", opts)\n end",
"def commit_transaction(conn, opts=OPTS)\n if (s = opts[:prepare]) && savepoint_level(conn) <= 1\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PostgreSQL supports transaction DDL statements. | def supports_transactional_ddl?
true
end | [
"def supports_ddl_transactions?; end",
"def supports_transactional_ddl?\n true\n end",
"def ddl_transaction(migration)\n if use_transaction?(migration)\n ActiveRecord::Base.transaction { yield }\n else\n yield\n end\n end",
"def commit_transaction_sql\n 'CO... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Array of symbols specifying view names in the current database. Options: :materialized :: Return materialized views :qualify :: Return the views as Sequel::SQL::QualifiedIdentifier instances, using the schema the view is located in as the qualifier. :schema :: The schema to search :server :: The server to use | def views(opts=OPTS)
relkind = opts[:materialized] ? 'm' : 'v'
pg_class_relname(relkind, opts)
end | [
"def views(name=nil)\n schemas = schema_search_path.split(/,\\s*/).map { |p| quote(p) }.join(',')\n query(<<~SQL, name).map { |row| row[0] }\n SELECT viewname\n FROM pg_views\n WHERE schemaname IN (#{schemas})\n SQL\n end",
"def enum_view_names... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dataset used to retrieve CHECK constraint information | def _check_constraints_ds
@_check_constraints_ds ||= metadata_dataset.
from{pg_constraint.as(:co)}.
left_join(Sequel[:pg_attribute].as(:att), :attrelid=>:conrelid, :attnum=>SQL::Function.new(:ANY, Sequel[:co][:conkey])).
where(:contype=>'c').
select{[co[:conname].as(:cons... | [
"def parse_constraint_validations\n db.extension(:_model_constraint_validations)\n\n unless hash = Sequel.synchronize{db.constraint_validations}\n hash = {}\n db.from(constraint_validations_table).each do |r|\n (hash[r[:table]] ||= []) << r\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build dataset used for foreign key list methods. | def __foreign_key_list_ds(reverse)
if reverse
ctable = Sequel[:att2]
cclass = Sequel[:cl2]
rtable = Sequel[:att]
rclass = Sequel[:cl]
else
ctable = Sequel[:att]
cclass = Sequel[:cl]
rtable = Sequel[:att2]
rclass = Sequel[:cl... | [
"def build!(data_set_name)\n interface(data_set_name).create_empty_data_set\n library[data_set_name] = DataSet.new(data_set_name, interface(data_set_name))\n end",
"def foreign_key_list(table, opts=OPTS)\n m = output_identifier_meth\n h = {}\n metadata_dataset.with_sql(\"PR... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.