query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Override: Detect the special status set by the Proxy Servlet and use the default Jekyll response instead. | def service(req, res)
proxy_servlet.service(req, res)
if res.status == STATUS_SERVE_ORIGINAL
res.status = 200
super
end
end | [
"def default_status\n 200\n end",
"def fallback\n @response.status = fallback_response[:status] || 200\n @response.content_type fallback_response[:content_type] || 'text/html'\n @response.content = fallback_response[:body] || fallback_response[:content] || \"\"\n self.succeed\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: A WEBRick servlet that uses a Rack proxy internally. | def proxy_servlet
@proxy_servlet ||= begin
# Called by the proxy if a request shouldn't be served by Vite.
app = ->(_env) { [STATUS_SERVE_ORIGINAL, {}, []] }
# Initialize the proxy which is a Rack app.
proxy = ViteRuby::DevServerProxy.new(app)
# Return a servlet compliant with WEBric... | [
"def start_dav4rack(port, root)\n options = {:resource_class => MyResource, :root => root }\n\n app = Rack::Builder.new do\n use Rack::ShowExceptions\n # use Rack::CommonLogger # Display all requests\n use Rack::Reloader\n use Rack::Lint\n run DAV4Rack::Handler.new(options)\n end.to_app\n\n runn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /produits/:produit_id/comments/:id PUT /produits/:produit_id/comments/:id.xml | def update
@produit = Produit.find(params[:produit_id])
@comment = @produit.comments.find(params[:id])
if @comment.update(comment_params)
redirect_to produit_path(@produit)
else
render 'edit'
end
end | [
"def destroy\n produit = Produit.find(params[:produit_id])\n @comment = produit.comments.find(params[:id])\n @comment.destroy\n redirect_to(produit)\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /produits/:produit_id/comments/1 DELETE /produits/:produit_id/comments/1.xml | def destroy
produit = Produit.find(params[:produit_id])
@comment = produit.comments.find(params[:id])
@comment.destroy
redirect_to(produit)
end | [
"def destroy\n @commentaire = Commentaire.find(params[:id])\n @commentaire.destroy\n\n respond_to do |format|\n format.html { redirect_to(commentaires_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @thesis_proposal_comment = ThesisProposalComment.find(params[:id])\n @t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get file ext and return language as 'ruby', 'javascript', 'php' or nil if unknown | def get_lang_from_path
case File.extname(@path).downcase
when '.rb'
'ruby'
when '.js'
'javascript'
when '.php'
'php'
else
nil
end
end | [
"def language\n parts = file.split('.')\n raise \"file has no extension\" if parts.length < 2\n parts[-1]\n end",
"def extname\n ext = File.extname(file)\n if ext.empty?\n ext = '.rdoc' if /^\\=/ =~ text\n ext = '.md' if /^\\#/ =~ text\n end\n return ext\n end",
"def r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /contract_types GET /contract_types.json | def index
@contract_types = ContractType.all
end | [
"def index\n @catalog_contract_types = Catalog::ContractType.all\n end",
"def index\n @type_contracts = TypeContract.all\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n format.ext_json { render :json => find_contract_types.to_ext_jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /contract_types POST /contract_types.json | def create
@contract_type = ContractType.new(contract_type_params)
respond_to do |format|
if @contract_type.save
format.html { redirect_to @contract_type, notice: 'Contract type was successfully created.' }
format.json { render :show, status: :created, location: @contract_type }
els... | [
"def create\n @contract_type = ContractType.new(params[:contract_type])\n\n respond_to do |format|\n if @contract_type.save\n format.html { redirect_to @contract_type, notice: 'Contract type was successfully created.' }\n format.json { render json: @contract_type, status: :created, location... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /contract_types/1 PATCH/PUT /contract_types/1.json | def update
respond_to do |format|
if @contract_type.update(contract_type_params)
format.html { redirect_to @contract_type, notice: 'Contract type was successfully updated.' }
format.json { render :show, status: :ok, location: @contract_type }
else
format.html { render :edit }
... | [
"def update\n @contract_type = ContractType.find(params[:id])\n\n respond_to do |format|\n if @contract_type.update_attributes(params[:contract_type])\n format.html { redirect_to @contract_type, notice: 'Contract type was successfully updated.' }\n format.json { head :ok }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /contract_types/1 DELETE /contract_types/1.json | def destroy
@contract_type.destroy
respond_to do |format|
format.html { redirect_to contract_types_url, notice: 'Contract type a bien été supprimé.' }
format.json { head :no_content }
end
end | [
"def destroy\n @contract_type = ContractType.find(params[:id])\n @contract_type.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contract_type = ContractType.find(params[:id])\n\n respond_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Around callback that makes sure default ENV variables needed for JWT authentication are set by default. It is still possible to overwrite some of the ENV vars for specific case. class MyControllerTest < ContainerService::IntegrationTest test "env var needs to be stubed for this test" do ClimateControl.modify(JWT_VALIDA... | def around
ClimateControl.modify(default_env_vars) do
super
end
end | [
"def mock_env_vars(vars)\n vars.each do |k, v|\n allow(ENV).to receive(:[]).with(k).and_return(v)\n end\n end",
"def with_test_env\n in_separate_environment do\n # Overwrite environment variables with values for testing\n Dotenv.overload '.env.test'\n yield\n end\nend",
"def confi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
row level methods go here extract the first three stanzas from each filename e.g 'webgl_shadowmap_viewer.html' > ['webgl', 'shadowmap', 'viewer'] def extract_name_info_from_fn(fn:) | def extract_stanzas(fn:)
result = []
# switch on the number of "stanzas" in the fn
# three or greater stanzas
if fn.match(/([^_\.]+)_([^_]+)_([^_\.]+)/)
m = fn.match(/([^_\.]+)_([^_]+)_([^_\.]+)/)
result[0] = m[1]
result[1] = m[2]
result[2] = m[3]
# two stanzas
elsif fn... | [
"def infer_species_from_filename fn\n fields = fn.split(\".\")\n fields.last =~ /^[A-Z][a-z]{1,2}$/ ? fields.last : nil\nend",
"def get_func_name (filestem)\n return $1 if filestem =~ /^(.+)_/\n filestem\nend",
"def extract_ais_fields_from_filename(filename)\n pn = Pathname.new(filename)\n matches = /... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin def initialize(user, controller_namespace) case controller_namespace when 'Admin' can :manage, :all if user.has_role? 'admin' else rules for nonadmin controllers here end end =end | def initialize(user, controller_namespace)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
# can :read, :all
# end
#
# The first argument to `can` is the ac... | [
"def initialize(user)\n #can :manage, :all\n #return\n\n user ||= AdminUser.new # user (not logged in)\n\n case user.role.name\n \n when 'admin'\n can :manage, :all\n\n when 'guardian'\n can :read, Provider\n can :read, ActiveAdmin::Page, :name => \"Dashboard\"\n \n when ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The parking space costs $1 for 60 min Return the number of minutes remaining | def minutes_remaining
time_elapsed = (Time.new - @start_time) / 60
(@total_paid * 60 - time_elapsed).floor
end | [
"def time_spent_waiting\n time_in_store - time_to_checkout\n end",
"def approx_minutes_remaining\n (remaining / 60.0).round.to_i\n end",
"def work_needed(project_minutes, freelances)\n freelance_hours = 0\n freelance_minutes = 0\n my_hours = 0\n my_minutes = 0\n\n freelances.each do |f|\n fr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check how much time is left on the meter | def check_meter
puts "You have #{minutes_remaining} minutes remaining."
end | [
"def time_left\n return 0.0 if free?\n return end_time - Time.now.to_f\n end",
"def time_left\n time_difference(Time.now,out_time)\n end",
"def remaining_time()\n return @total_time_units - @done_time_units\n end",
"def total_exclusive_time; end",
"def charged?\n return (@time ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The meter maid checks if you have overstayed your meter If so, he / she writes a ticket The fine is 3x the number of minutes overstayed | def meter_maid_check
if minutes_remaining < 0
fine = minutes_remaining * -3
"Bummer! You got a $#{fine} ticket."
else
'The meter maid came and went.'
end
end | [
"def check_meter\n puts \"You have #{minutes_remaining} minutes remaining.\"\n end",
"def evil_code_medal(user_time, gold, silver, bronze)\n\n def time_in_seconds\n self.split(\":\").map(&:to_i).map.with_index {|num, index| num = num * 60 if index == 1 ; num = num * 3600 if index == 0 ; num }.inject(:+)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a temporary directory. This directory will exist for the life of the spec. id Identifier of the tmpdir (default: the default identifier). Returns a String. | def tmpdir(id=:default)
@tmpdirs[id] ||= Dir.mktmpdir
end | [
"def tmpdir(id=:default)\n @tmpdirs[id] ||= Pathname.new(Dir.mktmpdir)\n end",
"def tmpdir(id=:default)\n @tmpdirs[id] ||= Pathname.new(Dir.mktmpdir).realdirpath\n end",
"def make_tempdir\n\t\tdirname = \"%s.%d.%0.4f\" % [\n\t\t\t'strelka_spec',\n\t\t\tProcess.pid,\n\t\t\t(Time.now.to_f % 3600),\n\t\t ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a test mysql database. The database will exist for the life of the spec. schema String schema to create (default: no schema). Returns nothing. | def create_mysql_database(schema="")
@mysql_database = true
MysqlUtils.create_mysql_database(database_name, schema)
end | [
"def create_schema(schema)\n execute \"CREATE SCHEMA #{schema}\", 'Create Schema'\n end",
"def create_schema schema_name\n exec_query(\"CREATE SCHEMA #{schema_name}\")\n end",
"def create_schema schema_name\n execute \"CREATE SCHEMA #{quote_schema_name(schema_name)}\"\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Drop the test mysql database. Returns nothing. | def drop_mysql_database
MysqlUtils.drop_mysql_database(database_name)
end | [
"def drop_database\n puts \"Droping database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"DROP DATABASE IF EXISTS #{@db_name}\")\n client.close\n rescue Exception => e\n puts \"An e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get access to the mysql database. Returns a MysqlInspector:Access. | def access
(@access ||= {})[database_name] ||= MysqlInspector::Access.new(database_name, "root", nil, "mysql")
end | [
"def access\n MysqlInspector::AR::Access.new(ActiveRecord::Base.connection)\n end",
"def database_type\n :access\n end",
"def mysql\n config_var = shift_argument\n config_vars = get_config_vars(config_var)\n uri = resolve_config_var_uri(\"mysql\", *config_vars)\n if !open_mysql(\"MyS... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We want to be sure that failures to apply resources with potentially sensitive output don't leak any content. Currently our only sensitive resource is `Secret`, but we cannot reproduce a failure scenario where the kubectl output contains the filename (which would trigger some extra logging). This test stubs `Deployment... | def test_apply_failure_with_sensitive_resources_hides_template_content
logger.level = 0
Krane::Deployment.any_instance.expects(:sensitive_template_content?).returns(true).at_least_once
result = deploy_fixtures("hello-cloud", subset: ["web.yml.erb"], render_erb: true) do |fixtures|
bad_port_name = "htt... | [
"def do_create_secret(secret)\n namespace = secret['namespace']\n name = secret['name']\n spec = secret['data']\n annotations =secret['annotations']\n labels= secret['labels']\n secret_type= secret['secret_type']\n filename=\"/var/vcap/data/action/secret_#{name}.yml\"\n\n\n File.open(filename, 'w+') do |f|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test_global_deploy_black_box_failure is in test/integration/krane_test.rb because it does not modify global state. The following two tests modify global state and must be run in serially | def test_global_deploy_black_box_success
setup_template_dir("globals") do |target_dir|
flags = "-f #{target_dir} --selector app=krane"
out, err, status = krane_black_box("global-deploy", "#{KubeclientHelper::TEST_CONTEXT} #{flags}")
assert_empty(out)
assert_match("Success", err)
assert... | [
"def test_global_deploy_black_box_failure\n setup_template_dir(\"resource-quota\") do |target_dir|\n flags = \"-f #{target_dir} --selector app=krane\"\n out, err, status = krane_black_box(\"global-deploy\", \"#{KubeclientHelper::TEST_CONTEXT} #{flags}\")\n assert_empty(out)\n assert_match(\"F... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempts to return parameter Search string if available. If search String not available, then return IP address Zip Code. If IP Zip Code not available, then just return St.Louis zip code. | def getSearchString(searchString)
return params[:search] if (params[:search].present?)
@IP_ZipCode = request.location.postal_code
return @IP_ZipCode if (@IP_ZipCode.present?)
return "63101"
end | [
"def postal_code_search(_zip, _city, _country, or_search)\n unless or_search\n Rails.logger.debug \"\\t1) Determine longitude/latitude using exact search (AND)\" \n else\n Rails.logger.debug \"\\t\\t1.1) Determine longitude/latitude using matched search (OR)\"\n end\n \n geo_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lesson 2 Ruby control flow Is It Chicken Tenders Day? 5/??/2014 To test any of your functions from the command line, type $ ruby lesson2.rb and follow the instructions... I Do Specification: write a function tenders(day) that will return true if day == "THURSDAY" and false otherwise. Examples: tenders('THURSDAY') => tr... | def tenders(day)
if day == 'THURSDAY'
true
else
false
end
end | [
"def tenders_ci(day)\n\tif day.upcase == 'THURSDAY' #convert our string to uppercase and then test\n\t\t\"It's Chicken Tenders Day!\" \n\telse \n\t\t\"Nope.\"\n\tend\nend",
"def am_I_afraid(day,num)\n case day\n when \"Monday\"\n num == 12 ? true : false\n when \"Tuesday\"\n num > 95 ? true : false\n w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We Do Specification: write a function tenders_ci(day) that will return "It's Chicken Tenders Day!" if the day is Thursday (caseinsensitive) and "Nope." otherwise Examples tenders_ci('THURSDAY') => "It's Chicken Tenders Day!" tenders_ci('tHuRsDaY') => "It's Chicken Tenders Day!" tenders_ci('thursday') => "It's Chicken T... | def tenders_ci(day)
if day.upcase == 'THURSDAY' #convert our string to uppercase and then test
"It's Chicken Tenders Day!"
else
"Nope."
end
end | [
"def get_day_name(day) \n day_name = \"\"\n\n case day \n when \"Mon\"\n day_name = \"Monday\"\n when \"Tues\"\n day_name = \"Tuesday\"\n when \"Wed\"\n day_name = \"Wednesday\"\n when \"Thur\"\n day_name = \"Thursday\"\n when \"Fri\"\n day_name = \"Friday\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specification: write a function tenders_flip() that will return "It's Chicken Tenders Day!" if Random.rand(2) == 0 and "Nope" otherwise. This achieves 50/50 probability... Examples tenders_flip() => "It's Chicken Tenders Day!" tenders_flip() => "Nope." tenders_flip() => "It's Chicken Tenders Day!" | def tenders_flip()
if Random.rand(2) == 0 #achieves 50/50 probability
"It's Chicken Tenders Day!"
else
"Nope."
end
end | [
"def tenders_rand()\n\tif Random.rand(7) == 0 #achieves 1/7 probability\n\t\t\"It's Chicken Tenders Day!\" \n\telse \n\t\t\"Nope.\"\n\tend\nend",
"def coin_flip(v1=1, v2=1)\n raise \"Poor argument to coin_flip\" if v1<=0 or v2<=0\n weight = v1.to_f / (v1 + v2)\n return random < weight\nend",
"def coin_flipp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /invitations/new GET /invitations/new.json | def new
@invitation = Invitation.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @invitation }
end
end | [
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invitation_response = InvitationResponse.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"
]
]
}
} |
Resolve the given event object into a Coordination::Task and a Coordination::Models::Task | def resolve_task(task)
if root_task && task.kind_of?(Roby::Task)
root_task.plan.add(task)
model_task = Coordination::Models::Task.new(task.model)
script_task = instance_for(model_task)
bind_coordination_task_to_instance(scri... | [
"def resolve_event(event)\n if event.respond_to?(:to_sym)\n symbol = event\n if root_task\n event = root_task.find_event(symbol)\n else\n event = model.root.find_event(symbol)\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resolve the given event object into a Coordination::Event and a Coordination::Models::Event | def resolve_event(event)
if event.respond_to?(:to_sym)
symbol = event
if root_task
event = root_task.find_event(symbol)
else
event = model.root.find_event(symbol)
end
... | [
"def event\n @event ||= event_type.singularize.camelize.constantize.find_by_id(event_id)\n end",
"def deserialize_event(event)\n event.event_type.camelize.constantize.new(aggregate_id: event.aggregate_id,\n id: event.id,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sleep for a given number of seconds | def sleep(seconds)
task = start(Tasks::Timeout.new(delay: seconds), explicit_start: true)
wait task.stop_event
end | [
"def sleep(seconds)\n sleep(seconds)\n end",
"def sleep(dur=0) end",
"def delay(seconds)\n sleep(seconds)\n end",
"def sleep(time)\n error \"sleep parameter must be a float or a integer\" if\n not time.kind_of?(Numeric)\n seconds = time.to_f\n puts \"Waiting #{time} s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Emit the given event | def emit(event)
event, model_event = resolve_event(event)
model.emit(model_event)
event
end | [
"def emit(event)\n validate_event event\n add Emit.new(event)\n end",
"def emit(event, data)\n broker.emit(event, data)\n end",
"def emit(event_model, *context)\n event(event_model).emit(*context)\n self\n end",
"def emit(ev... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Execute the provided block once per execution cycle, until the given event is emitted | def poll_until(event, &block)
raise ArgumentError, "poll_until requires a block" unless block
event, model_event = resolve_event(event)
model.instructions << Script::Models::PollUntil.new(model_event, block)
event
end | [
"def call(event)\n @block.call(event)\n end",
"def every_step(&block)\n add_event Event.new(block),true\n end",
"def signal_wait_until(pr, &block)\n #NOTE: busy waiting!!!\n while true do\n torrent = yield\n break if pr.call torrent\n end\n end",
"def follow &... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stop a timeout operation. Usually not used directly | def timeout_stop(timeout)
model.timeout_stop(timeout)
end | [
"def cancel_timeout; end",
"def stop_timer\n @stop_time = Time.now\n end",
"def cancel\n @stopped = true\n @event_loop.cancel_timer self\n end",
"def wait_or_cancel(timeout); end",
"def timeout\n if stop_time.nil?\n nil\n else\n timeout = stop... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a task script that is going to be executed while this task instance runs. | def script(options = {}, &block)
execute do |task|
script = model.create_script(task, &block)
script.prepare
script.step
end
model.create_script(self, &block)
end | [
"def add_a_task\n\n end",
"def add_script name\n return if @scripts.include? name\n\n $log.debug(\"Flags.add_script\") { name }\n\n @scripts << name\n end",
"def add_eval_task(ev_task)\n self.all_tasks << ev_task\n end",
"def add_task(&blk)\n _tasker.push blk\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return priority of current attack | def attack_priority
if @action == "items"
return $data.items[@item_id].priority
else
return 3 if @skill_id == nil
return $data.skills[@skill_id].priority
end
end | [
"def struggle_priority\n GameData::Skill[ID_Struggle].priority * DeltaPrio\n end",
"def priority\n return data.priority\n end",
"def priority\n self.class.priorities.key(self[:priority])\n end",
"def priority\n get(:priority) || -Float::INFINITY\n end",
"def calculated_priority\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a user in canvas based on the passed user storing the new canvas user id in the object. Be sure to call user.save at some point after using this. | def create_user(user)
open_canvas_http
# the v1 is API version, only one option available in Canvas right now
# accounts/1 refers to the Beyond Z account, which is the only one
# we use since it is a custom installation.
request = Net::HTTP::Post.new('/api/v1/accounts/1/users')
requ... | [
"def create_user_in_canvas(user, username, timezone = nil, docusign_template_id = nil)\n user_student_id = nil\n enrollment = Enrollment.find_by_user_id(user.id)\n user_student_id = enrollment.student_id unless enrollment.nil?\n\n # the v1 is API version, only one option available in Canvas righ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Syncs the user enrollments with the given data, by unenrolling from existing courses, if necessary, and enrolling them in the new course+section. The goal of this method is to make Canvas's internal data match the spreadsheet data, allowing for bulk fixes via csv import. | def sync_user_course_enrollment(user, course_id, role, section)
@course_enrollment_cache = {} if @course_enrollment_cache.nil?
if @course_enrollment_cache[course_id].nil?
@course_enrollment_cache[course_id] = get_course_enrollments(course_id)
end
existing_enrollment = nil
@course... | [
"def refresh_enrollments_in_section(campus_section, course_id, section_id, teacher_role, canvas_section_id, enrollments_csv, known_users, users_csv)\n refresh_students_in_section(campus_section, course_id, section_id, enrollments_csv, known_users, users_csv)\n refresh_teachers_in_section(campus_section, c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of enrollments objects for the user. | def get_user_enrollments(user_id)
open_canvas_http
request = Net::HTTP::Get.new(
"/api/v1/users/#{user_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}"
)
response = @canvas_http.request(request)
info = JSON.parse response.body
info
end | [
"def get_user_enrollments(user_id)\n request = Net::HTTP::Get.new(\n \"/api/v1/users/#{user_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = get_all_from_pagination(response)\n\n info\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of enrollments objects for the course. | def get_course_enrollments(course_id)
open_canvas_http
request = Net::HTTP::Get.new(
"/api/v1/courses/#{course_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}"
)
response = @canvas_http.request(request)
info = JSON.parse response.body
info
... | [
"def fetch_course_enrollments\n bad_request_error('Unauthorized Access to Course Enrollments') && return unless enrollment_course_tutor_or_admin?\n @enrollments = Enrollment.where(course_id: @course.id)\n # TODO: Add pagination, fetch only first 20 by default\n render json: @enrollments\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Opens a connection to the canvas http api (the address of the server is pulled from environment variables). | def open_canvas_http
if @canvas_http.nil?
@canvas_http = Net::HTTP.new(Rails.application.secrets.canvas_server, Rails.application.secrets.canvas_port)
if Rails.application.secrets.canvas_use_ssl
@canvas_http.use_ssl = true
if Rails.application.secrets.canvas_allow_self_signed_s... | [
"def open_canvas_http\n \n # NOTE: disabling the re-use of connections. When connecting to Heroku hosted\n # apps over SSL, the first request works but the second fails with:\n # \"OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: tlsv1 alert protocol version\"\n # Leaving this method ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
max=0 accounts.each_with_index do |account,index| accountsum = account.inject(:+) if max < accountsum max = accountsum end end return max end | def maximum_wealth(accounts)
accounts.map {|account| account.sum }.max
end | [
"def max_sum(row)\n\tbiggest = 0\n\trow.each do |e|\n\t\tbiggest = e if e > biggest\n\tend\n\tbiggest\nend",
"def max_profit(stocks)\n max = 0\n buy = stocks[0]\n\n stocks.each_with_index do |sell, index|\n # ignore the first index just because already set it above\n next if index == 0\n\n current_pro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves crumbs created by the user | def crumbs_by(opts = {})
klass = Redcrumbs.crumb_class
klass.created_by(self).all(opts)
end | [
"def crumbs_by\n crumb_or_custom_class.all(:creator_id => self[Redcrumbs.creator_primary_key], :order => [:created_at.desc])\n end",
"def crumbs\n [self]\n end",
"def crumbs\n get_or_set_ivar \"@_crumbs\", []\n end",
"def crumbs_as_user(opts = {})\n opts[:limit] ||= 100\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
, :require_http_basic_auth TODO [11/2/10 2:35 AM] => TEST_AND_REMOVE_CODE (:enable_light_box, :disable_light_box) def enable_light_box | def require_http_basic_auth
if APP_CONFIG['perform_authentication']
authenticate_or_request_with_http_basic do |login, password|
login==APP_CONFIG['username'] and password == APP_CONFIG['password']
end
end
end | [
"def request_http_basic_auth(value = nil)\n rw_config(:request_http_basic_auth, value, false)\n end",
"def basic_auth\n if ENV['BASIC_AUTH_ACTIVATED'] && ENV['BASIC_AUTH_ACTIVATED'].downcase == \"true\"\n authenticate_or_request_with_http_basic('Dev Access') do |username, password|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method checks for presence of one or more files/dirs in a config item. The config may be singular (String) or multiple (Array) so we need to check [configKey] is a param name from knife.rb, command line or generated by Knife/Chef [description] is used to pass a helpful message to the user if the param is missing | def checkfiles(configKey, description)
# Check if the file/dir name is actually set
if config[configKey].nil?
puts ui.color(" #{configKey} is not set", :red)
puts ui.color(" #{description}", :magenta)
else
# Check if we have been passed an array of files/dirs
... | [
"def check_config\n list = []\n %w(app_key secret_key endpoint).map do |k|\n list << k unless config.has_key? k\n end\n\n raise \"[#{list.join(', ')}] not included in your yaml file.\" unless list.empty?\n end",
"def check_config\n list = []\n %w(app_key secret_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is called by checkfiles to verify an individual file [configKey] is a param name from knife.rb, command line or generated by Knife/Chef [fileName] is the actual value of the configKey [description] is used to pass a helpful message to the user if the param is missing | def checkfile(configKey, fileName, description)
# Check if the file exists
if ::File.exists?(File.expand_path(fileName))
# Yes, so display it
puts ui.color(" #{configKey} is set to '#{fileName}'",:green)
else
# No, so tell the user it's missing
puts ui.co... | [
"def checkfiles(configKey, description)\n # Check if the file/dir name is actually set\n if config[configKey].nil?\n puts ui.color(\" #{configKey} is not set\", :red)\n puts ui.color(\" #{description}\", :magenta)\n else\n # Check if we have been passed an array... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method checks for the existence of specified parameters [configKey] is a param name from knife.rb, command line or generated by Knife/Chef [description] is used to pass a helpful message to the user if the param is missing | def checkparm(configKey,description)
# Check if the [configKey] is set
if config[configKey].nil?
# No, so tell the user a bit about what it does, why its needed, what to do etc.
puts ui.color(" #{configKey} is not set", :red)
puts ui.color(" #{description}", :magenta)... | [
"def read_and_validate_params\n if @name_args.length < 1\n show_usage\n exit 1\n end\n\n if config[:name].nil? ||\n config[:vios].nil? ||\n config[:virtual_server].nil?\n show_usage\n exit 1\n end\n end",
"def check_global_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /armor_slots GET /armor_slots.json | def index
@armor_slots = ArmorSlot.all
end | [
"def index\n @ship_armor_slots = ShipArmorSlot.all\n end",
"def equip_slots\r\n # data = {equip_slots: (@race_equip_slots + @mobile_class_equip_slots)}\r\n # Game.instance.fire_event(self, :get_equip_slots, data )\r\n slots = []\r\n if @race_equip_slots && @race_equip_slots.any?\r\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /armor_slots POST /armor_slots.json | def create
@armor_slot = ArmorSlot.new(armor_slot_params)
respond_to do |format|
if @armor_slot.save
format.html { redirect_to @armor_slot, notice: 'Armor slot was successfully created.' }
format.json { render :show, status: :created, location: @armor_slot }
else
format.html... | [
"def create\n @ship_armor_slot = ShipArmorSlot.new(ship_armor_slot_params)\n\n respond_to do |format|\n if @ship_armor_slot.save\n format.html { redirect_to @ship_armor_slot, notice: 'Ship armor slot was successfully created.' }\n format.json { render :show, status: :created, location: @shi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /armor_slots/1 PATCH/PUT /armor_slots/1.json | def update
respond_to do |format|
if @armor_slot.update(armor_slot_params)
format.html { redirect_to @armor_slot, notice: 'Armor slot was successfully updated.' }
format.json { render :show, status: :ok, location: @armor_slot }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @ship_armor_slot.update(ship_armor_slot_params)\n format.html { redirect_to @ship_armor_slot, notice: 'Ship armor slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @ship_armor_slot }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /armor_slots/1 DELETE /armor_slots/1.json | def destroy
@armor_slot.destroy
respond_to do |format|
format.html { redirect_to armor_slots_url, notice: 'Armor slot was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @ship_armor_slot.destroy\n respond_to do |format|\n format.html { redirect_to ship_armor_slots_url, notice: 'Ship armor slot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ammo_slot.destroy\n respond_to do |format|\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find all the end points of possible sequences which contain (x, y) | def find_end_points(x, y, chip)
end_points = @DIR_DELTAS.keys.map { |dir| end_point_in_direction(x, y, chip, dir) }
end_points.uniq { |point| point.take(2) }
end | [
"def find_all_sequences(x,y)\n ret = []\n ret << [[x,y],[x+1,y],[x+2,y],[x+3,y]] if x+3 <= 19\n ret << [[x,y],[x,y+1],[x,y+2],[x,y+3]] if y+3 <= 19\n ret << [[x,y],[x+1,y+1],[x+2,y+2],[x+3,y+3]] if y+3 <= 19 && x+3 <= 19\n ret << [[x,y],[x-1,y+1],[x-2,y+2],[x-3,y+3]] if x-3 >= 0 && y+3 <= 19\n ret\nend",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the end point of a possible sequence which contains (x, y) in a given direction | def end_point_in_direction(x, y, chip, dir)
# TODO: Currently this will keep searching for an end point until it reaches
# an empty space, the end of the board, or an opposing chip. It would be
# more efficient to also stop searching if the distance searched exceeds
# the number of chips needed in a row... | [
"def find_end_points(x, y, chip)\n end_points = @DIR_DELTAS.keys.map { |dir| end_point_in_direction(x, y, chip, dir) }\n end_points.uniq { |point| point.take(2) }\n end",
"def near_xy direction\n nx = @x\n ny = @y\n delta = [\"ny -= 1\", \"nx += 1\", \"ny += 1\", \"nx -= 1\"]\n @angle.times{del... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine if the given point, which is an end point of a sequence, is the end point of a winning sequence of chips | def winning_end_point?(point, num_to_win)
x = point[0]
y = point[1]
dir = point[2]
chip = get_chip_at(x, y)
delta = @DIR_DELTAS[dir]
count = 1
1.upto(num_to_win - 1) do |i|
check_x = x + (i * delta[0])
check_y = y + (i * delta[1])
if in_bounds?(check_x, check_y) && get_chip... | [
"def is_obstructed?(start_point, end_point)\n\t\terror_msg = \"Invalid input. Not diagonal, horizontal, or vertical\"\n\n\t\t# Define starting and ending coordinates for pieces\n\t\tstart_x, start_y = start_point\n\t\tend_x, end_y = end_point\n\n\t\t# Determine if piece is moving vertically, x coordinates being th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The string representing the display of the column numbers | def column_numbers_string
normalize_widths = (1..@width).to_a.map do |num|
# If the column number is 1 digit, put a space in front of it
if num > 9
num.to_s
else
" " + num.to_s
end
end
normalize_widths.join('|')
end | [
"def column_header\n (0..upper_bound_x+1)\n .to_a\n .map { |num| num.to_s.rjust((upper_bound_y + 1).to_s.size,'0')}\n .map { |num| num.chars }\n .transpose\n .map { |num| num.join }\n .map { |num| num.rjust(num.size + 5,\" \") }\n .join(\"\\n\") + \"\\n\"\n end",
"def col(nu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=> bird Reflection I started to understand what James told me. I had never played boggle board before. This started to make sense Part 2: Write a method that takes a row number and returns all the elements in the row. Pseudocode define a method called row that takes the parameters board and row the method will take row... | def get_row(row,board) # row(x,*y)
board[row]
end | [
"def get_row(board, row) # def method takes 2 params (board name & row #)\n\tboard[row] # grab from \"X\" board the \"X\" row (in this exercise it'll be boggle_board \nend",
"def get_row(row,board) # row(x,*y)\r\n\tboard[row]\r\nend",
"def get_row(board,row_num)\n\tboard[row_num]\nend",
"def get_row(row)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Take care of the changes in the font_awsome icon names. Now, instead of "iconsomething" we must return "fa fasomething" | def the_icon
icon.sub(/^icon\-/, 'fa fa-')
end | [
"def get_icon(name)\n case name\n when \"tasks\" then \"fa-check-square-o\"\n when \"campaigns\" then \"fa-bar-chart-o\"\n when \"leads\" then \"fa-tasks\"\n when \"accounts\" then \"fa-users\"\n when \"contacts\" then \"fa-user\"\n when \"opportunities\" then \"fa-money\"\n when \"team\" th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instance Methods Verify all of the audit's design checks. :callseq: verify_all_checks() > boolean Set all design check results, both self and peer, to 'Verified' and set the audit's state variables to indicate that the audit is complete. | def verify_all_checks
now = Time.now
self.trim_checklist_for_design_type
self.design_checks each do | design_check |
if design_check.check.is_peer_check?
design_check.auditor_result = 'Verified'
design_check.auditor_checked_on = now
end
if design_check.check.is_se... | [
"def clear_all_checks\n \n self.trim_checklist_for_design_type\n \n self.design_checks.each do | design_check |\n design_check.auditor_result = 'None' #if design_check.check.is_peer_check?\n design_check.designer_result = 'None' #if design_check.check.is_self_check?\n design_check.save\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset all of the audit's design checks. :callseq: clear_all_checks() > boolean Set all design check results, both self and peer, to 'None' and reset the audit's state variables. | def clear_all_checks
self.trim_checklist_for_design_type
self.design_checks.each do | design_check |
design_check.auditor_result = 'None' #if design_check.check.is_peer_check?
design_check.designer_result = 'None' #if design_check.check.is_self_check?
design_check.save
end
... | [
"def reset\n self.skip = false\n self.designer_complete = false\n self.designer_completed_checks = 0\n self.auditor_complete = false\n self.auditor_completed_checks = 0\n self.save\n\n now = Time.now\n self.design_checks.each do |design_check|\n de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Force a skip of a setup audit :callseq: force_skip_audit() => status message Delete all the audit checks and set the audit to skipped If auditor_completed_checks == 0 | def force_skip_audit
msg = "Can't force skip because audit has started"
return msg if self.designer_completed_checks != 0
msg = ""
ok = true
self.trim_checklist_for_design_type
self.design_checks.each do | design_check |
unless design_check.delete
msg += "Can't delete... | [
"def skip_audit\n @skip = true\n end",
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n block.call\n ensure\n enable_auditing if auditing_was_enabled\n end",
"def without_auditing(&block)\n auditing_was_enab... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Report the status of the audit. :callseq: audit_state() > integer Returns one of the following values that indicate the state of the audit. Audit::SELF_AUDIT:: the audit is in the self audit state Audit::PEER_AUDIT:: the audit is in the peer audit state Audit::AUDIT_COMPLETE:: the audit is complete | def audit_state
return SELF_AUDIT unless self.designer_complete?
return PEER_AUDIT unless self.auditor_complete?
return AUDIT_COMPLETE
end | [
"def human_readable_audit_status\n stat = audit_stat\n case stat\n when 0\n 'failing'\n when 1\n 'passing'\n else\n stat\n end\n end",
"def audit_status(sequence)\n context = sequence.context\n title = context.decommission? ? 'decommissio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is_self_audit? Description: This method determines if the audit is a self audit. Parameters: None Return value: TRUE if the audit is in the SELF_AUDIT state, FALSE otherwise. | def is_self_audit?
self.audit_state == SELF_AUDIT
end | [
"def self_update?(user)\n self.is_self_audit? && self.is_self_auditor?(user)\n end",
"def is_self_auditor?(user)\n (self.design.designer_id == user.id ||\n self.audit_teammates.detect { |t| t.user_id == user.id && t.self? })\n end",
"def set_is_accessing_self\n @is_accessing_self = (\n u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is_peer_audit? Description: This method determines if the audit is a peer audit. Parameters: None Return value: TRUE if the audit is in the PEER_AUDIT state, FALSE otherwise. | def is_peer_audit?
self.audit_state == PEER_AUDIT
end | [
"def is_peer_auditor?(user)\n (self.design.peer_id == user.id ||\n self.audit_teammates.detect { |t| t.user_id == user.id && !t.self? })\n end",
"def peer_update?(user)\n self.is_peer_audit? && self.is_peer_auditor?(user)\n end",
"def is_self_audit?\n self.audit_state == SELF_AUDIT\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is_complete? Description: This method determines if the audit is complete. Parameters: None Return value: TRUE if the audit is in the AUDIT_COMPLETE state, FALSE otherwise. | def is_complete?
self.audit_state == AUDIT_COMPLETE
end | [
"def is_complete?\n is_complete = true\n\n unless metaData.first.status == 'ACTIVE'\n Rails.logger.debug \"REGISTRATION::IS_COMPLETE? status = #{metaData.first.status}\"\n is_complete = false\n return\n end\n\n if is_awaiting_conviction_confirmation?\n is_complete = false\n retu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is_self_auditor? Description: This method determines if the user is a self auditor. Parameters: user A User record for the person this method is checking to if the person is on the self audit team. Return value: TRUE if the user is on the self audit team, FALSE otherwise. | def is_self_auditor?(user)
(self.design.designer_id == user.id ||
self.audit_teammates.detect { |t| t.user_id == user.id && t.self? })
end | [
"def self_update?(user)\n self.is_self_audit? && self.is_self_auditor?(user)\n end",
"def is_self_audit?\n self.audit_state == SELF_AUDIT\n end",
"def is_peer_auditor?(user)\n (self.design.peer_id == user.id ||\n self.audit_teammates.detect { |t| t.user_id == user.id && !t.self? })\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is_peer_auditor? Description: This method determines if the user is a peer auditor. Parameters: user A User record for the person this method is checking to if the person is on the peer audit team. Return value: TRUE if the user is on the peer audit team, FALSE otherwise. | def is_peer_auditor?(user)
(self.design.peer_id == user.id ||
self.audit_teammates.detect { |t| t.user_id == user.id && !t.self? })
end | [
"def peer_update?(user)\n self.is_peer_audit? && self.is_peer_auditor?(user)\n end",
"def is_peer_audit?\n self.audit_state == PEER_AUDIT\n end",
"def is_self_auditor?(user)\n (self.design.designer_id == user.id ||\n self.audit_teammates.detect { |t| t.user_id == user.id && t.self? })\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create_checklist Description: This method creates a new checklist at the kick off of a Peer Audit Revew. Parameters: None | def create_checklist
self.checklist.each_check do |check|
DesignCheck.add(self, check) if check.belongs_to?(self.design)
end
end | [
"def create_new_checklist(name)\n client.post(\"/cards/#{id}/checklists\", { name: name })\n end",
"def create\n @checklist = Checklist.new(params[:checklist])\n\n respond_to do |format|\n if @checklist.save\n flash[:notice] = 'Checklist was successfully created.'\n format.html { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update_checklist_type Description: This method creates or destroys design checks based on the type of design the audit is tied to. This is used when the type of design is changed. Parameters: None Returns: The number of design checks added or deleted. | def update_checklist_type
design_checks = DesignCheck.find(:all, :conditions => "audit_id=#{self.id}")
delta = 0
# Keep track of the completed checks that are deleted to update the
# audit counts of the completed checks.
completed_self_check_delta = 0
completed_peer_audit_delta = 0
sel... | [
"def flip_design_type\n \n self.design_type = self.design_type == 'New' ? 'Dot Rev' : 'New'\n self.save\n \n self.audit.update_checklist_type\n \n end",
"def increment_checklist_counters(checklist, increment)\n\n checklist = [checklist] if checklist.class == Check\n\n checklist.each do |c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check_count Description: This method returns the number of checks for the designer and the peer based on the design type. Parameters: None | def check_count
count = { :designer => 0, :peer => 0 }
checklist = self.checklist
case self.design.design_type
when 'New'
count[:designer] = checklist.new_design_self_check_count
count[:peer] = checklist.new_design_peer_check_count
when 'Dot Rev'
count[:designer] = checkl... | [
"def peer_check_count\n \n checklist = self.checklist\n\n case self.design.design_type\n when 'New'\n checklist.new_design_peer_check_count\n when 'Dot Rev'\n checklist.bareboard_design_peer_check_count\n end\n\n end",
"def designer_auditor_check_count\n \n total = 0\n self.che... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
peer_check_count Description: This method returns the number of checks for the peer audit team based on the design type. Parameters: None | def peer_check_count
checklist = self.checklist
case self.design.design_type
when 'New'
checklist.new_design_peer_check_count
when 'Dot Rev'
checklist.bareboard_design_peer_check_count
end
end | [
"def partial_review_peer_check_count\n check_count = 0\n self.sections.each do |s|\n next if !s.dot_rev_check?\n s.subsections.each do |ss|\n next if !ss.dot_rev_check?\n ss.checks.each { |c| check_count += 1 if c.bare_board_design_check? && c.is_peer_check? }\n end\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
peer_percent_complete Description: This method returns percent complete statistics for the peer audit team. Parameters: None | def peer_percent_complete
if !self.peer_check_count.blank?
if self.auditor_completed_checks <= self.peer_check_count
self.auditor_completed_checks * 100.0 / self.peer_check_count
else
100.0
end
else
0
end
end | [
"def completed_peer_design_checks_percentage\n (self.completed_peer_design_checks * 100.0) / self.checks.size\n end",
"def percent_complete\n return @percent_complete\n end",
"def percentage_complete\n return @percentage_complete\n end",
"def percent_com... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
self_check_count Description: This method returns the number of checks for the self audit team based on the design type. Parameters: None | def self_check_count
checklist = self.checklist
case self.design.design_type
when 'New'
checklist.new_design_self_check_count
when 'Dot Rev'
checklist.bareboard_design_self_check_count
end
end | [
"def full_review_self_check_count\n check_count = 0\n self.sections.each do |s|\n next if !s.full_review?\n s.subsections.each do |ss|\n next if !ss.full_review?\n ss.checks.each { |c| check_count += 1 if c.new_design_check? && c.is_self_check? }\n end\n end\n check_count\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
self_percent_complete Description: This method returns percent complete statistics for the self audit team. Parameters: None | def self_percent_complete
if !self.self_check_count.blank?
if self.designer_completed_checks <= self.self_check_count
self.designer_completed_checks * 100.0 / self.self_check_count
else
100.0
end
else
0
end
end | [
"def percent_complete\n return @percent_complete\n end",
"def completed_self_design_checks_percentage\n (self.completed_self_design_checks * 100.0) / self.checks.size\n end",
"def percent_complete\n self.completeness_score.to_f / self.class.max_completeness_score.to_f * 100... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
completion_stats Description: This method returns percent complete statistics for the self and peer audit. Parameters: None | def completion_stats
stats = { :self => "0.0", :peer => "0.0" }
total_checks = self.check_count
if total_checks[:designer] > 0
stats[:self] = self.designer_completed_checks * 100.0 / total_checks[:designer]
end
if total_checks[:peer] > 0
stats[:peer] = self.auditor_completed_chec... | [
"def completion_percentage\n return @completion_percentage\n end",
"def profile_completion\n percentage = 0\n percentage += 25 if self.full_name.present?\n percentage += 25 if self.has_avatar? and self.city\n percentage += 25 if self.subjects.any?\n percentage += 25 if sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
completed_self_audit_check_count Description: This method provides the number of self audit design checks that have been completed for the subsection. Parameters: subsection the subsection record that is used to group the design checks. | def completed_self_audit_check_count(subsection)
design_checks = []
self.design_checks.each { |dc| design_checks << dc if dc.self_auditor_checked? }
design_checks.delete_if do |dc|
check = Check.find(dc.check_id)
!subsection.checks.include?(check)
end
design_checks.size
end | [
"def completed_peer_audit_check_count(subsection)\n\n design_checks = []\n self.design_checks.each { |dc| design_checks << dc if dc.peer_auditor_checked? }\n design_checks.delete_if do |dc| \n check = Check.find(dc.check_id)\n !subsection.checks.include?(check) \n end\n\n design_checks.size... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
completed_check_count Description: Returns the number of design checks that are completed for both the self and peer audit. Parameters: None | def completed_check_count
count = { :self => 0, :peer => 0 }
self.checklist.each_check do |check|
design_check = self.design_checks.detect { |dc| dc.check_id == check.id }
next if !design_check
count[:self] += 1 if design_check.self_auditor_checked?
count[:peer] += 1 if design_... | [
"def completed_peer_design_checks\n completed_checks = 0\n self.checks.each do |check| \n completed_checks += 1 if check.design_check.peer_auditor_checked?\n end\n completed_checks\n end",
"def completed_self_design_checks\n completed_checks = 0\n self.checks.each do |check| \n comple... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
completed_peer_audit_check_count Description: This method provides the number of peer audit design checks that have been completed for the subsection. Parameters: subsection the subsection record that is used to group the design checks. | def completed_peer_audit_check_count(subsection)
design_checks = []
self.design_checks.each { |dc| design_checks << dc if dc.peer_auditor_checked? }
design_checks.delete_if do |dc|
check = Check.find(dc.check_id)
!subsection.checks.include?(check)
end
design_checks.size
end | [
"def completed_self_audit_check_count(subsection)\n\n design_checks = []\n self.design_checks.each { |dc| design_checks << dc if dc.self_auditor_checked? }\n design_checks.delete_if do |dc| \n check = Check.find(dc.check_id)\n !subsection.checks.include?(check)\n end\n\n design_checks.size\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
user_complete?(user) Description: Checks to see if the logged in user has finished all assigned checks Parameters: user a user record that identifies the person who is logged in. Return value: true if user has finished all checks | def completed_user?(user)
incomplete = false;
self.design_checks.each do | dsn_chk |
section = dsn_chk.check.section
if ( self.is_self_audit? && dsn_chk.designer_result == "None" )
auditor = self.audit_teammates.detect { |tmate|
tmate.section_id == section.id && tmate.self? }... | [
"def check_if_completed(user)\n\n \tlogger.info(\"Checking completion for workout \" + id.to_s + \" by user \" + user.name.to_s)\n\n \tif complete?(user) # If a CompletedWorkout exists already, no further action\n \t\tlogger.info(\"Already completed\")\n \t\treturn false\n elsif self.workout_exercises.map {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get_section_teammate Description: Retrieves the teammate for the audit section. Parameters: section a record that identifies the section Return value: A user record for the teammate, if one exists. Otherwise a nil is returned. | def get_section_teammate(section)
teammate = self.audit_teammates.detect do |at|
at.section_id == section.id && at.self == (self.is_self_audit? ? 1 : 0)
end
# If a teammate was located, return the user record.
teammate ? teammate.user : nil
end | [
"def auditor_name(section_id, teammate_list, lead)\n teammate = teammate_list.detect { |tmate| tmate.section_id == section_id }\n if teammate\n teammate.user.name\n else\n lead.name\n end\n end",
"def peer_auditor(section)\n \n auditor = self.audit_teammates.detect { |tmate| tmate.sec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
section_auditor? Description: Indicates that the user can perform the audit for the audit section. Parameters: section a record that identifies the section user a record that identifies the user Return value: TRUE the user can perform the audit for the section FALSE the user can not perform the audit for the section | def section_auditor?(section, user)
teammate = self.get_section_teammate(section)
if self.is_self_audit?
((!teammate && user.id == self.design.designer_id) || ( teammate && user == teammate))
else
(!self.is_complete? &&
((!teammate && user.id == self.design.peer_id) || ( teammate && use... | [
"def self_auditor(section)\n \n auditor = self.audit_teammates.detect { |tmate| tmate.section_id == section.id && tmate.self? }\n\n if auditor\n auditor.user\n elsif self.design.designer_id > 0 \n self.design.designer\n else\n nil\n end\n \n end",
"def peer_auditor(section)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
filtered_checklist Description: The method will removed sections and subsections based on whether the audit is a full, date code, or dot rev audit Parameters: user a user record that identifies the person who is logged in. Return value: The audit's checklist will be modified as described above. | def filtered_checklist(user)
sections = self.checklist.sections
if self.design.date_code?
sections.delete_if { |sec| !sec.date_code_check? }
sections.each do |section|
section.subsections.delete_if { |subsec| !subsec.date_code_check? }
end
elsif self.design.dot_rev?
sec... | [
"def trim_checklist_for_design_type\n \n design = self.design\n \n # Remove the sections that are not used in the audit.\n self.checklist.sections.delete_if { |section| !design.belongs_to(section) }\n \n self.checklist.sections.each do |section|\n \n # Remove the subsections that ar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update_type Description: The method returns the update type based on the user and the state of the audit (self audit vs. peer audit). Parameters: user a user record that identifies the person who is logged in. Return value: A string that indicates the state of audit self, peer, or none | def update_type(user)
if (self.is_self_auditor?(user) && self.is_self_audit?)
:self
elsif (self.is_peer_auditor?(user) && self.is_peer_audit?)
:peer
else
:none
end
end | [
"def update_user_type(options={})\r\n unless options[:stub].blank? # stub type\r\n options[:stub] = User::Types::Undergrad unless User::Types::All.include?(options[:stub].to_i)\r\n self.user_type = options[:stub].to_i\r\n else # update via LDAP\r\n person = self.ldap_person\r\n case #... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
self_update? Description: The method determines if the update that is being processed is a self audit update. Parameters: user a user record that identifies the person who is logged in. Return value: True if the update is to the self audit. Otherwise, false | def self_update?(user)
self.is_self_audit? && self.is_self_auditor?(user)
end | [
"def is_self_audit?\n self.audit_state == SELF_AUDIT\n end",
"def is_self_auditor?(user)\n (self.design.designer_id == user.id ||\n self.audit_teammates.detect { |t| t.user_id == user.id && t.self? })\n end",
"def peer_update?(user)\n self.is_peer_audit? && self.is_peer_auditor?(user)\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
peer_update? Description: The method determines if the update that is being processed is a peer audit update. Parameters: user a user record that identifies the person who is logged in. Return value: True if the update is to the peer audit. Otherwise, false | def peer_update?(user)
self.is_peer_audit? && self.is_peer_auditor?(user)
end | [
"def is_peer_auditor?(user)\n (self.design.peer_id == user.id ||\n self.audit_teammates.detect { |t| t.user_id == user.id && !t.self? })\n end",
"def is_peer_audit?\n self.audit_state == PEER_AUDIT\n end",
"def updated?(user)\n read_by?(user) && !latest_update_read_by?(user)\n end",
"def s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process_self_audit_update Description: The method processes self audit input. If the result is anything than "None" then the designer completed checks is incremented and the design_check.designer_result is updated with the new result. If the self audit is complete then email is sent indicating that the self audit is co... | def process_self_audit_update(result_update, design_check, user)
if design_check.designer_result == "None"
self.update_self_check_count
if self.designer_complete?
AuditMailer.self_audit_complete(self).deliver
AuditMailer.final_review_warning(self.design).deliver
end
... | [
"def process_peer_audit_update(result_update, comment, design_check, user)\n\n check = Check.find(design_check.check_id)\n return if check.check_type != 'designer_auditor'\n\n incr = design_check.update_auditor_result(result_update, user)\n\n if incr != 0\n self.update_peer_check_count(incr)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process_peer_audit_update Description: The method processes peer audit input. If the result is anything than "None" or "Comment then the auditor completed checks is incremented and the design_check.auditor_result is updated with the new result. If the peer audit is complete then email is sent indicating that the peer a... | def process_peer_audit_update(result_update, comment, design_check, user)
check = Check.find(design_check.check_id)
return if check.check_type != 'designer_auditor'
incr = design_check.update_auditor_result(result_update, user)
if incr != 0
self.update_peer_check_count(incr)
AuditMailer.p... | [
"def process_self_audit_update(result_update, design_check, user)\n\n if design_check.designer_result == \"None\"\n\n self.update_self_check_count\n \n if self.designer_complete?\n AuditMailer.self_audit_complete(self).deliver\n AuditMailer.final_review_warning(self.design).deliver\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
manage_auditor_list Description: The method processes updates to the audit team. Audit Teammate records are added and removed from the database based on the user's input. Parameters: self_auditor_list a hash of self audit assignments. The hash is accessed by section ids (key) to provide the user of id of the self audit... | def manage_auditor_list(self_auditor_list, peer_auditor_list, user)
lead_designer_assignments = {}
self_auditor_list.each do |key, auditor|
lead_designer_assignments[key] = (self.design.designer_id == auditor.to_i)
end
lead_peer_assignments = {}
peer_auditor_list.each do |key, auditor|
... | [
"def update_auditor_list\n \n audit = Audit.find(params[:audit][:id])\n \n self_auditor_list = {}\n params[:self_auditor].each do |section_id_string, self_auditor|\n section_id = section_id_string.split('_')[2].to_i\n self_auditor_list[section_id] = self_auditor\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process_design_checks Description: Processes a list of design check updates. Processing is done for both the self and peer updates. Parameters: design_check_list a list of self or peer design check updates user the record for the user making the update Return value: None | def process_design_checks(design_check_list, user)
# Go through the paramater list and pull out the checks.
design_check_list.each { |design_check_update|
design_check = DesignCheck.find(design_check_update[:design_check_id])
if self.self_update?(user)
result = design_check.designe... | [
"def update_design_check(design_check_update, user)\n\n self.errors.clear\n \n self_audit_result = design_check_update[:designer_result]\n peer_audit_result = design_check_update[:auditor_result]\n\n updated = false\n design_check = DesignCheck.find(design_check_update[:design_check_id])\n if s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
clear_message Description: The method clears all of the error messages Parameters: None Return value: None | def clear_message
errors.clear
end | [
"def clear_error_message\n self[:error_message] = nil\n end",
"def clear_error\n if @error\n @error = false\n do_default_text\n end\n end",
"def clear_messages\n @message_list.clear\n end",
"def clear!\n @errors.clear\n end",
"def clear\n @errors.cle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
message? Description: The method indicates if there is an error message available for the object Parameters: None Return value: True if an error message exists. Otherwise False | def message?
#errors.on(:message) != nil
errors[:message] != nil
end | [
"def error_message?\n true if message[:error]\n end",
"def has_error_message?(text)\n has_message?(:error, text)\n end",
"def error\n valid? ? nil : @error_message\n end",
"def has_description?\n !error.description.to_s.empty?\n end",
"def may_have_messages?; true; en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set_message Description: Creates or appends the message to the error message depending on the append flag Parameters: append a flag that indicates the message should be appended to any existing error message when True Return value: None | def set_message(message, append=false)
errors.clear if !append
errors.add(:message, message)
end | [
"def set_error_message(msg)\n if self[:error_message]\n self[:error_message] += \"\\n\" + msg\n else\n self[:error_message] = msg\n end\n end",
"def add_error( message )\n add_to_message_list :error, message;\n end",
"def error_message=(value)\n @error_message = valu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update_self_check_count Description: Increments the designer (self) completed check count by count. If the caller does not specify the count then the increment is by 1. If another user has updated the record, the exception handler code is executed. The audit record is reloaded and the work is redone. Parameters: count ... | def update_self_check_count(count = 1)
begin
completed_checks = self.designer_completed_checks + count
self.designer_completed_checks = completed_checks
self.designer_complete = (completed_checks == self.self_check_count)
self.save
rescue ActiveRecord::StaleObjectError
self... | [
"def update_peer_check_count(count = 1)\n begin\n completed_checks = self.auditor_completed_checks + count\n self.auditor_completed_checks = completed_checks\n self.auditor_complete = (completed_checks == self.peer_check_count)\n self.save\n rescue ActiveRecord::StaleObjectError\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update_peer_check_count Description: Increments the auditor (peer) completed check count by count. If the caller does not specify the count then the increment is by 1. If another user has updated the record, the exception handler code is executed. The audit record is reloaded and the work is redone. Parameters: count p... | def update_peer_check_count(count = 1)
begin
completed_checks = self.auditor_completed_checks + count
self.auditor_completed_checks = completed_checks
self.auditor_complete = (completed_checks == self.peer_check_count)
self.save
rescue ActiveRecord::StaleObjectError
self.re... | [
"def update_self_check_count(count = 1)\n begin\n completed_checks = self.designer_completed_checks + count\n self.designer_completed_checks = completed_checks\n self.designer_complete = (completed_checks == self.self_check_count)\n self.save\n rescue ActiveRecord::StaleObjectError... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a list of designers eligible to perform a self audit. :callseq: self_audtor_list() > array The array returned contains a list of active designers. | def self_auditor_list
@self_auditor_list ||= Role.active_designers
end | [
"def current_officers\n officers.select { |x| x.current? }\n end",
"def peer_auditor_list\n @peer_auditor_list ||= (self.self_auditor_list - [self.design.designer])\n end",
"def designs_on_subject_event(current_user)\n current_user.all_viewable_designs.where(id: required_design_ids)\n end",
"def p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a list of designers eligible to perform a peer audit. :callseq: peer_audtor_list() > array The array returned contains a list of active designers with the record for the lead designer removed. | def peer_auditor_list
@peer_auditor_list ||= (self.self_auditor_list - [self.design.designer])
end | [
"def self_auditor_list\n @self_auditor_list ||= Role.active_designers\n end",
"def manage_auditor_list(self_auditor_list, peer_auditor_list, user)\n\n lead_designer_assignments = {}\n self_auditor_list.each do |key, auditor|\n lead_designer_assignments[key] = (self.design.designer_id == auditor.to_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Locate and remove any orphaned design checks associated with the audit :callseq: orphaned_design_checks Find all design checks that were incorrectly created and processed and remove them from the database. The design checks were created due to a bug that existed that blindly created design checks new designs. The progr... | def orphaned_design_checks
log = []
total_design_checks = self.design_checks.size
self.trim_checklist_for_design_type
self.get_design_checks
completed_check_counts = self.completed_check_count
attached_design_checks = []
self.checklist.each_check { |ch| attached_design_ch... | [
"def clear_all_checks\n \n self.trim_checklist_for_design_type\n \n self.design_checks.each do | design_check |\n design_check.auditor_result = 'None' #if design_check.check.is_peer_check?\n design_check.designer_result = 'None' #if design_check.check.is_self_check?\n design_check.save\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Trim sections, subsections, and checks from the audit that do not apply. :callseq: trim_checklist_for_design_type() > audit The resulting audit checklist contains only the sections, subsection, and checks that apply to the audit. | def trim_checklist_for_design_type
design = self.design
# Remove the sections that are not used in the audit.
self.checklist.sections.delete_if { |section| !design.belongs_to(section) }
self.checklist.sections.each do |section|
# Remove the subsections that are not used in ... | [
"def trim_checklist_for_self_audit\n \n self.trim_checklist_for_design_type\n self.checklist.sections.each do |section|\n section.subsections.each do |subsection|\n subsection.checks.delete_if { |check| !check.is_self_check? }\n end\n end\n \n # Lop off any empty sections and subsections... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Trim checks that do no apply to a self audit. :callseq: trim_checklist_for_self_audit() > audit The resulting audit checklist contains only the checks that apply to a self audit. | def trim_checklist_for_self_audit
self.trim_checklist_for_design_type
self.checklist.sections.each do |section|
section.subsections.each do |subsection|
subsection.checks.delete_if { |check| !check.is_self_check? }
end
end
# Lop off any empty sections and subsections
self.check... | [
"def trim_checklist_for_peer_audit\n \n self.trim_checklist_for_design_type\n \n self.checklist.sections.each do |section|\n section.subsections.each do |subsection|\n subsection.checks.delete_if { |check| !check.is_peer_check? }\n end\n end\n \n # Lop off any empty sections and... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Trim checks that do no apply to a peer audit. :callseq: trim_checklist_for_peer_audit() > audit The resulting audit checklist contains only the checks that apply to a peer audit. | def trim_checklist_for_peer_audit
self.trim_checklist_for_design_type
self.checklist.sections.each do |section|
section.subsections.each do |subsection|
subsection.checks.delete_if { |check| !check.is_peer_check? }
end
end
# Lop off any empty sections and subsections
... | [
"def get_checks(auditor_type, audit_type = :full)\n\n checks = self.checks\n \n # Self auditors perform all of the checks.\n # If performing a peer audit (retreiving peer checks) delete any check that\n # is not performed by a peer auditor.\n checks.delete_if { |c| !c.is_peer_check? } if auditor_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve and load the associated design checks :callseq: get_design_checks() > audit Go through all of the checks in the check list and attach the associated design checks. | def get_design_checks
design_checks = self.design_checks # DesignCheck.find(:all, :conditions => "audit_id=#{self.id}")
self.checklist.each_check do |check|
design_check = design_checks.detect { |dc| dc.check_id == check.id }
check.design_check = design_check if design_check
end
... | [
"def perform_checks\n\n @audit = Audit.find(params[:audit_id])\n @total_checks = @audit.check_count\n\n if @audit.is_self_audit?\n @audit.trim_checklist_for_self_audit\n else\n @audit.trim_checklist_for_peer_audit\n end\n @design_checks = @audit.design_checks\n\n # Locate the s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve the self auditor for the section. :callseq: self_audtor(section) > user If a self auditor for the section is assigned then the user record is returned. Otherwise the user record for the design's lead designer is returned. A nil is returned if none of the above conditions apply. | def self_auditor(section)
auditor = self.audit_teammates.detect { |tmate| tmate.section_id == section.id && tmate.self? }
if auditor
auditor.user
elsif self.design.designer_id > 0
self.design.designer
else
nil
end
end | [
"def peer_auditor(section)\n \n auditor = self.audit_teammates.detect { |tmate| tmate.section_id == section.id && !tmate.self? }\n\n if auditor \n return auditor.user\n elsif self.design.peer_id > 0\n return self.design.peer\n else\n nil\n end\n \n end",
"def is_self_auditor?(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve the peer auditor for the section. :callseq: peer_audtor(section) > user If a peer auditor for the section is assigned then the user record is returned. Otherwise the user record for the design's lead peer auditor is returned. A nil is returned if none of the above conditions apply. | def peer_auditor(section)
auditor = self.audit_teammates.detect { |tmate| tmate.section_id == section.id && !tmate.self? }
if auditor
return auditor.user
elsif self.design.peer_id > 0
return self.design.peer
else
nil
end
end | [
"def self_auditor(section)\n \n auditor = self.audit_teammates.detect { |tmate| tmate.section_id == section.id && tmate.self? }\n\n if auditor\n auditor.user\n elsif self.design.designer_id > 0 \n self.design.designer\n else\n nil\n end\n \n end",
"def peer_auditor\n if sel... | {
"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.