query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
GET /party_lists GET /party_lists.json | def index
@party_lists = PartyList.all.order(:id)
end | [
"def lists\n\t\tlistable = Listable.find_by_id(params['listable_id'])\n\t\tunless listable\n\t\t\trender :json => 'not found' , :status => :not_found\n\t\t\treturn\n\t\tend\n\t\tlists = List.where :name => listable.name\t\n\t\trender :json => lists.to_json\n\tend",
"def get_list(list_id:)\n JSON.parse(api_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /party_lists POST /party_lists.json | def create
@party_list = PartyList.new(party_list_params)
respond_to do |format|
if @party_list.save
format.html { redirect_to @party_list, notice: 'Party list was successfully created.' }
format.json { render :show, status: :created, location: @party_list }
else
format.html... | [
"def create_list(name:)\n JSON.parse(api_request(method: :post, path: \"lists\", params: list_params(name)))\n end",
"def update\n respond_to do |format|\n if @party_list.update(party_list_params)\n format.html { redirect_to @party_list, notice: 'Party list was successfully updated.' }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /party_lists/1 PATCH/PUT /party_lists/1.json | def update
respond_to do |format|
if @party_list.update(party_list_params)
format.html { redirect_to @party_list, notice: 'Party list was successfully updated.' }
format.json { render :show, status: :ok, location: @party_list }
else
format.html { render :edit }
format.jso... | [
"def update_list(list_id:, name:)\n api_request(method: :patch, path: \"lists/#{list_id}\", params: list_params(name))\n end",
"def update\n @party = current_user.parties.find(params[:id])\n\n respond_to do |format|\n if @party.update_attributes(params[:party])\n format.html { redire... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /party_lists/1 DELETE /party_lists/1.json | def destroy
@party_list.destroy
respond_to do |format|
format.html { redirect_to party_lists_url, notice: 'Party list was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @party = Party.find(params[:id])\n @party.destroy\n\n respond_to do |format|\n format.html { redirect_to(parties_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @party = Party.find(params[:id])\n @party.destroy\n\n respond_to do |format|\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simple method to merge strings from freelancer skills | def merge_skills(skills, newSkill)
if newSkill!=""
skills = skills + " " + newSkill
end
return skills
end | [
"def full_name_with_skills\n self.full_name + ' ' + self.all_skills_with_hashtags\n end",
"def merica(str)\n # concatenating the strings\n str + \"only in America!\"\nend",
"def merge_word_strings str1, str2\n return str2||\"\" if str1.blank?\n return str1 if str2.blank?\n (str1.split(/\\s+/) + str... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use the Anemone page store to find the closest referer in the crawl tree that is a case (or nil if any URL in the chain can't be found) | def find_nearest_page_matching(url, regex)
raise ArgumentError,
'No crawl found. Set @crawl as the first thing in your Anemone.crawl block' if crawl.nil?
page = @crawl.pages[url]
return page if page.nil? || page.url.to_s =~ regex
find_nearest_page_matching(page.referer, regex)
... | [
"def find_next_url(page)\r\n raise 'Define me!'\r\n end",
"def find_linked_page( current_page, reference )\n\t\t\n\t\tcatalog = current_page.catalog\n\t\t\n\t\t# Lookup by page path\n\t\tif reference =~ /\\.page$/\n\t\t\treturn catalog.uri_index[ reference ]\n\t\t\t\n\t\t# Lookup by page title\n\t\tel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List milestones for a repository = Examples bitbucket = BitBucket.new :user => 'username', :repo => 'reponame' bitbucket.issues.milestones.list | def list(user_name, repo_name, params={})
_update_user_repo_params(user_name, repo_name)
_validate_user_repo_params(user, repo) unless user? && repo?
normalize! params
response = get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
return response unless bl... | [
"def list_milestones(repository, options = T.unsafe(nil)); end",
"def fetch()\n puts \"+ Loading github milestones\".blue\n\n @milestones = GitHub.get \"#{REPO}/milestones\", :headers => {\"User-Agent\" => \"Jamoma issues migration\"}\n end",
"def milestones\n Sifter.\n get(api_milestones_url).\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a single milestone = Examples bitbucket = BitBucket.new bitbucket.issues.milestones.get 'username', 'reponame', 'milestoneid' | def get(user_name, repo_name, milestone_id, params={})
_update_user_repo_params(user_name, repo_name)
_validate_user_repo_params(user, repo) unless user? && repo?
_validate_presence_of milestone_id
normalize! params
get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/milestones... | [
"def get(projectId,milestoneId)\r\n\t\t\t\turl = getBaseURL+\"projects/\"+String(projectId)+\"/milestones/\"+String(milestoneId)+\"/\"\r\n\t\t\t\tresponse = ZohoHTTPClient.get(url, getQueryMap)\r\n\t\t\t\treturn $milestonesParser.getMilestone(response)\r\n\t\t\tend",
"def get(user_name, repo_name, milestone_id, p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a milestone = Inputs :name Required string = Examples bitbucket = BitBucket.new :user => 'username', :repo => 'reponame' bitbucket.issues.milestones.create :name => 'helloworld' | def create(user_name, repo_name, params={})
_update_user_repo_params(user_name, repo_name)
_validate_user_repo_params(user, repo) unless user? && repo?
normalize! params
filter! VALID_MILESTONE_INPUTS, params
assert_required_keys(%w[ name ], params)
post_request("/1.0/repositories/... | [
"def create(projectId,milestone)\r\n\t\t\t\turl = getBaseURL+\"projects/\"+String(projectId)+\"/milestones/\"\r\n\t\t\t\tresponse = ZohoHTTPClient.post(url, getQueryMap, milestone.toParamMAP())\r\n\t\t\t\treturn $milestonesParser.getMilestone(response)\r\n\t\t\tend",
"def create_milestones(project_id, milestones)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update a milestone = Inputs :name Required string = Examples bitbucket = BitBucket.new bitbucket.issues.milestones.update 'username', 'reponame', 'milestoneid', :name => 'helloworld' | def update(user_name, repo_name, milestone_id, params={})
_update_user_repo_params(user_name, repo_name)
_validate_user_repo_params(user, repo) unless user? && repo?
_validate_presence_of milestone_id
normalize! params
filter! VALID_MILESTONE_INPUTS, params
assert_required_keys(%w[ ... | [
"def update(user_name, repo_name, milestone_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of milestone_id\n\n normalize! params\n filter! VALID_MILESTONE_INPUTS, params\n assert_requir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /custom_events/1 GET /custom_events/1.xml | def show
@custom_event = CustomEvent.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @custom_event }
end
end | [
"def calendar_event(event_id)\n record \"/calendar_events/#{event_id}.xml\", :method => :get\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def index\n @events = Event.lookup\n\n respond_to do |format|\n format.html # index.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /custom_events/new GET /custom_events/new.xml | def new
@custom_event = CustomEvent.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @custom_event }
end
end | [
"def new\n @event = Event.new_default\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end",
"def new\n setup_variables\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /custom_events/1 PUT /custom_events/1.xml | def update
@custom_event = CustomEvent.find(params[:id])
respond_to do |format|
if @custom_event.update_attributes(params[:custom_event])
logger.info "updated attribute"
flash[:notice] = 'CustomEvent was successfully updated.'
#@custom_events = CustomEvent.find(:all)
#@public... | [
"def update\n @custom_event = CustomEvent.find(params[:id])\n\n respond_to do |format|\n if @custom_event.update_attributes(params[:custom_event])\n format.html { redirect_to(@custom_event, :notice => 'Custom event was successfully updated.') }\n format.xml { head :ok }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /custom_events/1 DELETE /custom_events/1.xml | def destroy
@custom_event = CustomEvent.find(params[:id])
@custom_event.destroy
respond_to do |format|
format.html { redirect_to(custom_events_url) }
format.xml { head :ok }
end
end | [
"def delete_events(args)\n\t\t\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\t\t\tdo_the_delete_call( url: api_url )\n\t\tend",
"def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to(events_path) }\n format.xml { head :o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The host name at which to connect to Solr. Default 'localhost'. ==== Returns String:: host name | def hostname
unless defined?(@hostname)
@hostname = solr_url.host if solr_url
@hostname ||= user_configuration_from_key('solr', 'hostname')
@hostname ||= default_hostname
end
@hostname
end | [
"def hostname\n unless defined?(@hostname)\n @hostname = solr_url.host if solr_url\n @hostname ||= configuration_from_key('solr', @hostname_key)\n @hostname ||= default_hostname\n end\n @hostname\n end",
"def hostname\n name + '.localhost'\n end",
"def hostname\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The port at which to connect to Solr. Defaults to 8981 in test, 8982 in development and 8983 in production. ==== Returns Integer:: port | def port
unless defined?(@port)
@port = solr_url.port if solr_url
@port ||= user_configuration_from_key('solr', 'port')
@port ||= default_port
@port = @port.to_i
end
@port
end | [
"def port\n @port ||=\n if user_configuration.has_key?('solr')\n user_configuration['solr']['port']\n end || 8983\n end",
"def port\n @port ||= default_port\n end",
"def port\n @port ||= use_ssl ? 636 : 389\n end",
"def port\n server.addr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The url path to the Solr servlet (useful if you are running multicore). Default '/solr/default'. ==== Returns String:: path | def path
unless defined?(@path)
@path = solr_url.path if solr_url
@path ||= user_configuration_from_key('solr', 'path')
@path ||= default_path
end
@path
end | [
"def path\n unless defined?(@path)\n @path = solr_url.path if solr_url\n @path ||= configuration_from_key('solr', @path_key)\n @path ||= default_path\n end\n @path\n end",
"def path\n @path ||=\n if user_configuration.has_key?('solr')\n \"#{user_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The host name at which to connect to the master Solr instance. Defaults to the 'hostname' configuration option. ==== Returns String:: host name | def master_hostname
@master_hostname ||= (user_configuration_from_key('master_solr', 'hostname') || hostname)
end | [
"def hostname\n unless defined?(@hostname)\n @hostname = solr_url.host if solr_url\n @hostname ||= configuration_from_key('solr', @hostname_key)\n @hostname ||= default_hostname\n end\n @hostname\n end",
"def hostname\n unless defined?(@hostname)\n @hostnam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The path to the master Solr servlet (useful if you are running multicore). Defaults to the value of the 'path' configuration option. ==== Returns String:: path | def master_path
@master_path ||= (user_configuration_from_key('master_solr', 'path') || path)
end | [
"def path\n @path ||=\n if user_configuration.has_key?('solr')\n \"#{user_configuration['solr']['path'] || '/solr'}\"\n end\n end",
"def path\n unless defined?(@path)\n @path = solr_url.path if solr_url\n @path ||= configuration_from_key('solr', @path_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
True if there is a master Solr instance configured, otherwise false. ==== Returns Boolean:: bool | def has_master?
@has_master = !!user_configuration_from_key('master_solr')
end | [
"def is_master_running?\n !list_of_running_instances.select {|a| a.name == \"master\"}.first.nil?\n end",
"def master?\n @server_type == 'master'\n end",
"def master?\n doc = db_command(:ismaster => 1)\n is_master = doc['ismaster']\n ok?(doc) && is_master.kind_of?(Nume... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The default log_level that should be passed to solr. You can change the individual log_levels in the solr admin interface. If no level is specified in the sunspot configuration file, use a level similar to Rails own logging level. ==== Returns String:: log_level | def log_level
@log_level ||= (
user_configuration_from_key('solr', 'log_level') ||
LOG_LEVELS[::Rails.logger.level]
)
end | [
"def log_level\n @log_level ||= configuration_from_key('solr', 'log_level')\n @log_level ||= LOG_LEVELS[::Rails.logger.level]\n end",
"def default_log_level\n\t\t\tif $DEBUG\n\t\t\t\tLogger::DEBUG\n\t\t\telsif $VERBOSE\n\t\t\t\tLogger::INFO\n\t\t\telse\n\t\t\t\tLogger::WARN\n\t\t\tend\n\t\tend",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Should the solr index receive a commit after each httprequest. Default true ==== Returns Boolean: auto_commit_after_request? | def auto_commit_after_request?
@auto_commit_after_request ||=
user_configuration_from_key('auto_commit_after_request') != false
end | [
"def auto_commit_after_request?\n @auto_commit_after_request ||= (configuration_from_key('auto_commit_after_request') != false)\n end",
"def auto_commit?\n\t\t@auto_commit\n\tend",
"def force_solr_commit\n # assuming we're running this after adding\n # some things to Solr, we want to give ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
As for auto_commit_after_request? but only for deletes Default false ==== Returns Boolean: auto_commit_after_delete_request? | def auto_commit_after_delete_request?
@auto_commit_after_delete_request ||=
(user_configuration_from_key('auto_commit_after_delete_request') || false)
end | [
"def auto_commit_after_delete_request?\n @auto_commit_after_delete_request ||= (configuration_from_key('auto_commit_after_delete_request') || false)\n end",
"def auto_commit_after_request?\n @auto_commit_after_request ||= (configuration_from_key('auto_commit_after_request') != false)\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The callback to use when automatically indexing records. Defaults to after_save. | def auto_index_callback
@auto_index_callback ||=
(user_configuration_from_key('auto_index_callback') || 'after_save')
end | [
"def auto_index_callback\n @auto_index_callback ||= (configuration_from_key('auto_index_callback') || 'after_save')\n end",
"def after_update\n super\n self.class.call_es { index_document }\n end",
"def after_update\n super\n self.class.call_es { _index_documen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Logging in rails_root/log as solr_.log as a default. ===== Returns String:: default_log_file_location | def default_log_file_location
File.join(::Rails.root, 'log', "solr_" + ::Rails.env + ".log")
end | [
"def default_log_file_location\n File.join(::Rails.root, 'log', \"solr_\" + ::Rails.env + \".log\")\n end",
"def log_file\n File.join(FileUtils.pwd, 'log', \"sunspot-solr.log\")\n end",
"def log_file\n File.join(::Rails.root, 'log', \"sunspot-solr-#{::Rails.env}.log\")\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clears both the internal lists of entities and contexts. | def clear
@entity_list = {}
@context_list = {}
@last_unique_id = 0
@entity_names = {} # Internal cache of context names for quick key retrieval
end | [
"def clear!\n contexts.clear\n attributes.clear\n end",
"def clear!\n context_manager.clear!\n end",
"def clear_context\n end",
"def clear_current\n all_contexts.delete(Thread.current.object_id)\n end",
"def remove_all_contexts\n previous_size = @contexts.size\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
++ Creates a new EntityDAO, adding it to the internal list and returning its instance. Entity names should be unique among the same context. (No check is performed about this, though.) They will be converted to strings internally. | def new_entity( name, parent_context = nil )
@last_unique_id += 1
entity = V3::EntityDAO.new( @last_unique_id, name.to_s, parent_context )
parent_context.entity_list[ name.to_s ] = entity if parent_context.instance_of?( V3::ContextDAO )
# Cache the key for... | [
"def create_entity\n context.entity = Entity.new(context.to_h)\n context.entity.uuid = UUID.generate(:compact)\n context.entity.display_name ||= context.entity.name\n context.entity.cached_full_name ||= context.entity.decorate.full_name\n context.entity.source ||= :local\n end",
"def get_entity( n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new ContextDAO, adding it to the internal list and returning its instance. Context names can be duplicated, to allow multiple childcontexts holding different values of the same group of entities. The suggested way to process the contexts is as a sequential list. (i.e. scanning all the contexts named "result_r... | def new_context( name, parent_context = nil )
@last_unique_id += 1
@context_list[ @last_unique_id ] = V3::ContextDAO.new( @last_unique_id, name.to_s, parent_context )
end | [
"def contexts\n @contexts ||= Hash.new\n end",
"def build_context(context: Context.current)\n builder = Builder.new(correlations_for(context).dup)\n yield builder\n context.set_value(CORRELATION_CONTEXT_KEY, builder.entries)\n end",
"def new_context( name, parent_contex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
++ Retrieves the unique entity name, used internally to cache its key. | def get_entity_unique_name( name, parent_context = nil )
"#{ parent_context ? "#{parent_context.id}-#{parent_context.name}" : '' }-#{ name.to_s }"
end | [
"def entity_name\n @entity[:name]\n end",
"def get_entity_unique_name( name, parent_context = nil )\n @factory.get_entity_unique_name( name, parent_context )\n end",
"def object_name_from_external_entity_hash(entity)\n raise \"Not implemented\"\n end",
"def object_name_from_external_entity... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves an entity by its name, given the parent context instance. | def get_entity( name, parent_context = nil )
id = @entity_names[ get_entity_unique_name(name, parent_context) ]
@entity_list[ id ]
end | [
"def get_entity( name, parent_context = nil )\n @factory.get_entity( name, parent_context )\n end",
"def entity(name)\n @entities[name]\n end",
"def get_entity_unique_name( name, parent_context = nil )\n @factory.get_entity_unique_name( name, parent_context )\n end",
"def get(class_name, id)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
++ Retrieves the contexts named as indicated. (i.e. "all the contexts named 'result_row'") | def get_contexts_named( name )
@context_list.values.map{ |context| context if context.name == name }.compact
end | [
"def result_for( context_name )\n @result.get_contexts_named( context_name )\n end",
"def get_contexts_named( name )\n @factory.get_contexts_named( name )\n end",
"def contexts\n JSON.parse(raw_contexts())[\"results\"][\"bindings\"].map{|x| x[\"contextID\"][\"value\"] }\n end",
"def context_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
++ Retrieves all the entities for a specific context. | def get_entities_for_context( parent_context = nil )
if parent_context.instance_of?( V3::ContextDAO )# Context specified? Return its entity list:
parent_context.entity_list.values
else # Let's do a "manual" search among the entities:
# [Steve, 20150805] Thi... | [
"def get_entities_for_context( parent_context = nil )\n @factory.get_entities_for_context( parent_context )\n end",
"def entities\n @@entities ||= load\n end",
"def entities\n _entities\n end",
"def entities\n @entities ||= []\n end",
"def active_entities\n request... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all the (siblings) contexts for a specific context. Note that by specifying +nil+ as a parent context, will result in all root context retrieved. | def get_siblings_for_context( parent_context = nil )
@context_list.values.map do |context|
context if context.respond_to?(:parent_context) && (context.parent_context == parent_context)
end.compact
end | [
"def get_siblings_for_context( parent_context = nil )\n @factory.get_siblings_for_context( parent_context )\n end",
"def contexts(mode=nil)\n\t\t\tmode ||= :flat\n\n\t\t\tif mode == :flat\n\t\t\t\tqueue, ctxs = @contexts.clone, []\n\t\t\t\twhile (ctx = queue.shift)\n\t\t\t\t\t#\tmyself\n\t\t\t\t\tctxs << ctx\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: For a given +point+ in time, calculates the load which should be handled by transient energy producers, and assigns the calculated values to the producer's load curve. This is the "jumping off point" for calculating the merit order, and note that the method is called once per Merit::POINT. Since Calculator co... | def compute_point(order, point, producers)
# Optimisation: This is order-dependent; it requires that always-on
# producers are before the transient producers, otherwise "remaining"
# load will not be correct.
#
# Since this method is called a lot, being able to handle always-on a... | [
"def compute_point(order, point, participants)\n if (demand = demand_at(order, point)).negative?\n raise SubZeroDemand.new(point, demand)\n end\n\n demand = compute_always_ons(\n point, demand,\n participants.always_on,\n participants.flex.at_point(point)\n )\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a new secondary_publication_number | def create
@secondary_publication_number = SecondaryPublicationNumber.new(params[:secondary_publication_number])
@secondary_publication_number.save
end | [
"def create\n @primary_publication_number = PrimaryPublicationNumber.new(params[:primary_publication_number])\n @primary_publication_number.save\n end",
"def update\n @secondary_publication_number = SecondaryPublicationNumber.find(params[:id])\n\t@secondary_publication_number.update_attributes... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update an existing secondary_publication_number | def update
@secondary_publication_number = SecondaryPublicationNumber.find(params[:id])
@secondary_publication_number.update_attributes(params[:secondary_publication_number])
end | [
"def update\n @primary_publication_number = PrimaryPublicationNumber.find(params[:id])\n\t @primary_publication_number.update_attributes(params[:primary_publication_number])\n end",
"def update\n @primary_publication_number = PrimaryPublicationNumber.find(params[:id])\n\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
destroy the secondary_publication_number with id = params[:id] | def destroy
thisNumber = SecondaryPublicationNumber.find(params[:id])
thisNumber.destroy
@secondary_publications = @study.get_secondary_publications(params[:extraction_form_id])
end | [
"def destroy\n @primary_publication_number = PrimaryPublicationNumber.find(params[:id])\n @primary_publication_number.destroy\n\n respond_to do |format|\n format.html { redirect_to(primary_publication_numbers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @publication_num... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /product_cates GET /product_cates.json | def index
@product_cates = ProductCate.all
end | [
"def index\n @product_cates = ProductCate.page(params[:page]).order(\"updated_at DESC\")\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n @product_categories = Produc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /product_cates POST /product_cates.json | def create
@product_cate = ProductCate.new(product_cate_params)
respond_to do |format|
if @product_cate.save
format.html { redirect_to @product_cate, notice: 'Product cate was successfully created.' }
format.json { render :show, status: :created, location: @product_cate }
else
... | [
"def index\n @product_cates = ProductCate.all\n end",
"def create\n @candies_product = CandiesProduct.new(candies_product_params)\n\n respond_to do |format|\n if @candies_product.save\n format.html { redirect_to @candies_product, notice: 'Candies product was successfully created.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /product_cates/1 DELETE /product_cates/1.json | def destroy
@product_cate.destroy
respond_to do |format|
format.html { redirect_to product_cates_url, notice: 'Product cate was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @client_product.destroy\n respond_to do |format|\n format.html { redirect_to @client, notice: 'Custom price was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @productos_json.destroy\n respond_to do |format|\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add or change an asset id in the asset id cache. This can be used for SASS on Heroku. :api: public | def add_to_asset_ids_cache(source, asset_id)
self.asset_ids_cache_guard.synchronize do
self.asset_ids_cache[source] = asset_id
end
end | [
"def rails_asset_id(source)\n if asset_id = ENV[\"RAILS_ASSET_ID\"]\n asset_id\n else\n if self.cache_asset_ids && (asset_id = self.asset_ids_cache[source])\n asset_id\n else\n path = File.join(config.assets_dir, source)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sort talks in descending order by duraion Find number of tracks needed, since we know the total duraion exactly And intialize tracks As per the Best fit algorithm, Fill each tracks by looping through sorted talks Do this till available talks become empty | def schedule_talks
until available_talks.empty?
Track.all.each do |track|
schedule_talks_for_track(track)
# When a track didn't fill exactly
# Removing already scheduled last element from track and
# Again trying for a exact match on available talks
# Not a perfect sol... | [
"def pack_talks\n\n @tracks << Track.new() # create first [0] Track object\n x = 0 # first object @tracks[0]\n\n @talks.each do |talk|\n\n # if it's morning session, set limit to 180min, otherwise to 240min\n len = get_max_length(x)\n\n # if the sum of Track's total length + current talk's l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return true if canceled this task ==== Return true if canceled this task | def canceled?
@state == :cancel
end | [
"def canceled?\n @__status == TaskStatus::CANCELED\n end",
"def cancel\n warn(\"Cancelling task #{name}...\")\n self.status = :canceled\n stopped?\n end",
"def cancelled?\n cancelled\n end",
"def cancelled?\n return @cancelled\n end",
"def canceled_by?(event)\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A getter for `gradle_task`, returning 'spotbugsRelease' if value is nil. | def gradle_task
@gradle_task ||= 'spotbugsRelease'
end | [
"def gradle_task\n @gradle_task ||= 'pmd'\n end",
"def gradle_task\n @gradle_task ||= \"ktlintCheck\"\n end",
"def gradle_task\n @gradle_task ||= \"lint\"\n end",
"def get_task(task_name)\n if using_rake? and task_defined?(task_name)\n Rake::Task[task_name]\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A getter for `skip_gradle_task`, returning false if value is nil. | def skip_gradle_task
@skip_gradle_task ||= false
end | [
"def excluded_task?(task)\n @tasks.include?(task)\n end",
"def ignore_force?(task)\n !(metadata[\"run_#{task}\"].nil? || metadata[\"run_#{task}\"])\n end",
"def skip?\n !!current_model.try(:skip?)\n end",
"def ignore_task?(task)\n return true unless is_active?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A getter for `root_path`, returning result of `git revparse showtoplevel` if value is nil. | def root_path
@root_path ||= `git rev-parse --show-toplevel`.chomp
end | [
"def repository_root\n return unless available?\n root = Licensed::Shell.execute(\"git\", \"rev-parse\", \"--show-toplevel\", allow_failure: true)\n return nil if root.empty?\n root\n end",
"def root\n Pathname.new `git rev-parse --show-toplevel`.chomp\n end",
"def raw_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A getter for `report_file`, returning 'app/build/reports/spotbugs/release.xml' if value is nil. | def report_file
@report_file ||= 'app/build/reports/spotbugs/release.xml'
end | [
"def report_file\n return @report_file || \"build/reports/detekt/detekt.xml\"\n end",
"def report_file\n @report_file ||= 'app/build/reports/pmd/pmd.xml'\n end",
"def report_file\n @report_file ||= 'build/reports/jacoco/jacoco/jacoco.xml'\n end",
"def report_to\n @report_to ||= fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A getter for `report_files`, returning ['app/build/reports/spotbugs/release.xml'] if value is nil. | def report_files
@report_files ||= [report_file]
end | [
"def report_file\n @report_file ||= 'app/build/reports/spotbugs/release.xml'\n end",
"def report_file\n return @report_file || \"build/reports/detekt/detekt.xml\"\n end",
"def ed_reports\n Dir.children(path).select{ |fn| fn.end_with?('editor_report.xls') }\n end",
"def get_files\n fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls SpotBugs task of your Gradle project. It fails if `gradlew` cannot be found inside current directory. It fails if `report_file` cannot be found inside current directory. It fails if `report_files` is empty. | def report(inline_mode: true)
unless skip_gradle_task
raise('Could not find `gradlew` inside current directory') unless gradlew_exists?
exec_gradle_task
end
report_files_expanded = Dir.glob(report_files).sort
raise("Could not find matching SpotBugs report files for #{report_fil... | [
"def lint\n unless gradlew_exists?\n fail(\"Could not find `gradlew` inside current directory\")\n return\n end\n\n unless SEVERITY_LEVELS.include?(severity)\n fail(\"'#{severity}' is not a valid value for `severity` parameter.\")\n return\n end\n\n system \"./gr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check gradlew file exists in current directory. | def gradlew_exists?
!`ls gradlew`.strip.empty?
end | [
"def gradlew_exists?\n `ls gradlew`.strip.empty? == false\n end",
"def web_build_exists?\n File.exist?(File.join(absolute_path, 'package.json'))\n end",
"def test_env_sample_exists\n assert(File.file?('./.env_sample'))\n end",
"def project_configuration_file_exists?\n File.exi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A getter for `spotbugs_report`, returning SpotBugs report. | def spotbugs_report(report_file)
require 'oga'
Oga.parse_xml(File.open(report_file))
end | [
"def report_file\n @report_file ||= 'app/build/reports/spotbugs/release.xml'\n end",
"def get_bug_report_fields\n return bugs_report_fields\n end",
"def report\n return @report\n end",
"def getBug(response)\r\n\t\t\t\tbug_json = JSON.parse response\r\n\t\t\t\tbug_array = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns +ture+ if the element is included in _self_. | def include?(elem)
@elements.include?(elem)
end | [
"def not_include?(element)\n !self.include?(element)\n end",
"def include?(el)\n end",
"def include?(item)\n true\n end",
"def include?( element_id )\n self.elements_ids.include?( element_id )\n end",
"def included?\n if self.included.nil?\n (parent.nil? ? false : parent.include... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes the +element+ from this max heap, and maintains the heap properties. If the element is not found, return +nil+. | def delete(elem)
deleted = @elements.delete(elem)
build_heap unless deleted.nil?
deleted
end | [
"def remove()\n return if @store.empty? # do nothing\n\n swap(0, -1) # swap the first and the last (Take the bottom level's right-most item and move it to the top, to fill in the hole.)\n removed = @store.pop\n\n heap_down() if @store.length > 1 # only if there is something to heap down\n return remo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the parent index of the element at +i+. | def parent(i)
(i-1)/2
end | [
"def parent_at(i)\n @parents.keys.sort.collect {|p| [p] * @parents[p].length }.flatten[i]\n end",
"def parent(i)\n @data[parent_index(i)]\n end",
"def parent_child_index(parent) #:nodoc:\n duck = parent[:builder].instance_variable_get('@nested_child_index')\n\n child = parent[:for]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Heapifies the element at position +i+. | def heapify(i)
left = left(i)
right = right(i)
target = i
if left < @elements.size and @comparator.call(@elements[i],@elements[left]) < 0
target = left
end
if right < @elements.size and @comparator.call(@elements[target],@elements[right]) < 0
targe... | [
"def heapify(i)\n left = left_index(i)\n left = nil if left >= @data.size\n\n right = right_index(i)\n right = nil if right >= @data.size\n\n largest = [i,left,right].compact.sort{|x,y| relation(x,y)?-1:1}.first\n\n if largest != i\n @data[i], @data[largest] = @data[largest], @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if this numeric range intersects with another | def intersect?(o)
self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)
end | [
"def bounds_intersected_by?(range)\n return false if IntervalSet.range_empty?(range)\n\n !empty? && range.first < max && range.last > min\n end",
"def bounds_intersected_or_touched_by?(range)\n return false if IntervalSet.range_empty?(range)\n\n !empty? && range.first <= max && range.last >= min\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /event_elements GET /event_elements.json | def index
@event_elements = EventElement.all
end | [
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def events\n events = @vulnerability.events.map do |e|\n {\n id: e.id,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /event_elements POST /event_elements.json | def create
@event_element = EventElement.new(event_element_params)
respond_to do |format|
if @event_element.save
format.html { redirect_to @event_element, notice: 'Event element was successfully created.' }
format.json { render :show, status: :created, location: @event_element }
els... | [
"def push_events\n saved = []\n jsonHash = request.POST[:_json];\n jsonHash.each do |jsonEvent|\n event = Event.new\n event.race_id = jsonEvent[\"raceId\"]\n event.walker_id = jsonEvent[\"walkerId\"]\n event.eventId = jsonEvent[\"eventId\"]\n event.eventType = jsonEvent[\"type\"]\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /event_elements/1 PATCH/PUT /event_elements/1.json | def update
respond_to do |format|
if @event_element.update(event_element_params)
format.html { redirect_to @event_element, notice: 'Event element was successfully updated.' }
format.json { render :show, status: :ok, location: @event_element }
else
format.html { render :edit }
... | [
"def update\n event = event.find(params[\"id\"]) \n event.update_attributes(event_params) \n respond_with event, json: event\n end",
"def update\n #TODO params -> strong_params\n if @event.update(params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /event_elements/1 DELETE /event_elements/1.json | def destroy
@event_element.destroy
respond_to do |format|
format.html { redirect_to event_elements_url, notice: 'Event element was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @simple_event = SimpleEvent.find(params[:id])\n @simple_event.destroy\n\n respond_to do |format|\n format.html { redirect_to simple_events_dashboard_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event = Event.using(:shard_one).find(params[:id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
up by identifiers for each block, print 1 message per failure or error found | def parse_message_from_log_entry
unique_messages = { }
id = ""
ARGF.each do |line|
block_id = line.match(/Loaded suite (.*)/)
failure_msg = line.match(/[1-9]+ failures/)
err_msg = line.match(/[1-9]+ errors/)
if ! block_id.nil?
id = block_id[1]
elsif ! failure_msg.n... | [
"def print_failures\n report_errors.each { | err| puts \" + #{err}\" }\n errors.each { |err| puts \" - #{err}\" }\n end",
"def summarize_errors\n return if failures_and_errors.empty?\n\n puts \"Failures:\"\n puts\n\n pad_indexes = failures_and_errors.size.to_s.size\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /contacters/new GET /contacters/new.json | def new
@contacter = Contacter.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @contacter }
end
end | [
"def new\n @character = Character.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @character }\n end\n end",
"def new\n @caracteristica = Caracteristica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /contacters/1 PUT /contacters/1.json | def update
@contacter = Contacter.find(params[:id])
respond_to do |format|
if @contacter.update_attributes(params[:contacter])
format.html { redirect_to @contacter, notice: 'Contacter was successfully updated.' }
format.json { head :no_content }
else
format.html { render act... | [
"def update\n respond_to do |format|\n if @caracter.update(caracter_params)\n format.html { redirect_to @caracter, notice: 'Caracter was successfully updated.' }\n format.json { render :show, status: :ok, location: @caracter }\n else\n format.html { render :edit }\n format.j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /contacters/1 DELETE /contacters/1.json | def destroy
@contacter = Contacter.find(params[:id])
@contacter.destroy
respond_to do |format|
format.html { redirect_to contacters_url }
format.json { head :no_content }
end
end | [
"def destroy\n @contacter = Contacter.find(params[:id])\n @contacter.destroy\n\n respond_to do |format|\n format.html { redirect_to(bin_contacters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @caracter.destroy\n respond_to do |format|\n format.html { redirect_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If the passphrase contains one of "i", "o" or "l", we should skip past all the subsequent strings in the sequence that will also contain these letters. | def skip_known_failures(passphrase)
passphrase.gsub(/[iol].+$/) { |m| m.chars.first.next + ('a' * m[1..-1].size) }
end | [
"def valid_subsequent_letters(letter)\n case letter\n when 'h'\n # i and j may or may not be skipped\n %w[i j k]\n when 'i'\n # j may or may not be skipped\n %w[j k]\n when 'k'\n # always skip l\n %w[m]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A method that attempts to render content from rit and if none found will raise an error Arguments: layout_name: +String+ The name of the rit layout instance_name: +String+ The name of the rit instance (optional) plate_name: +String+ The name of the rit plate Returns: Returns content (string) or raises error if not foun... | def rit_plate!(layout_name, instance_name, plate_name)
Rit::Plate.get(layout_name, instance_name, plate_name, session[:preview_time])
end | [
"def rit_plate!(layout_name, instance_name, plate_name)\n RitClient::Plate.get(layout_name, instance_name, plate_name, nil) # session[:preview_time]\n end",
"def render_content_in_layout(layout, object)\n content = object.matter\n layout.gsub /\\{\\{(.+?)\\}\\}/ do |tag_invocation|\n if md ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /fotos_empresas GET /fotos_empresas.json | def index
@fotos_empresas = FotosEmpresa.all
end | [
"def index\n @fotos = Foto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fotos }\n end\n end",
"def show\n @fotosresposta = Fotosresposta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /fotos_empresas POST /fotos_empresas.json | def create
@fotos_empresa = FotosEmpresa.new(fotos_empresa_params)
respond_to do |format|
if @fotos_empresa.save
format.html { redirect_to @fotos_empresa, notice: 'Fotos empresa was successfully created.' }
format.json { render :show, status: :created, location: @fotos_empresa }
els... | [
"def create\n \n @foto = Fotosresposta.new(params[:fotosresposta])\n\n respond_to do |format|\n if @foto.save\n format.html { redirect_to @foto, notice: 'Respostas Criadas com Sucesso.' }\n format.json { render json: @foto, status: :created, location: @foto}\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /fotos_empresas/1 PATCH/PUT /fotos_empresas/1.json | def update
respond_to do |format|
if @fotos_empresa.update(fotos_empresa_params)
format.html { redirect_to @fotos_empresa, notice: 'Fotos empresa was successfully updated.' }
format.json { render :show, status: :ok, location: @fotos_empresa }
else
format.html { render :edit }
... | [
"def update\n @foto = Fotosresposta.find(params[:id])\n\n respond_to do |format|\n if @foto.update_attributes(params[:fotosresposta])\n format.html { redirect_to @foto, notice: 'Respostas actualizadas com sucesso.' }\n format.json { head :no_content }\n else\n format.html { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /fotos_empresas/1 DELETE /fotos_empresas/1.json | def destroy
@fotos_empresa.destroy
respond_to do |format|
format.html { redirect_to fotos_empresas_url, notice: 'Fotos empresa was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @fotos_estab.destroy\n respond_to do |format|\n format.html { redirect_to fotos_estabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fotosresposta = Fotosresposta.find(params[:id])\n @fotosresposta.destroy\n\n respond_to do |format|\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is this an scp formatted uri? (Yes, always) | def scp?
true
end | [
"def scp?\n false\n end",
"def is_puppet_url(url)\n \t\turl =~ /^puppet:\\/\\//\n \tend",
"def absolute_url?(string); end",
"def validate_uri(uri)\n unless uri.is_a?(String)\n return false\n end\n\n unless uri.slice(GIT_REGEXP).nil?\n return true\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pagina_principals POST /pagina_principals.json | def create
@pagina_principal = PaginaPrincipal.new(pagina_principal_params)
respond_to do |format|
if @pagina_principal.save
format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully created.' }
format.json { render :show, status: :created, location: @pagina_... | [
"def valid_principals; end",
"def create\n @principio_ativo = PrincipioAtivo.new(params[:principio_ativo])\n\n respond_to do |format|\n if @principio_ativo.save\n format.html { redirect_to @principio_ativo, notice: 'Principio ativo was successfully created.' }\n format.json { render json:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pagina_principals/1 PATCH/PUT /pagina_principals/1.json | def update
respond_to do |format|
if @pagina_principal.update(pagina_principal_params)
format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully updated.' }
format.json { render :show, status: :ok, location: @pagina_principal }
else
format.html { ren... | [
"def update_principal(path, prop_patch)\n end",
"def update\n @principio_ativo = PrincipioAtivo.find(params[:id])\n\n respond_to do |format|\n if @principio_ativo.update_attributes(params[:principio_ativo])\n format.html { redirect_to @principio_ativo, notice: 'Principio ativo was success... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /pagina_principals/1 DELETE /pagina_principals/1.json | def destroy
@pagina_principal.destroy
respond_to do |format|
format.html { redirect_to pagina_principals_url, notice: 'Pagina principal was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @principio_ativo = PrincipioAtivo.find(params[:id])\n @principio_ativo.destroy\n\n respond_to do |format|\n format.html { redirect_to principio_ativos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :index, @user, :message => 'Not authorize... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
checks the album to see if there is a file with the same def has_same_photo?(album_id, f) | def has_same_photo?(fb_photos, f)
# album = Mogli::Album.find(album_id, client)
# fb_photos = album.photos
has_photo = false
fb_photos.each do |p|
break if has_photo
fb_photo_url = p.source
fb_photo_file = get_photo_as_file_from_url(fb_photo_url)
# Rails.logge... | [
"def photo_exist?(photo) \n\t### \n\t# compare sha of photo with the sha tag of EVERY photo that we've\n\t# already uploaded. \n\t# \thow do we do that? \n\t# \t\t \n\t# return true if that sha already exits as a tag. \n\t# return false if it dunna. \n\tsha = checksum_photo(photo) \n\t####\n\t# \t\nend",
"def has... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A group is not destroyed, it's disbanded! | def disband_group
destroy_collection({:table=>'groups', :on_success=>'You disbanded the group.'})
rescue
flash[:notice] = "Could not find group."
redirect_to :action=>'groups'
end | [
"def dissolve_groups\n groups.destroy_all\n end",
"def ungroup\n send_transport_message('BecomeCoordinatorOfStandaloneGroup')\n end",
"def delete_group(group)\n\t\t\tend",
"def remove_group!( group )\n save if remove_group( group )\n end",
"def remove_group\n create_group.tap do |r|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /room_plants GET /room_plants.json | def index
@room_plants = RoomPlant.all
end | [
"def index\n \n @plants = Plant.all\n @personal_plants = PersonalPlant.where(:user_id => session[:user][:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plants }\n end\n end",
"def show\n @people_by_room = PeopleByRoom.find(params[:id])\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /room_plants POST /room_plants.json | def create
@room_plant = RoomPlant.new(room_plant_params)
if @room_plant.save
render :show, status: :created, location: @room_plant
else
render json: @room_plant.errors, status: :unprocessable_entity
end
end | [
"def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end",
"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 => :unprocessabl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /room_plants/1 PATCH/PUT /room_plants/1.json | def update
if @room_plant.update(room_plant_params)
render :show, status: :ok, location: @room_plant
else
render json: @room_plant.errors, status: :unprocessable_entity
end
end | [
"def update\n @people_by_room = PeopleByRoom.find(params[:id])\n\n respond_to do |format|\n if @people_by_room.update_attributes(params[:people_by_room])\n format.html { redirect_to @people_by_room, notice: 'People by room was successfully updated.' }\n format.json { head :no_content }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /room_plants/1 DELETE /room_plants/1.json | def destroy
@room_plant.destroy
end | [
"def destroy\n @path_of_plant.destroy\n respond_to do |format|\n format.html { redirect_to path_of_plants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_roommate.destroy\n respond_to do |format|\n format.html { redirect_to admin_rooms_url }\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the active tasks | def active_tasks
request.method = :get
request.uri = '_active_tasks'
Couchdbtools.execute(request)
end | [
"def active_tasks\n @tasks.select { | task | task.active }\n end",
"def active_tasks\n @tasks.where( :active => true )\n end",
"def available_tasks\n return @db.filter {|task| task.user_id == @current_user_id}\n end",
"def tasks\n return @tasks\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the base url for this class. Note that it will not be inherited by subclasses. | def set_base_url(url)
base_url = url
end | [
"def base_url=(url)\n @base_url = url\n end",
"def base_url=(val)\n @base_url = val\n end",
"def base_url\n @base_url || self.class.base_url\n end",
"def with_base_url(base_url)\n @url_prefix = base_url\n self\n end",
"def base_url\n @base_url || DEFAULT_BASE_URL\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a new HTTP request and adds it to the +Config.hydra+ request queue. Registers a callback that invokes +handle_response+ when the request completes. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_tim... | def queue_request(url_or_path, options = {}, &block)
url = absolute_url(url_or_path)
headers = {:Accept => MEDIA_TYPE_JSON}.merge(options.fetch(:headers, {}))
headers = merge_log_weasel_header(headers)
timeout = options.fetch(:timeout, Ladon.default_request_timeout)
req... | [
"def do_request req, options={}\n Log.debug RequestLogSeperator\n Log.debug \"#{req.class} #{req.path}\"\n Log.debug \"HEADERS: #{req.to_hash}\"\n Log.debug \"BODY:\\n#{req.body}\" if req.request_body_permitted?\n\n if options.has_key? :timeout\n cur_timeout = @http.read_timeout\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends a synchronous DELETE request. On success, yields any returned data; on error, yields any provided default data or +nil+. Recognizes the following options: +headers+ a hash to add or update the request headers +timeout+ the timeout for the request (defaults to +Ladon.default_request_timeout+) +default_data+ passes... | def fire_delete(url_or_path, options = {}, &block)
params = options.fetch(:params, {})
params.merge!(mapped_params(options))
url = absolute_url(url_or_path, params: params)
headers = {:Accept => MEDIA_TYPE_JSON}.merge(options.fetch(:headers, {}))
headers = merge_log_we... | [
"def delete(path, params={}); make_request(:delete, host, port, path, params); end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def request_delete(path, headers = {})\n http = Net::HTTP.new(REST_ENDPOINT, @options[:ss... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a copy of +headers+ that includes a LogWeasel header if a LogWeasel transaction is in progress. | def merge_log_weasel_header(headers)
if LogWeasel::Transaction.id
headers.merge(LogWeasel::Middleware::KEY_HEADER => LogWeasel::Transaction.id)
else
headers
end
end | [
"def headers\n @headers ||= message.header_fields\n end",
"def headers(hash=nil)\n @headers = hash unless hash.nil?\n @headers ||= {}\n end",
"def headers(hash = nil || (return @headers))\n @headers.merge!(hash)\n end",
"def headers\n # units and source have to go last,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the URL created by appending +url_or_path+ to the server's base URL, unless +url_or_path+ is alrady absolute. | def absolute_url(url_or_path, options= {})
url = url_or_path =~ /^#{base_url}/ ? url_or_path : "#{base_url}#{url_or_path}"
params = options.fetch(:params, {})
query = params.inject([]) do |rv, param|
rv.concat((param[1].is_a?(Array) ? param[1] : [param[1]]).map {|v| "#{uri_esca... | [
"def base_url(operation = nil)\n index = server_operation_index.fetch(operation, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation, server_variables), operation_se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Encodes +entity_ as a JSON string. | def encode_entity(entity)
Yajl::Encoder.encode(entity)
end | [
"def serialize(entity)\n @coercer.to_record(entity)\n end",
"def _serialize(entity)\n @collection.serialize(entity)\n end",
"def serialize_item(entity)\n Hash[entity.map { |k, v| [k.to_s, format_attribute_value(v)] }]\n end",
"def json_encoder; end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts +entity+ from a JSON string to an object. | def parse_entity(entity)
entity = Yajl::Parser.parse(entity)
entity.is_a?(Hash) ? HashWithIndifferentAccess.new(entity) : entity
end | [
"def jsonapi_to_entity(response, data)\n return data unless data['type']\n\n data['type'].classify.constantize.make(self, data, response: response)\n rescue => error\n raise Oops(\n error: 'Cannot construct Entity from data',\n data: data,\n wrapped: error,\n )\n end",
"def from_json ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts options to a pager. If none of the below described options is provided, returns +nil+. | def pager(options)
pager = if options.include?(:pager)
options[:pager]
elsif options[:paged] || options[:pre_paged] || options[:page].present? || options[:per].present?
Ladon::Pager.new(options)
end
end | [
"def best_available\n if !_pry_.config.pager\n NullPager.new(_pry_.output)\n elsif !SystemPager.available? || Helpers::Platform.jruby?\n SimplePager.new(_pry_.output)\n else\n SystemPager.new(_pry_.output)\n end\n end",
"def best_available\n if !_pry_.config.pager\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns lowest sum of the winning and losing teams' scores | def lowest_total_score
total_game_scores = games.map { |game| game.home_goals + game.away_goals}
total_game_scores.min
end | [
"def winning_team\n brooklyn_players = team_player_info(\"Brooklyn Nets\")\n charlotte_players = team_player_info(\"Charlotte Hornets\")\n\n brooklyn_scores = brooklyn_players.map {|stats|\n stats[:points]}\n\n charlotte_scores = charlotte_players.map {|stats|\n stats[:points]}\n \n brooklyn_total = bro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns venue with most games played | def most_popular_venue
venues = @games.group_by { |game| game.venue}
venues.max_by { |venue, games| games.count }.first
end | [
"def order_games_by_venue\n most_popular_venue = Hash.new(0)\n sort_games_by_venue.each do |venue|\n most_popular_venue[venue] += 1\n end\n most_popular_venue\n end",
"def least_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.min_by { |venue, games| games.count }.fir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns venue with least games played | def least_popular_venue
venues = @games.group_by { |game| game.venue}
venues.min_by { |venue, games| games.count }.first
end | [
"def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end",
"def most_popular_venue\n venues = @games.group_by { |game| game.venue}\n venues.max_by { |venue, games| games.count }.first\n end",
"def lowest_total_sco... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns percentage of games a home team has won | def percentage_home_wins
home_wins = @teams.map { |team| team.home_wins }.sum
home_games = @teams.map { |team| team.home_games }.sum
(home_wins.to_f / home_games.to_f).round(2)
end | [
"def percentage_home_wins\n home_wins = 0\n self.games.each_value do |object|\n if object.home_goals > object.away_goals\n home_wins += 1\n end\n end\n\n (home_wins / (self.games.length).to_f).round(2)\n end",
"def games_win_percentage(team_id, games)\n total = games.count\n wo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns percentage of games an away team has won | def percentage_visitor_wins
visitor_wins = @teams.map { |team| team.away_wins }.sum
visitor_games = @teams.map { |team| team.away_games }.sum
(visitor_wins.to_f / visitor_games.to_f).round(2)
end | [
"def games_win_percentage(team_id, games)\n total = games.count\n won = 0\n games.each do |game|\n if (team_id == game.away_team_id) && game.outcome.match?(/away win/)\n won += 1\n elsif (team_id == game.home_team_id) && game.outcome.match?(/home win/)\n won += 1\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns season with most games played | def season_with_most_games
seasons = @games.group_by { |game| game.season }
seasons.max_by { |season, games| games.count }.first
end | [
"def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end",
"def last_season\n seasons.max_by { |s| s.index.to_i }\n end",
"def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns season with fewest games played | def season_with_fewest_games
seasons = @games.group_by { |game| game.season }
seasons.min_by { |season, games| games.count }.first
end | [
"def season_with_most_games\n seasons = @games.group_by { |game| game.season }\n seasons.max_by { |season, games| games.count }.first\n end",
"def seasons\n costume_assignments.group(:dance_season).count\n end",
"def count_of_games_by_season\n games_by_season = @games.group_by { |game| game.season... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a hash with season names as keys and counts of games as values | def count_of_games_by_season
games_by_season = @games.group_by { |game| game.season.to_s }
games_by_season.each { |season, games| games_by_season[season] = games.count }
end | [
"def count_of_games_by_season\n output = Hash.new(0)\n\n self.games.each_value do |game|\n output[game.season] += 1\n end\n\n output\n end",
"def seasons\n costume_assignments.group(:dance_season).count\n end",
"def count_seasons(date)\n (date.year-2010)*2 + date.two_season - 1\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns average number of goals scored in a game across all seasons | def average_goals_per_game
total_goals = @teams.map {|team| team.total_goals_scored}.sum
total_games = @teams.map {|team| team.home_games}.sum
(total_goals.to_f / total_games.to_f).round(2)
end | [
"def average_goals_by_season\n goals_by_season = @games.group_by { |game| game.season.to_s }\n goals_by_season.each do |season, games|\n season_goals = games.map { |game| game.home_goals + game.away_goals }.sum\n goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a hash with season names as keys and average goals that season as a value | def average_goals_by_season
goals_by_season = @games.group_by { |game| game.season.to_s }
goals_by_season.each do |season, games|
season_goals = games.map { |game| game.home_goals + game.away_goals }.sum
goals_by_season[season] = (season_goals.to_f / games.count.to_f).round(2)
end
end | [
"def average_goals_by_season\n seasons_goals = Hash.new(0.00)\n\n unique_seasons_array_helper.each do |season|\n self.games.each_value do |game|\n seasons_goals[season] += (game.home_goals + game.away_goals) if game.season == season\n end\n end\n\n seasons_goals.merge!(count_of_games_by... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns total number of teams | def count_of_teams
@teams.count
end | [
"def team_count\n @teams.length\n end",
"def num_total_teams_possible\n count = 0\n self.owned_participant_registrations.each do |pr|\n count = count + pr.num_novice_local_teams\n count = count + pr.num_experienced_local_teams\n count = count + pr.num_novice_district_teams\n count = ... | {
"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.