query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
DELETE /admin/kpi_templates/1 DELETE /admin/kpi_templates/1.json
def destroy @admin_kpi_template = Admin::KpiTemplate.find(params[:id]) @admin_kpi_template.destroy respond_to do |format| format.html { redirect_to admin_kpi_templates_url } format.json { head :no_content } end end
[ "def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end", "def destroy\n @admin_kpi_category_template = Admin::KpiCategoryTemplate.find(params[:id])\n @admin_kpi_category_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_kpi_categor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /inventory_plans GET /inventory_plans.json
def index @inventory_plans = InventoryPlan.all end
[ "def plans(params = {})\n scope 'default'\n get('plans/', params)\n end", "def plans\n @api.get_plans( :project_id => @id )\n end", "def index\n @plans = Plan.all\n \n render json: @plans\n end", "def index\n @plans = Plan.all\n\n render json: @plans\n end", "def plan\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /inventory_plans POST /inventory_plans.json
def create @inventory_plan = InventoryPlan.new(inventory_plan_params) respond_to do |format| if @inventory_plan.save format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully created.' } format.json { render :show, status: :created, location: @inventory_plan } ...
[ "def create_plan(options = {})\n build_response(make_request(:post, url: 'plans', options: options))\n end", "def create(options = nil)\n request = Request.new(@client)\n path = \"/plans\"\n data = {\n \"id\"=> @id, \n \"name\"=> @name, \n \"amount\"=> @amount, \n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /inventory_plans/1 PATCH/PUT /inventory_plans/1.json
def update respond_to do |format| if @inventory_plan.update(inventory_plan_params) format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully updated.' } format.json { render :show, status: :ok, location: @inventory_plan } else format.html { render :edit ...
[ "def update\n @plan = @store.plans.find(params[:id])\n flash[:error] = \"Cannot edit that plan.\" and redirect_to store_plans_path if @plan.is_readonly\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to store_plan_path(@plan), notice: 'Plan was su...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /answer_respondents GET /answer_respondents.json
def index @answer_respondents = AnswerRespondent.all end
[ "def index\n @reply_answers = ReplyAnswer.all\n end", "def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n redirect_user\n @respondents = Respondent.all\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /answer_respondents POST /answer_respondents.json
def create @answer_respondent = AnswerRespondent.new(answer_respondent_params) respond_to do |format| if @answer_respondent.save format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully created.' } format.json { render :show, status: :created, location: @a...
[ "def index\n @answer_respondents = AnswerRespondent.all\n end", "def answer_questions\n @project = Project.find(params[:id])\n @question_responses = []\n params[:question_responses].each do |question_id, response|\n @question_responses << QuestionResponse.create!(:question_id => question_id.to_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /answer_respondents/1 PATCH/PUT /answer_respondents/1.json
def update respond_to do |format| if @answer_respondent.update(answer_respondent_params) format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully updated.' } format.json { render :show, status: :ok, location: @answer_respondent } else format.html ...
[ "def update\n @answer = current_user.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.json { head :no_content }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /answer_respondents/1 DELETE /answer_respondents/1.json
def destroy @answer_respondent.destroy respond_to do |format| format.html { redirect_to answer_respondents_url, notice: 'Answer respondent was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end", "def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set default values if nothing has input for max and backup student
def default_values self.max_student ||= 0 self.backup_student ||= 0 end
[ "def default_values\n self.pmu_type ||= \"uncommitted\"\n self.completed ||= false\n self.max_people ||= 1\n end", "def set_default_values\n self.base_exp ||= 0\n self.time_bonus_exp ||= 0\n end", "def default_values\n \tself.total_worth ||= 0\n \tend", "def set_creation_defaults\n if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
show how many seats available, show full if left 0
def seats_available available = total_student - UserEvent.joined_students_count(self.id) if available > 0 available else "FULL" end end
[ "def remaining_seats(showing)\n booked = 0\n Booking.where(showing_id: showing.id).each do |booking|\n booked += booking.no_of_people\n end\n remaining = showing.capacity - booked\n return remaining > 0 ? \"Available Seats - #{remaining}\" : \"SOLD OUT!\"\n end", "def seats_left\n avai...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determine if an event is expired
def is_expired? self.event_date < DateTime.now end
[ "def is_expired?\n (!end_time.nil? and end_time < Clock.time)\n end", "def expired?\n false\n end", "def expired?\n Time.now > valid_until\n end", "def expired?\n self.expiration.past? || self[:expired]\n end", "def expired?\n expiration_timestamp && (Time.now > expiration_timestamp)\nen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
validate end time cannot be earlier than start time
def end_time_cannot_be_earlier_than_start_time if end_time && start_time if end_time < start_time errors.add(:end_time, "End time should not be earlier than start time.") end end end
[ "def check_times\n if start_time >= end_time\n errors.add(:end_time, \"must be after Start time\")\n end \n end", "def start_time_must_be_before_end_time\n errors.add(:start_time, \"start time cannot be after end time\") if (start_time > end_time)\n end", "def end_time_after_start_time\n if start...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /prod_cotis GET /prod_cotis.json
def index @prod_cotis = ProdCoti.all end
[ "def index\n @cotas = Cota.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cotas }\n end\n end", "def index\n @costa_tropicals = CostaTropical.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /prod_cotis POST /prod_cotis.json
def create @prod_coti = ProdCoti.new(prod_coti_params) respond_to do |format| if @prod_coti.save format.html { redirect_to @prod_coti, notice: 'Prod coti was successfully created.' } format.json { render :show, status: :created, location: @prod_coti } else format.html { rend...
[ "def create\n @cotizclomul = Cotizclomul.new(cotizclomul_params)\n @cotizclomul.confirmacion = 'Por confirmar'\n\n numerocaracteresclave = 20\n caracteresclavecompra = %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /prod_cotis/1 PATCH/PUT /prod_cotis/1.json
def update respond_to do |format| if @prod_coti.update(prod_coti_params) format.html { redirect_to @prod_coti, notice: 'Prod coti was successfully updated.' } format.json { render :show, status: :ok, location: @prod_coti } else format.html { render :edit } format.json { r...
[ "def update\n respond_to do |format|\n if @cotizclomul.update(cotizclomul_params)\n format.html { redirect_to @cotizclomul, notice: 'Cotizclomul was successfully updated.' }\n format.json { render :show, status: :ok, location: @cotizclomul }\n else\n format.html { render :edit }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /prod_cotis/1 DELETE /prod_cotis/1.json
def destroy @prod_coti.destroy respond_to do |format| format.html { redirect_to prod_cotis_url, notice: 'Prod coti was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @prod_cli.destroy\n respond_to do |format|\n format.html { redirect_to prod_clis_url, notice: 'produto excluido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
progress goal see for testing if an internal or external goal
def is_internal? return (self.goal_type % 2) == 1 end
[ "def goal_test(state)\n return state == @goal\n end", "def account_setup?\n self.setup?(:goal)\n end", "def is_valid_for_execution\n (@metadata[\"short_dest_repo_name\"] == \"osrf/gazebo\" and @pr_status == :update) ? false : true\n end", "def test_continue_truthy\n turns_remaining_miner = Pros...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
sets goal to ABANDONED and calls remove on children
def remove_act # outdent children in case remove_act doesn't delete self.children.each do |child| if child.type != 'GoalTracker' child.outdent child.remove_act end end # check if parent should update completeness old_parent = self.parent self.state = Activity::A...
[ "def remove_finished_children\n # We call #to_a to get a copy of children, since we will remove\n # children in the block. Note that we can't use #delete_if here\n # since #children is a relation enumerator (not the relation list\n # itself...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add CD object to the array variable, $cd_arr
def add_cd(a_cd) $cd_arr << a_cd end
[ "def addCD(aCD)\n $cd_arr << aCD\nend", "def addCD( aCD )\n $cd_arr << aCD\nend", "def add obj\n\t\t\t@objs2 += [obj] \n\t\tend", "def add_carray name: ,c_name: ,dimension: ,type: ,value: nil\n type = Rubex::DataType::CArray.new dimension, type\n entry = Rubex::SymbolTable::Entry.new name, c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
prints data from the array to screen in human readable yaml format
def show_data puts $cd_arr.to_yaml end
[ "def showData\n puts( $cd_arr.to_yaml )\nend", "def showData\n puts($cd_arr.to_yaml)\nend", "def display_yaml( obj )\n puts YAML::dump(obj)\n end", "def print\n hash(@yaml)\n end", "def to_yaml() end", "def display object\n # stringify symbols in YAML output for better readability\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wraps a block catching errors and logging / replying to the source, when they happen before reraising them
def wrapping_errors(response=nil, &block) begin yield if block_given? rescue StandardError => e "Oh noes, #{e.message}".tap do |message| log.error message response.reply message if response end e.backtrace.each { |t| e.debug...
[ "def handle_errors(&block)\n block.call\n rescue Exception => e\n handle_error(e,true)\n end", "def _catch_warden(&block); end", "def transform_error(&block)\n errback do |*err|\n self.fail(\n begin\n yield(*err)\n rescue => e\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetches info about a single user
def fetch_user(id) client.user(id) end
[ "def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end", "def fetch_user\n @user = User.find(params[:user_id])\n end", "def get_user_info\n request :get_user_info\n end", "def show_user()\n path = sprintf(\"/api/v2/user\")\n data_hash = {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Consumes an input array and returns a balanced binary tree.
def build_tree(input_array) sorted_set = input_array.sort.uniq build_tree_aux(sorted_set, 0, sorted_set.length - 1) end
[ "def array_to_binary(arr)\n node = Node.new(arr[0])\n arr.slice(1..-1).each {|el| insert_into_tree(node, el) }\n node\nend", "def build_tree(array)\n #Assign first value (at 0 index) as root node, shift removes the first element, so array is shorten by 1\n @root = Node.new(array.shift) if @root.nil?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /barks or /barks.json
def create @bark = current_user.barks.build(bark_params) respond_to do |format| if @bark.save format.html { redirect_to root_path, notice: "Bark was successfully created." } format.json { render :show, status: :created, location: @bark } else format.html { render :new, statu...
[ "def create\n @barrack = Barrack.new(params[:barrack])\n\n respond_to do |format|\n if @barrack.save\n format.html { redirect_to @barrack, notice: 'Barrack was successfully created.' }\n format.json { render json: @barrack, status: :created, location: @barrack }\n else\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /barks/1 or /barks/1.json
def update respond_to do |format| if @bark.update(bark_params) format.html { redirect_to @bark, notice: "Bark was successfully updated." } format.json { render :show, status: :ok, location: @bark } else format.html { render :edit, status: :unprocessable_entity } format.js...
[ "def update\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n if @barrack.update_attributes(params[:barrack])\n format.html { redirect_to @barrack, notice: 'Barrack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
takes a string preposistion and turns it into a 2d array ands of ors with id numbers + depending on negation
def string_to_internal(preposition) temp_kb =Array.new #string input of format literal_name LOGICAL_PREPOSISTION preposition_array = preposition.split next_negated = false sentence = [] preposition_array.each do |word| #####################################3 # puts " word: " + word #don't need to ...
[ "def ships_from_string(str)\n arr = []\n\n str.chars.each do |ch|\n arr << 1 if ch == CHAR_SHIP\n arr << 0 if ch == CHAR_EMPTYSPACE\n end\n\n arr\n end", "def contain_all_rots(strng, arr)\n array = strng.chars\n number = 0\n result = []\n (array.size - 1).times do \n array....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
turns the propositions to CNF(if needed)
def toCNF end
[ "def convertToCNF theParsedPuzzle\nend", "def propositional_symbols\n symbols = []\n @classified.each do |el|\n symbols.push el if el.instance_of? Proposition\n end\n symbols\n end", "def to_peg\n new_rules = []\n\n # Look for rules containing sub-sequences\n if expr.any? {|e| e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the way this is designed, it short circuts. so sometimes when it should say false it will say indeterminant for the whole knowledgebase returns false, true, or indetermninant as 1,1,0 (in current encoding) alike with the assignment list and literal class assignment must be parallel array to id nums (may want to use has...
def satisfiable_assignment?(assignment) sentence_eval = 1 index = 0 while(sentence_eval == 1 && index < @kb.size) sentence_eval = 0 all_false = true ##############################################3 # puts "kb is: " + @kb.to_s # puts "the assignments are : " + assignment.to_s @kb[index].each do |id|...
[ "def assignment\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n\n __ID11__ = nil\n __EQUAL12__ = nil\n\n\n begin\n # at line 88:13: ID ( dim_obj )? ( EQUAL ( mega_expression | input ) ) SEMI\n __ID11__ = match( ID, TOKENS_FOLLOWING_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a function with two arguments that will return a list of length (n) with multiples of (x). Assume both the given number and the number of times to count will be positive numbers greater than 0. Return the results as an array (or list in Python or Haskell.) Examples: count_by(1,10) should return [1,2,3,4,5,6,7,8,...
def count_by(x, n) a=[] y=0 n.times {y+=x; a<<y} a end
[ "def counts(n)\n divisors = Array.new\n (1..n).each do |n|\n single_divisors = count n\n divisors.push(single_divisors)\n end\n divisors\n end", "def amicableNumbersUnder n\n\t\th = Array.new\n\t\t1.upto(n) do |x|\n\t\t\ty = sum(properDivisors(x))\n\t\t\th.push x if x != y && x == sum(prope...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tipocuenta GET /tipocuenta.json
def index @tipocuenta = Tipocuentum.all end
[ "def show\n @tipocliente = Tipocliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @tipocliente }\n end\n end", "def show\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls mattermost using the default Mattermost URL from the configuration data is a hash containing the data to send. Note that channel, username, and icon_url are reserved url is the Mattermost URL defined above. This can be overridden for debugging header is the default headers. This shouldn't need modified, but it's ...
def call_mattermost (data = {}, url = [Config['Mattermost']['url'], 'hooks', Config['Mattermost']['webhook_code']].join('/'), header = {content_type: :json, accept: :json}) if !data.has_key?(:login_id) payload = data.merge(Config['DefaultPayload']) else payload = data end # Just in case, though we may not need...
[ "def push_data(push_params)\n # Push URI\n push_uri = URI.parse(\"#{$tipboard_base_uri}/#{$apikey}/push\")\n\n # Post to API to set up tile\n push_response = Net::HTTP.post_form(push_uri, push_params)\nend", "def send_message(mes,token,user_id)\n #Open a direct message\n options = {\n token: toke...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
upload_file moves the file to the webserver from the config file filename: The full path of the image file video_filename: Used to generate a unique MD5 hash for each image file
def upload_file (filename, video_filename) # new filename is the md5 of the old filename, plus "jpg" new_filename = Digest::MD5.hexdigest video_filename new_filename += '.jpg' FileUtils.mv(filename, [Config['WebServer']['webroot'], Config['WebServer']['preview_dir'], new_filename].join('/')) return [Config['WebS...
[ "def upload_file\n\tproject = self.use_case.project\n\n\tfile = url_path.read\n whole_name = url_path.original_filename\n final_name = self.name + \".v1.0\" + File.extname(whole_name)\n file_path = project.name + \"/UseCases/\" + self.name + \"/\" + final_name\n dbsession = DropboxSession.deserialize(pr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates previews for each movie file in the transcode directory filename: The full path of the video file to output options: allows you to pass the following values for configuration. If not set they'll be pulled from your config framegrab_grid: (string) Something like '5x6' or '2x4' to specify the size of the grid f...
def generate_previews(filename, options = {}) framegrab_grid = options['framegrab_grid'] || Config['PreviewSettings']['default_grid'] framegrab_interval = options['framegrab_interval'] || Config['PreviewSettings']['default_interval'] framegrab_height = options['framegrab_height'] || Config['PreviewSettings']['defaul...
[ "def generate_compilation\n puts \"Generating compilation\"\n get_selected_vines\n pathArray = [];\n @selected_vines.each do |vid|\n vine = Vine.find(vid)\n pathArray.push vine.path\n end\n if pathArray.count > 0\n return outputFile = execut...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs the command defined in the config file input_filename: The full path of the file you want to run the command on file_operation: One of the defined file operations in the config file
def run_command(input_filename, file_operation) Log.info "Inside run_command" if !Config['FileOperations'].key?(file_operation) return "#{file_operation} isn't a valid preset" end transcode_settings = Config['FileOperations'][file_operation] Log.info transcode_settings.to_s begin if !transcode_settings.key...
[ "def execute!\n from_file(filename)\n end", "def execute_file(file_name)\r\n puts \"Loading file #{file_name}...\"\r\n execute(Parser.new(StringSource.new(IO.readlines(file_name))))\r\n end", "def execute_each_fileline \n output = parse_input_command\n create_output_file output\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The position of the data dictionary header within the page.
def pos_data_dictionary_header pos_page_body end
[ "def pos_header\n @position - 2\n end", "def pos_header\n @position - 2\n end", "def header_position\n C.archive_read_header_position archive\n end", "def pe_header_offset\n deref(e_lfanew_offset)\n end", "def data_chunk_start_pos\n read_page_header_and_data_chunk_start un...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The size of the data dictionary header.
def size_data_dictionary_header ((8 * 3) + (4 * 7) + 4 + Innodb::FsegEntry::SIZE) end
[ "def size_data_dictionary_header\n ((8 * 3) + (4 * 7) + 4 + Innodb::FsegEntry::SIZE)\n end", "def header_size\n TYPE_SIZE\n end", "def header_length\n @header_length ||= @data[20, 4].unpack('N*')[0]\n end", "def byte_size(); @data.byte_size + 4; end", "def size_fil_header\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /krishes GET /krishes.json
def index @krishes = Krish.all end
[ "def index\n @kushis = Kushi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kushis }\n end\n end", "def show\n @kushi = Kushi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ku...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /krishes POST /krishes.json
def create @krish = Krish.new(krish_params) respond_to do |format| if @krish.save format.html { redirect_to @krish, notice: 'Krish was successfully created.' } format.json { render action: 'show', status: :created, location: @krish } else format.html { render action: 'new' }...
[ "def create\n @shed = Shed.new(shed_params)\n\n if @shed.save\n render json: @shed, status: :created, location: @shed\n else\n render json: @shed.errors, status: :unprocessable_entity\n end\n end", "def create\n @knjige = Knjige.new(knjige_params)\n\n respond_to do |format|\n if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /krishes/1 DELETE /krishes/1.json
def destroy @krish.destroy respond_to do |format| format.html { redirect_to krishes_url } format.json { head :no_content } end end
[ "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @kushi = Kushi.find(params[:id])\n @kushi.destroy\n\n respond_to do |format|\n format.html { redirect_to kushis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @koszyk = Koszyk.find(pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Toggle guest access on or off
def toggle_guest_access raise NotImplementedError end
[ "def toggle_guest_access\n # re-join the room to get the guest url\n verify_response(post(\"room/#{id}/toggle_guest_access\"), :success) && join(true)\n end", "def toggle_admin\n if @user.is_admin?\n @user.revoke_admin\n else\n @user.grant_admin(current_user, session[:pwd])\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the url for guest access
def guest_url if guest_access_enabled? "http://#{@campfire.subdomain}.campfirenow.com/#{guest_invite_code}" else nil end end
[ "def guest_url\n \"#{@connection.uri}/#{guest_invite_code}\" if guest_access_enabled?\n end", "def guest_url\n join\n link = (Hpricot(@room.body)/\"#guest_access h4\").first\n link.inner_html if link\n end", "def guest_link\n return guest_hearing_link if guest_hearing_link.present?\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The invite code use for guest
def guest_invite_code load @active_token_value end
[ "def guest_invite_code\n join\n guest_url.scan(/\\/(\\w*)$/).to_s\n end", "def generate_invite_code\n self.invite_code = SecureRandom.hex(3)\n end", "def generate_invite_code\n self.invite_code = generate_token\n end", "def use_invitation_code(icode)\n self.email = icode.invitation.em...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Change the name of the room
def name=(name) connection.post("/room/#{@id}.json", :body => { :room => { :name => name } }) end
[ "def room_name=(value)\n @room_name = value\n end", "def set_name(new_name)\n @name = new_name\n @@all_rooms[@id] = self\n end", "def set_room_name(room_id, name, **params)\n content = {\n name: name\n }\n send_state_event(room_id, 'm.room.name', content, **params)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tuberculoses GET /tuberculoses.json
def index @tuberculoses = Tuberculose.all end
[ "def index\n @tenures = Tenure.all\n render json: @tenures\n end", "def index\n @otakus = Otaku.all\n\n render json: @otakus\n end", "def index\n @user_tickets = list_tickets\n #render json: {tic: @user_tickets}\n end", "def index\n @tipees = Tipee.all\n json_response(@tipees)\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /pharmas GET /pharmas.json
def index @pharmas = Pharma.all end
[ "def show\n @phono = Phono.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phono }\n end\n end", "def show\n @phlog = Phlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /pharmas POST /pharmas.json
def create @pharma = Pharma.new(pharma_params) respond_to do |format| if @pharma.save format.html { redirect_to @pharma, notice: 'Pharma was successfully created.' } format.json { render :show, status: :created, location: @pharma } else format.html { render :new } fo...
[ "def create\n @pharm = Pharm.new(pharm_params)\n @pharm.user_id = current_user.id\n\n respond_to do |format|\n if @pharm.save\n format.html { redirect_to @pharm, notice: 'Pharm was successfully created.' }\n format.json { render :show, status: :created, location: @pharm }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /pharmas/1 PATCH/PUT /pharmas/1.json
def update respond_to do |format| if @pharma.update(pharma_params) format.html { redirect_to @pharma, notice: 'Pharma was successfully updated.' } format.json { render :show, status: :ok, location: @pharma } else format.html { render :edit } format.json { render json: @ph...
[ "def update\n @pharm = Pharm.find(params[:id])\n respond_to do |format|\n if @pharm.update(pharm_params)\n format.html { redirect_to @pharm, notice: 'Pharm was successfully updated.' }\n format.json { render :show, status: :ok, location: @pharm }\n else\n format.html { render :e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /message_outs GET /message_outs.json
def index @message_outs = MessageOut.all end
[ "def index\n @outmessages = Outmessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @outmessages }\n end\n end", "def receive\n @outbox_smses = []\n params[:destination_numbers].each do |dest_num|\n @outbox_smses << Outbox.creat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /message_outs POST /message_outs.json
def create @message_out = MessageOut.new(message_out_params) respond_to do |format| if @message_out.save format.html { redirect_to @message_out, notice: 'Message out was successfully created.' } format.json { render :show, status: :created, location: @message_out } else form...
[ "def receive\n @outbox_smses = []\n params[:destination_numbers].each do |dest_num|\n @outbox_smses << Outbox.create(:TextDecoded => params[:text_decoded], \n :DestinationNumber => dest_num, \n :SendingTimeOut => Time.now -...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /message_outs/1 PATCH/PUT /message_outs/1.json
def update respond_to do |format| if @message_out.update(message_out_params) format.html { redirect_to @message_out, notice: 'Message out was successfully updated.' } format.json { render :show, status: :ok, location: @message_out } else format.html { render :edit } forma...
[ "def update\n @outmessage = Outmessage.find(params[:id])\n\n respond_to do |format|\n if @outmessage.update_attributes(params[:outmessage])\n format.html { redirect_to @outmessage, :notice => 'Outmessage was successfully updated.' }\n format.json { head :ok }\n else\n format.htm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /message_outs/1 DELETE /message_outs/1.json
def destroy @message_out.destroy respond_to do |format| format.html { redirect_to message_outs_url, notice: 'Message out was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @outmessage = Outmessage.find(params[:id])\n @outmessage.destroy\n\n respond_to do |format|\n format.html { redirect_to outmessages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @outgoing_message_log = OutgoingMessageLog.find(params[:id])\n @outgoing_mes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /submission/1 GET /submission/1.xml
def show @submission = Submission.find(params[:id]) respond_to do |format| format.html # show.haml format.xml { render :xml => @submission } end end
[ "def show\n @submission = Submission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @submission }\n end\n end", "def show\n challenge = Challenge.find(params[:challenge_id])\n @submission = challenge.submissions.find(params[:id])...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /submission/new GET /submission/new.xml
def new @submission = Submission.new respond_to do |format| format.html # new.haml format.xml { render :xml => @submission } end end
[ "def new\n @submission = Submission.new params[:submission]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end", "def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.html.erb\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /submission POST /submission.xml
def create @submission = Submission.new(params[:submission]) respond_to do |format| if @submission.save flash[:notice] = 'Submission was successfully created.' format.html { redirect_to(submission_path(@submission)) } format.xml { render :xml => @submission, :status => :created, ...
[ "def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /submission/1 DELETE /submission/1.xml
def destroy @submission = Submission.find(params[:id]) @submission.destroy respond_to do |format| format.html { redirect_to(submission_url) } format.xml { head :ok } end end
[ "def destroy\n @submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(submissions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @submission = Submission.find(params[:id])\n @submission.destroy\n\n respond_to do |format|\n format.html { redirec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The +MessageOptions+ defined for this message.
def options message_descriptor_proto.options end
[ "def default_message_options\n @default_message_options ||= {type: 'message'}\n end", "def text_message_options\n # Get menu options\n menu_options = self.menu_options.where(:type => \"MenuOption\").all.order_by([:name, :desc])\n options = {}\n options[\"#0\"] = [\"menu\",\"\"]\n \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The extension ranges defined for this message
def extension_range message_descriptor_proto.extension_range end
[ "def extensions(range)\n extension_ranges << range\n end", "def ranges\n @ranges\n end", "def range_extensions\n @range_extensions ||= \n class << self.range\n self.included_modules - [Kernel]\n end\n end", "def ranges\n return @r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns a Reputation::Threshold instance and validates based on self action and sender
def threshold @threshold ||= Reputation::Threshold.lookup(self.action, self.sender, :tier => self.tier) end
[ "def reputation_threshold_action\n raise \"Reputation threshold needs to be defined in reputation_threshold_action method\"\n end", "def find_reputation_threshold_action_points(action)\n if tp = self.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s])\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
is this action defined as a reputation action
def action_defined? # ReputationThreshold.action_defined?(self.action, self.tier) !self.action_points.nil? end
[ "def reputation_threshold_action\n raise \"Reputation threshold needs to be defined in reputation_threshold_action method\"\n end", "def current_user_requires_reputation_threshold?\n true\n end", "def find_reputation_threshold_action_points(action)\n if tp = self.reputation_thresholds.find(:first, \n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the threshold points that are defined for certain action either in database or globally
def action_points @threshold_action_points_cache ||= ReputationThreshold.action_points(self.action, self.tier) end
[ "def find_reputation_threshold_action_points(action)\n if tp = self.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s])\n tp\n elsif self.parent && (ptp = self.parent.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
is a sender assigned?
def sender? !!self.sender end
[ "def sender? usr\r\n usr.id == user_id\r\n end", "def sender? usr\n usr.id == user_id\n end", "def was_sent_by?(actor)\n (self.sender.class == actor.class) && (self.sender.id == actor.id)\n end", "def sender?(message)\n if message.sender == id\n true\n else\n false\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
produces an html href to the faq pages
def link_to_faq(text, options={}) html = "<a" html += " class=\"#{options[:class]}\"" if options[:class] html += " href=\"/faq\"" html += ">" html += text html += "</a>" html end
[ "def link_to(questionnaire)\n \"<a href='/print/%s'>%s</a>\" % ([questionnaire['_id']] * 2)\n end", "def link_to_faq(title_or_faq, *args)\n if title_or_faq.is_a?(Faq)\n faq = title_or_faq\n title = faq.question\n else\n faq = args.delete(0)\n title = t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Defines a singleton_method in the receiver. The method parameter can be a Proc or Method object. If a block is specified, it is used as the method body. This block is evaluated using instance_eval.
def define_singleton_method(symbol, method) # TODO end
[ "def redefine_singleton_method(method, &block); end", "def create_method(name, &block)\n singleton_class.send(:define_method, name, &block)\n end", "def binop_define_singleton_method(name, op, receiver)\n [:method_add_block,\n [:command_call,\n [:var_ref, [:@ident, receiver.to_s]],\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Edit a particular Address in the database
def edit_address(edited_address) address = Address.find(edited_address.uid) address.attributes = edited_address.attributes address.save! end
[ "def edit\r\n @address = Address.find(params[:id])\r\n end", "def edit\n\t\t@address = current_user.addresses.find(params[:id])\n\tend", "def edit\n\t@address=Address.new\n\t@address=Address.find(params[:id])\nend", "def update\n @address = @addressable.addresses.find_by_id(params[:id])\n\n respond_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a particular Address from the database
def delete_address(address) address.delete! end
[ "def delete\n @address = Address.find(params[:address_id])\n end", "def delete_address(id)\n delete(\"addresses/#{id}\")\n end", "def delete\n self.class.delete_address_by_id(self.id)\n end", "def delete_address(application_id, address_id)\n address_to_delete = address(application_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Cleanse Address through third party service using SOA pattern (psuedocode)
def cleanse_address(address) cleansed_address = SOAAddressCleanser.cleanse_address(address) cleansed_address.save! end
[ "def normalize_address address\n funcs = [\n :remove_whitespaces,\n :full_to_half,\n :kansuuji,\n :separator,\n :remove_ignore_symbol,\n :remove_parenthesis,\n :remove_japan_prefix,\n :remove_zip_code,\n :remove_choume,\n :normalize_floor,\n :remove_building...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Validate zipcode through third party service using SOA pattern (psuedocode)
def validate_zip(address) return SOAZipValidator(address.city, address.zipcode) end
[ "def zipvalidate(postcode)\n !!postcode.match(/\\A[1-46][\\d]{5}\\z/)\nend", "def zip_code\n @zip_code || (@address_line3 if @address_line3 =~ /(?i)^[a-z0-9][a-z0-9\\- ]{0,10}[a-z0-9]$/)\n end", "def validation_of_zip_code(code)\n\n # check type\n for str in code.chars\n if !/\\A\\d+\\z/.match...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Nathan Tests def run_tests root = BinaryTreeNode.new(50) left = root.insert_left(30) right = root.insert_right(80) left_left = left.insert_left(20) left_right = left.insert_right(40) right_left = right.insert_left(70) right_right = right.insert_right(90) assert_true(root) root = BinaryTreeNode.new(50) left = root.inser...
def run_tests desc = 'valid full tree' tree = BinaryTreeNode.new(50) left = tree.insert_left(30) right = tree.insert_right(70) left.insert_left(10) left.insert_right(40) right.insert_left(60) right.insert_right(80) result = binary_search_tree?(tree) assert_true(result, desc) desc = 'both subtrees...
[ "def test_it_can_have_nodes_inserted\n # tree = create_binary_search_tree(4)\n tree = Bst.new(10)\n tree.insert(11)\n tree.insert(5)\n binding.pry\n \n \n assert_instance_of Node, tree.root_node\n end", "def test_make_root_node\n tree = BinarySearchTre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Delete customer from db
def delete() sql = "DELETE from customers WHERE id = $1" values = [@id] SqlRunner.run(sql, values) # => Deleting customer record, nothing to return end
[ "def delete_a_customer\n @customer.delete\n end", "def delete\n appctrl_delete( 'Customer' )\n end", "def delete_customer\n Stripe::Customer.delete(\n @user,\n )\n end", "def delete_customer(options = {})\n requires! options, :customer_number\n\n request = bui...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=> Display all the films a particular customer has bought ticket for
def films() sql = "SELECT films.* FROM films INNER JOIN tickets ON tickets.film_id = films.id WHERE customer_id = $1" values = [@id] film_data = SqlRunner.run(sql, values) return Film.map_items(film_data) end
[ "def films_for_customer()\n sql = \"SELECT films.* FROM films\n INNER JOIN tickets ON films.id = tickets.film_id\n WHERE customer_id = $1\"\n values = [@id]\n film_data = SqlRunner.run(sql, values)\n return Film.map_items(film_data)\n end", "def customers_for_film()\n sql = \"SELECT name FRO...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given an account type, set the account_params_key.
def account_params_key @account_params_key ||= Account.config.account_type_to_param(account_type) end
[ "def register_account_type_params\n if params[:account][:account_type]\n params.require(:account).require(:account_type).permit(AccountType.attribute_list)\n else\n {}\n end\n end", "def set_account_type\n @account_type = account.class.to_s\n end", "def account_type_to_param(account_type...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Applies strong_param rules to the passed in params based on the current `action`. Assumes params are guarenteed to be an instantiated `ActionController::Parameters` object. Silently returns an empty params hash if the `account_params_key` is missing.
def account_params return ActionController::Parameters.new unless params.key?(account_params_key) permitted = send("account_params_for_#{action}") params.require(account_params_key).permit(*permitted) end
[ "def strong_params(*args)\n #byebug\n params.require(controller_name.singularize.to_sym).permit(*args)\n end", "def app_safe_params\n return safe_params if self.respond_to?(:safe_params)\n\n params.permit\n end", "def ensure_redirected_params_are_safe!(passed_params)\n unl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simply assigns the strong_params to the account new/persisted account object.
def assign_params account.assign_attributes(account_params) account end
[ "def assign_account(account_id)\n self.account_id = account_id\n end", "def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end", "def account_params\n return ActionController::Parameters.new unless params.key?(account_params_key)\n permitted = send(\"acc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the `action` which is used to load the proper set of account_params. The action should always get set before `account_params` is called.
def set_action(action) @action = action end
[ "def set_action(action)\n params[:action] = action\n end", "def action=(action)\n unless action\n raise Occi::Core::Errors::InstanceValidationError,\n 'Missing valid action'\n end\n\n @action = action\n reset_attributes!\n\n action\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given an account, set the account_type. Only used for `update`.
def set_account_type @account_type = account.class.to_s end
[ "def user_account_type=(value)\n @user_account_type = value\n end", "def update_account_type username, account_id, account_type, account_sub_type, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_sec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build the owner account_user. Only used for `build`.
def build_account_users account.account_users.build( user_id: owner_user.id, user_role: "Owner", created_by: current_user.id, ) account end
[ "def build_user(attrs)\n user = User.new(client, attrs)\n user = if client.user == user\n client.user\n elsif @creator == user\n creator\n elsif result = @listeners && listener(user.id) || @moderators && moderator(user.id) || friend(user.id)\n result\n else\n use...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the affiliate_id if the account type supports affiliates, the affiliate param is present, and the affiliate exists. Also ensure affiliate_other gets wiped out if the affiliate_id does not point to `Other`.
def set_affiliate if affiliate.present? account.affiliate_id = affiliate.id account.affiliate_other = affiliate.subaffiliates_enabled? ? account_params[:affiliate_other] : nil else account.affiliate_id = account.affiliate_other = nil end account end
[ "def affiliate= affiliate\n if affiliate\n if affiliate.class != affiliate_class # self.class.to_s != \"#{affiliate.class.to_s}Reference\"\n raise \"Attempt to affiliate #{self.class.to_s} reference with #{affiliate.class} object.\"\n elsif affiliate_id && (affiliate_id != affiliate.id)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the facility if the account type is scoped to facility.
def set_facility return unless account.per_facility? && facility&.id account.account_facility_joins.build(facility: facility) account end
[ "def facility=(f)\n Log.facility=(f)\n end", "def set_facilities\n if user_signed_in?\n if current_user.role == \"site_admin\"\n @userfacilities = Facility.all\n else\n @userfacilities = current_user.facility_relationships.includes(:facility_roles).where.not(facility_roles: {name: '...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return the bank activity for the specified date
def activity(date) main_ledger_account.activity(date) end
[ "def activity(date)\n ledger_entries.for_date(date).sum(:debit) - ledger_entries.for_date(date).sum(:credit)\n end", "def activities_on_date(date)\n get(\"/user/#{@user_id}/activities/date/#{format_date(date)}.json\")\n end", "def daily_activity_summary(date)\n get_call(\"user/#{user_id}/activi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return daily balances for a date range...
def daily_balances(start_date, end_date) LedgerAccountHelper.daily_balances(main_ledger_account, start_date, end_date) end
[ "def daily_balances(start_date, end_date)\n balance = balance(start_date)\n\n data = execute_sql(daily_balances_sql(start_date, end_date))\n\n balances = Array.new\n ((start_date)..(end_date)).each do |date|\n delta = if data[date].present?\n delta = data[date]['activity'].to_d\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add errors if name_is_valid? returns false
def name_is_valid errors.add(:name,'Invalid empty string for name.') unless name_is_valid? end
[ "def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end", "def check_name\n\t \terrors.push('Name is not valid') unless valid_name?\n\t end", "def check_name\n self.errors.add('This', :name_blank) if (self.employee_user_id.blank? && self.name.blank?)\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests if the name of course is not nil and is a string and returns true or false.
def name_is_valid? return false unless not_nil_and_string(self.name) return self.name.length > 0 end
[ "def valid?\n @name.is_a?(String) &&\n !@name.empty? &&\n (@variant.nil? || @variant.is_a?(String))\n end", "def valid_name?(name)\n !name.strip.empty?\nend", "def card_name_is_a_string_and_not_null\n value_is_a_string(target: :card_name, value: card_name, nullable: false)\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add errors if start_time_is_valid? return false
def start_time_is_valid errors.add(:start_time,'Invalid empty string for start time.') unless start_time_is_valid? end
[ "def start_time_is_valid?\n return false unless not_nil_and_string(self.start_time)\n return self.start_time.length > 0\n end", "def check_time\t\n\t\treturn unless errors.blank? #this will ensure the right error count on top area\n\t\tif @start_date.present? && @start_time.present?\n\t\t\t#concatenate sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests if start_time of course is not nil and a string and returns true or false.
def start_time_is_valid? return false unless not_nil_and_string(self.start_time) return self.start_time.length > 0 end
[ "def has_start_time?\n !start_time.blank?\n end", "def start_time_is_valid\n errors.add(:start_time,'Invalid empty string for start time.') unless start_time_is_valid?\n end", "def start_time_present?\n if start_time.blank?\n errors.add('start_time',\"Please select appointment time\")\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if end_time_is_valid? returns false
def end_time_is_valid errors.add(:end_time,'Invalid empty string for end time.') unless end_time_is_valid? end
[ "def end_time_is_valid?\n return false unless not_nil_and_string(self.end_time)\n return self.end_time.length > 0\n end", "def check_lesson_time_ending\r\n unless (start_time.strftime(\"%H:%M\").include? \"00\")\r\n errors.add(:start_time, \"Start time must end with ':00'\")\r\n end\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests if end_time of course is not nil and a string and returns true or false
def end_time_is_valid? return false unless not_nil_and_string(self.end_time) return self.end_time.length > 0 end
[ "def end_time_is_valid\n errors.add(:end_time,'Invalid empty string for end time.') unless end_time_is_valid?\n end", "def check_lesson_time_ending\r\n unless (start_time.strftime(\"%H:%M\").include? \"00\")\r\n errors.add(:start_time, \"Start time must end with ':00'\")\r\n end\r\n unle...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if number_of_classes_is_valid? returns false
def number_of_classes_is_valid errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid? end
[ "def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end", "def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end", "def validate_as_component\n counts = Hash.new(0)\n to_ach.each do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests if number_of_classes for course is not nil and is greater than 0 and returns true or false.
def number_of_classes_is_valid? return ((self.number_of_classes != nil) and (self.number_of_classes > 0)) end
[ "def class_how_full?\n return [self.students.count, self.class_max]\n end", "def only_has_regular_classes?\n object.courses.pluck(:type).all? { |class_type| class_type != 'Course::Training' }\n end", "def last_of_course?\n \tchapter_count == lesson.chapters.count && lesson.lesson_count == course.lesson...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if days_of_week_are_valid? returns false
def days_of_week_are_valid errors.add(:days_of_week, "The days of the week are invalid.") unless days_of_week_are_valid? end
[ "def day_of_the_week_correctness\n\t\tif day_of_the_week.blank?\n\t\t\treturn\n\t\tend\n\t\tif day_of_the_week < 0 or day_of_the_week > 6\n\t\t\terrors.add(:day_of_the_week, 'must be before 0 and 6')\n\t\tend\n\tend", "def day_of_week(days)\n @validations[:day_of_week] ||= {}\n @validation_types[:day_of_wee...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests that none of the days for course are nil and that the days's values are either true or false and returns true or false.
def days_of_week_are_valid? if (self.sunday == nil); return false; end if (self.monday == nil); return false; end if (self.tuesday == nil); return false; end if (self.wednesday == nil); return false; end if (self.thursday == nil); return false; end if (self.friday == nil); return false; end ...
[ "def perfectDayChecker day\n\t\t\t# If all five prayers were performed\n\t\t\tif day[:fajr] == 2 && day[:zuhr] == 2 && day[:asr] == 2 && day[:maghrib] == 2 && day[:isha] == 2\n\t\t\t \ttrue \t# Return true\n\t\t\telse\n\t\t\t\tfalse\t# Return false\n\t\t\tend\n\t\tend", "def dates_not_nil?\n !from.nil? && !to....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if class_min_is_valid? returns false
def class_min_is_valid errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid? end
[ "def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end", "def number_of_classes_is_valid\n errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid?\n end", "def subclass_validations ; true ; end", "def class_mi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests that class_min is not nil or that the class_max has not been set. It checks that the class_min is greater than 0 and that the class_max is greater than the class_min. It returns true or false.
def class_min_is_valid? if ((self.class_min == nil) or (self.class_max == nil)); return false; end return ((self.class_min > 0) and (self.class_max >= self.class_min)) end
[ "def class_max_is_valid?\n if ((self.class_max == nil) or (self.class_min == nil)); return false; end\n return ((self.class_max > 0) and (self.class_max >= self.class_min))\n end", "def rating_check_max_greater_min\n\t\t\treturn if self.min_rating.nil? || self.max_rating.nil?\n\n\t\t\tif (self.min_rating <...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if class_max_is_valid? returns false
def class_max_is_valid errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid? end
[ "def number_of_classes_is_valid\n errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid?\n end", "def class_min_is_valid\n errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid?\n end", "def class_max_is_valid?\n if ((self.class_max == nil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests that class_max is not nil or that the class_min has not been set. It checks that the class_max is greater than 0 and that the class_max is greater than the class_min. It returns true or false.
def class_max_is_valid? if ((self.class_max == nil) or (self.class_min == nil)); return false; end return ((self.class_max > 0) and (self.class_max >= self.class_min)) end
[ "def class_min_is_valid?\n if ((self.class_min == nil) or (self.class_max == nil)); return false; end\n return ((self.class_min > 0) and (self.class_max >= self.class_min))\n end", "def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end", "def rati...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if fee_per_meeting_is_valid? returns false
def fee_per_meeting_is_valid errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid? end
[ "def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end", "def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end", "def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests that the fee_per_meeting for course is not nil and greater than or equal to 0 and returns true or false.
def fee_per_meeting_is_valid? return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0)) end
[ "def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end", "def scholarship_amount_is_valid?\n return false unless self.scholarship_amount != nil\n course = Course.find_by_id(self.course_id)\n return false unless course #make sure course is non-nil\n return ((sel...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if fee_for_additional_materials returns false
def fee_for_additional_materials_is_valid errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid? end
[ "def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end", "def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end", "def validate_materials\n if !self.ma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests that fee_for_additional_material for course is not nil and greater than or equal to 0 and returns true or false.
def fee_for_additional_materials_is_valid? return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0)) end
[ "def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end", "def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end", "def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds errors if total_fee_is_valid? returns false
def total_fee_is_valid errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid? end
[ "def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end", "def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests that course's total_fee is not nil and is greater than or equal to 0 and returns true or false.
def total_fee_is_valid? return ((self.total_fee != nil) and (self.total_fee >= 0)) end
[ "def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end", "def scholarship_amount_is_valid?\n return false unless self.scholarship_amount != nil\n course = Course.find_by_id(self.course_id)\n return false unless course #make sure course is non-nil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }