query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Checks if the type of the field is `TIMESTAMP`. | def timestamp?
type == "TIMESTAMP"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_timestamp(timestamp)\n fail ArgumentError, 'Timestamp must be a Time' unless timestamp.is_a? Time\n end",
"def check_timestamp!(timestamp)\n fail ArgumentError, 'Timestamp must be a Time' unless timestamp.is_a? Time\n end",
"def datetime?\n type == \"DATETIME\"\n ... | [
"0.70083463",
"0.69439775",
"0.67441046",
"0.67128104",
"0.67067975",
"0.6548675",
"0.6139999",
"0.613817",
"0.6133439",
"0.6036024",
"0.6018841",
"0.6016524",
"0.5987084",
"0.59496635",
"0.590741",
"0.5900461",
"0.5894694",
"0.5881744",
"0.5848368",
"0.5846171",
"0.58445066"... | 0.8122504 | 0 |
Checks if the type of the field is `TIME`. | def time?
type == "TIME"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_value?(input)\n return input.is_a?(Time) || input.is_a?(Date)\n end",
"def valid_time_or_date?(value)\n value.is_a?(Time) || value.is_a?(Date) || value.is_a?(ActiveSupport::TimeWithZone)\n end",
"def is_time_unit?\n self.is_numeric? && TIME_UNITS.include?(self.unit)\n end",
"def ... | [
"0.75910455",
"0.71092737",
"0.6954289",
"0.69318175",
"0.69092184",
"0.6798967",
"0.67504483",
"0.6715974",
"0.6713501",
"0.6647548",
"0.6590515",
"0.6581413",
"0.64501256",
"0.6442437",
"0.6401007",
"0.6358342",
"0.6355443",
"0.63516265",
"0.63376915",
"0.6305664",
"0.62841... | 0.8383756 | 0 |
Checks if the type of the field is `DATETIME`. | def datetime?
type == "DATETIME"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_validations_for_datetime\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time or DateTime\") if value && (! value.kind_of?(Time)) && (value.class.name != 'DateTime')\n end\n end",
"def is_valid?\n is_valid_datet... | [
"0.7253279",
"0.7066005",
"0.695279",
"0.6949436",
"0.69007933",
"0.67179453",
"0.6636011",
"0.66234845",
"0.6473741",
"0.639751",
"0.6379868",
"0.6309361",
"0.6288109",
"0.62505186",
"0.6227763",
"0.62239206",
"0.6209907",
"0.6202373",
"0.60372734",
"0.59958756",
"0.5961784"... | 0.84741426 | 0 |
Checks if the type of the field is `DATE`. | def date?
type == "DATE"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def looks_like_date?(value)\n value.is_a?(Date) || value.is_a?(Time)\n end",
"def can_be_date?\n raise NoMethodError, \"This method is no longer supported.\"\n end",
"def has_date?\n !fields.select { |f| f.responsible_for?('Date') }.empty?\n end",
"def validate_date_attribute(date_typ... | [
"0.76774865",
"0.74911207",
"0.74447596",
"0.7014848",
"0.6945377",
"0.6918824",
"0.6865966",
"0.6765849",
"0.6597502",
"0.6591865",
"0.65790087",
"0.652027",
"0.65072876",
"0.648048",
"0.6462714",
"0.64104706",
"0.6385692",
"0.6359112",
"0.631448",
"0.628149",
"0.6255187",
... | 0.8253281 | 0 |
Checks if the type of the field is `GEOGRAPHY`. | def geography?
type == "GEOGRAPHY"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geo_object\n begin\n if r = geo_object_type # rubocop:disable Lint/AssignmentInCondition\n send(r)\n else\n false\n end\n rescue RGeo::Error::InvalidGeometry\n return nil # TODO: we need to render proper error for this!\n end\n end",
"def is_xy?(); @type == GRT_XY;... | [
"0.6524741",
"0.6107748",
"0.6041386",
"0.60261095",
"0.59719145",
"0.59719145",
"0.59719145",
"0.5869683",
"0.5709475",
"0.5698675",
"0.5697295",
"0.56849015",
"0.56849015",
"0.5669533",
"0.55479497",
"0.54863834",
"0.54706085",
"0.5457221",
"0.5456846",
"0.5456844",
"0.5406... | 0.75620186 | 0 |
Checks if the type of the field is `RECORD`. | def record?
type == "RECORD" || type == "STRUCT"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expect_record name, value\n expect_type name, value, \"Record\", lambda{ value.is_a?(Record) }\n end",
"def record?\n type.record?\n end",
"def uses_record_type?\n list_class.attribute_names.include?('record_type')\n end",
"def record_with_type?(record)\n record.i... | [
"0.6796277",
"0.6785496",
"0.66050035",
"0.65891266",
"0.6562007",
"0.6303785",
"0.613521",
"0.61300427",
"0.6009332",
"0.6004249",
"0.5814604",
"0.56702024",
"0.5624154",
"0.56034684",
"0.554095",
"0.54789495",
"0.54681534",
"0.5450118",
"0.5432151",
"0.5392479",
"0.53802425... | 0.7889294 | 0 |
The nested fields if the type property is set to `RECORD`. Will be empty otherwise. | def fields
if frozen?
Array(@gapi.fields).map { |f| Field.from_gapi(f).freeze }.freeze
else
Array(@gapi.fields).map { |f| Field.from_gapi f }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields\n return @fields if defined?(@fields)\n\n @fields = array_of_items_for(Fields, :fields)\n end",
"def nested_object_fields\n @nested_object_fields\n end",
"def fields\n self.class.fields(true)\n end",
"def all_fields\n found_fields = Array.new\n self.fields.each... | [
"0.678552",
"0.67693776",
"0.66834253",
"0.66683996",
"0.66116625",
"0.65870357",
"0.65228474",
"0.65189856",
"0.65189856",
"0.65007037",
"0.64862615",
"0.6432243",
"0.6428611",
"0.64037454",
"0.63619715",
"0.6358757",
"0.6348525",
"0.6348525",
"0.6348525",
"0.6348525",
"0.63... | 0.56081444 | 83 |
The names of the nested fields as symbols if the type property is set to `RECORD`. Will be empty otherwise. | def headers
fields.map(&:name).map(&:to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields\n klass.members.map(&:to_sym)\n end",
"def fields\n properties.keys.map(&:to_sym)\n end",
"def fields\n properties.keys.map(&:to_sym)\n end",
"def fields\n @field_labels.collect { |k, v| { sym: k, name: v } }\n end",
"def field_names\n internal_form... | [
"0.704944",
"0.69432807",
"0.69432807",
"0.68852913",
"0.68282706",
"0.6805112",
"0.67131704",
"0.65895027",
"0.65304536",
"0.65304536",
"0.6509964",
"0.65070677",
"0.63958687",
"0.6316637",
"0.6244989",
"0.6173241",
"0.6169892",
"0.6114155",
"0.61100876",
"0.6095985",
"0.608... | 0.5702627 | 53 |
The types of the field, using the same format as the optional query parameter types. The parameter types are one of the following BigQuery type codes: `:BOOL` `:INT64` `:FLOAT64` `:NUMERIC` `:BIGNUMERIC` `:STRING` `:DATETIME` `:DATE` `:TIMESTAMP` `:TIME` `:BYTES` `Array` Lists are specified by providing the type code in an array. For example, an array of integers are specified as `[:INT64]`. `Hash` Types for STRUCT values (`Hash` objects) are specified using a `Hash` object, where the keys are the nested field names, and the values are the the nested field types. | def param_type
param_type = type.to_sym
param_type = fields.to_h { |field| [field.name.to_sym, field.param_type] } if record?
param_type = [param_type] if repeated?
param_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def types\n @types ||= {\n String => GraphQL::STRING_TYPE,\n\n Fixnum => GraphQL::INT_TYPE,\n Integer => GraphQL::INT_TYPE,\n Float => GraphQL::FLOAT_TYPE,\n\n Date => GraphQL::STRING_TYPE,\n Time => GraphQL::STRING_TYPE,\n DateTime => GraphQL::... | [
"0.6660835",
"0.64402235",
"0.6266272",
"0.59910387",
"0.58440995",
"0.5803015",
"0.5777114",
"0.5774889",
"0.5740401",
"0.57320464",
"0.57033545",
"0.5646276",
"0.56369185",
"0.56158304",
"0.56158304",
"0.56158304",
"0.56158304",
"0.56158304",
"0.5610856",
"0.5563489",
"0.55... | 0.6213474 | 3 |
Retrieve a nested field by name, if the type property is set to `RECORD`. Will return `nil` otherwise. | def field name
f = fields.find { |fld| fld.name == name.to_s }
return nil if f.nil?
yield f if block_given?
f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_by_name(name)\n self.class.get_field_by_name(name)\n end",
"def get_field_by_name(name)\n self.class.get_field_by_name(name)\n end",
"def get_field(field_name)\n fields = @data_source['fields']\n \n fields.each do | f |\n if f['name'] == filed_name\n return f\... | [
"0.66709703",
"0.66709703",
"0.6649633",
"0.6635229",
"0.6610409",
"0.64476484",
"0.6426916",
"0.6404205",
"0.6404205",
"0.63927656",
"0.6294397",
"0.62513715",
"0.6228461",
"0.6213466",
"0.62071985",
"0.6196045",
"0.61749434",
"0.58883244",
"0.58391106",
"0.57854563",
"0.576... | 0.63999707 | 9 |
Adds a string field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
record_check!
add_field name,
:string,
description: description,
mode: mode,
policy_tags: policy_tags,
max_length: max_length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_field(name, type, options={})\n name = name.to_s\n \n # preconditions\n raise InvalidModelField.new(\"Duplicate field name\") if record_fields.key?(name)\n raise InvalidModelField.new(\"Type must be a known yodel field type\") unless valid_type?(type)\n raise InvalidModelField.new(\"Field... | [
"0.5786031",
"0.5729764",
"0.5623608",
"0.56012726",
"0.5588057",
"0.55741584",
"0.55379826",
"0.5454162",
"0.54332656",
"0.5416976",
"0.5416976",
"0.5364636",
"0.53565776",
"0.53413695",
"0.531755",
"0.51861954",
"0.51587254",
"0.5148187",
"0.5145978",
"0.51384264",
"0.51112... | 0.4891323 | 45 |
Adds an integer field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def integer name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :integer, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def declare_integer_field(model, declaration)\n precision = declaration.attributes[:h_precision] || declaration.attributes[:precision] || 0\n declaration.remove_attributes! :h_precision, :precision\n if precision==0\n model.integer_h declaration.name\n else\n model.num... | [
"0.5685745",
"0.56851757",
"0.5654786",
"0.5628772",
"0.5596719",
"0.5501971",
"0.53155404",
"0.5276476",
"0.5261164",
"0.5255116",
"0.5243893",
"0.51886296",
"0.5179827",
"0.5176133",
"0.5176133",
"0.51687646",
"0.5151433",
"0.5139222",
"0.50960225",
"0.5091179",
"0.5085348"... | 0.55988455 | 4 |
Adds a floatingpoint number field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def float name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :float, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hincrbyfloat(key, field, increment)\n node_for(key).hincrbyfloat(key, field, increment)\n end",
"def type_literal_generic_float(column)\n :\"double precision\"\n end",
"def should_be_float?(field_info, field)\n field_info[\"type\"] == \"REAL\"\n end",
"def hincrbyfloat(key, field, inc... | [
"0.590296",
"0.5872035",
"0.57110816",
"0.565843",
"0.565843",
"0.56404763",
"0.55729514",
"0.55633736",
"0.55588853",
"0.55072445",
"0.54634774",
"0.54569006",
"0.5426369",
"0.5411874",
"0.5251561",
"0.52158725",
"0.52158725",
"0.52144057",
"0.52144057",
"0.517576",
"0.51558... | 0.5850331 | 2 |
Adds a boolean field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def boolean name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :boolean, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_boolean_field(field_name)\n\t\tend",
"def record?\n type == \"RECORD\" || type == \"STRUCT\"\n end",
"def type_literal_generic_boolean(column)\n :boolean\n end",
"def attr_set_boolean(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def fiel... | [
"0.5923192",
"0.5616594",
"0.55987525",
"0.5588339",
"0.5562626",
"0.54920614",
"0.54363596",
"0.536065",
"0.5359438",
"0.53562176",
"0.53481424",
"0.5345932",
"0.53389186",
"0.53388315",
"0.53347766",
"0.53011334",
"0.5284964",
"0.5282979",
"0.5282359",
"0.52556163",
"0.5211... | 0.6239906 | 0 |
Adds a bytes field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
record_check!
add_field name,
:bytes,
description: description,
mode: mode,
policy_tags: policy_tags,
max_length: max_length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_field(type, value)# {{{\n t = TLV.new(2,2)\n t.type = type\n t.value = value\n t.length = 4 + value.length\n self.payload += t.encode \n end",
"def add_raw(raw)\n @fields << Field.new(raw)\n self\n end",
"def record=(record)\n self.record_data = Base64.encode64(Marsh... | [
"0.59158766",
"0.56080073",
"0.55081683",
"0.5453812",
"0.5372978",
"0.53194565",
"0.5313502",
"0.52146715",
"0.518387",
"0.5176976",
"0.5137892",
"0.5135207",
"0.512863",
"0.51171196",
"0.50648403",
"0.50606465",
"0.50067043",
"0.49941772",
"0.49736175",
"0.49674642",
"0.496... | 0.5954681 | 0 |
Adds a timestamp field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def timestamp name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :timestamp, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamp_field=(_field_name)\n raise Error, E_TIMESTAMP_FIELD_CONFIG\n end",
"def type_literal_generic_datetime(column)\n :timestamp\n end",
"def append_timestamp(value)\n time = case value\n when Time\n value\n when Date\n value.to_... | [
"0.61602205",
"0.58389205",
"0.57605076",
"0.57245356",
"0.5676347",
"0.5663652",
"0.5568894",
"0.5564433",
"0.556219",
"0.55579257",
"0.5527557",
"0.5512983",
"0.5490998",
"0.5455854",
"0.54368854",
"0.5419557",
"0.5390411",
"0.5357996",
"0.53446263",
"0.5336489",
"0.5306169... | 0.66636753 | 0 |
Adds a time field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def time name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :time, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_field field = nil\n @time_field = field if field\n @time_field\n end",
"def type_literal_generic_only_time(column)\n :time\n end",
"def time_field(object_name, method, options = T.unsafe(nil)); end",
"def type_literal_generic_time(column)\n column[:only_time] ?... | [
"0.67043835",
"0.61925834",
"0.60828453",
"0.6065578",
"0.60606164",
"0.594004",
"0.58431935",
"0.5765489",
"0.57491165",
"0.57446575",
"0.572281",
"0.5712897",
"0.5704962",
"0.56798023",
"0.5677857",
"0.5674365",
"0.566035",
"0.5653106",
"0.56337565",
"0.55973554",
"0.556360... | 0.6748423 | 0 |
Adds a datetime field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def datetime name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :datetime, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime_field(object_name, method, options = T.unsafe(nil)); end",
"def to_doc\n # doc now has all the fields of our model instance, we \n # just add another field to it:\n doc = super\n # add a field containing the current time\n doc[:added] = Time.now.to_i.to_s\n return doc\n end",
"d... | [
"0.5910415",
"0.56748605",
"0.5605256",
"0.5586138",
"0.5501807",
"0.5490748",
"0.54817814",
"0.54065937",
"0.5399331",
"0.534236",
"0.53157085",
"0.5314812",
"0.5298801",
"0.52873474",
"0.52333033",
"0.52229726",
"0.519428",
"0.51758206",
"0.5173208",
"0.51540613",
"0.515311... | 0.6224733 | 0 |
Adds a date field to the nested schema of a record field. This can only be called on fields that are of type `RECORD`. | def date name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :date, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_nested\n self[Solrizer.solr_name('date_nested', :displayable)]\n end",
"def date_field(object_name, method, options = T.unsafe(nil)); end",
"def _build_date_single(date, xml)\n attrs = { localType: date['date_label'] }\n create_node(xml, 'date', attrs, date['structured_date_single']['date_ex... | [
"0.5841291",
"0.562257",
"0.5616748",
"0.55500364",
"0.54208255",
"0.5420433",
"0.5403138",
"0.53960913",
"0.53750974",
"0.531933",
"0.5253915",
"0.52248484",
"0.5169552",
"0.51013654",
"0.5096172",
"0.50791895",
"0.5062106",
"0.50587535",
"0.50331414",
"0.49732295",
"0.49703... | 0.6045377 | 0 |
Adds a geography field to the nested schema of a record field. | def geography name, description: nil, mode: :nullable, policy_tags: nil
record_check!
add_field name, :geography, description: description, mode: mode, policy_tags: policy_tags
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geography(name, options = {})\n column(name, :geography, options)\n end",
"def append_geom( geom, **other_attrs )\n if geom.is_a?(GeoRuby::SimpleFeatures::Geometry)\n geom = RGeo::WKRep::WKBParser.new.parse(geom.as_wkb) rescue nil\n end\n new_geom = geom\n self.place_geometry.rel... | [
"0.62719226",
"0.588863",
"0.5782519",
"0.56411237",
"0.5554195",
"0.55347544",
"0.5418438",
"0.53993815",
"0.53862447",
"0.5324835",
"0.5264566",
"0.52550924",
"0.52292585",
"0.5180059",
"0.516564",
"0.5143548",
"0.514169",
"0.5134572",
"0.5062158",
"0.5061737",
"0.49898568"... | 0.7446773 | 0 |
Adds a record field to the nested schema of a record field. A block must be passed describing the nested fields of the record. For more information about nested and repeated records, see [Preparing Data for BigQuery]( This can only be called on fields that are of type `RECORD`. | def record name, description: nil, mode: nil
record_check!
# TODO: do we need to raise if no block was given?
raise ArgumentError, "a block is required" unless block_given?
nested_field = add_field name, :record, description: description, mode: mode
yield nested_field
nested_field
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields_for(record_name, record_object = T.unsafe(nil), fields_options = T.unsafe(nil), &block); end",
"def semantic_fields_for(record_or_name_or_array, *args, &block)\n fields_for(record_or_name_or_array, *args, &block)\n end",
"def sub_field(named, human_name = nil, &block)\n human_name ||= nam... | [
"0.59745246",
"0.59244794",
"0.59064597",
"0.5882015",
"0.5728995",
"0.55676645",
"0.55551004",
"0.55478865",
"0.5523331",
"0.5452229",
"0.535457",
"0.53500193",
"0.5318665",
"0.53053296",
"0.5280825",
"0.5272067",
"0.52714926",
"0.52476114",
"0.5243147",
"0.5241524",
"0.5202... | 0.6552268 | 0 |
==Execute db migration tasks pdm database migrate up|down|reset PATH/TO/STEP1 PATH/TO/STEP2 task: up/down/reset/backup | def migrate(task, *step_files)
step_files = begin
Dir[File.join(File.dirname(__FILE__),"../../migrate/*.rb")]
end if step_files.empty?
establish! do
step_files.each do |step_file|
require step_file
File.basename(step_file) =~ /(.*)\.rb$/
migration = $1.camelize.constantize
step = migration.new
case task.to_s
when "up"
step.up unless step.migrated?
when "reset"
step.reset if step.migrated?
when "down"
step.down if step.migrated?
when "backup"
step.backup(options) if step.migrated?
else
raise "Unsupported sub command: #{task}"
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrate\n run_migrations pending_migrations, :up\n end",
"def migrate\n with_maintenance do\n backup if backup?\n run_migration\n restart\n end\n end",
"def migrate\n puts 'Migrating DBs on containers'\n puts Open3.capture3(\"pushd #{dot_futureadvisor} 2>&1; ./bin/dev re... | [
"0.7123244",
"0.6536604",
"0.64443934",
"0.640779",
"0.64054996",
"0.6379107",
"0.6359264",
"0.6316476",
"0.6315159",
"0.6297739",
"0.62144125",
"0.61788976",
"0.61778206",
"0.6170276",
"0.61682343",
"0.6162269",
"0.6156761",
"0.61159277",
"0.6076526",
"0.6068247",
"0.6065849... | 0.7597206 | 0 |
==Import analysis result from result file pdm database import ANALYSIS/RESULT | def import(*files)
require "models/user_task"
require "models/log_record"
require "timeout"
establish! do
unless( files.empty? )
files.each do |file|
puts "Loading %s" % file
File.open(file, "r:utf-8") do |stream|
import_from stream
end
end
else
begin
require "stringio"
str = Timeout::timeout(10) {
$stdin.set_encoding("utf-8")
$stdin.read # read as utf-8, ensured by top of this file comments
}
puts "Loading from stdin"
import_from StringIO.new(str,"r:utf-8")
rescue Timeout::Error
raise "You should specify several import file"
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadResult()\n json = nil ;\n file = scannedResultFilename() ;\n open(file,\"r\"){|strm|\n json = JSON.load(strm.read()) ;\n }\n\n json.each{|result|\n analyzer = AnalyzerExpA.new(@logBaseDir, nil) ;\n analyzer.scanResultJson(result) ;\n basename = analyzer.basename ;\n ... | [
"0.6698966",
"0.58360744",
"0.58332217",
"0.5769422",
"0.56747824",
"0.56346846",
"0.56202394",
"0.5610332",
"0.5585038",
"0.55586696",
"0.5529023",
"0.5504612",
"0.54733765",
"0.54568714",
"0.5454552",
"0.54086775",
"0.5393493",
"0.53922594",
"0.53881264",
"0.5352325",
"0.53... | 0.0 | -1 |
==Validate some tables pdm database validate user_tasks c "count(0) == 500" c "avg(cost) 10" | def validate(table)
establish! do
options[:conditions].each do |cond|
validate! table, cond
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_workflow\n e = 0\n status_usage = Array.new( flow_list.count, 0 )\n obsolete_use = Array.new( flow_list.count, 0 )\n @flow_list.each_with_index do |f,i|\n # count usage\n if f.status_id < 0 or f.status_id >= status_usage.count then\n puts \" status_id outside range: (0,#{... | [
"0.5699543",
"0.56384903",
"0.56208664",
"0.5521189",
"0.5519152",
"0.54761326",
"0.5417944",
"0.5401705",
"0.53787327",
"0.53584105",
"0.5356623",
"0.53564924",
"0.53563327",
"0.534639",
"0.5328587",
"0.5328587",
"0.5310493",
"0.52994883",
"0.5291515",
"0.52669436",
"0.52313... | 0.49331856 | 51 |
GET /music_discs GET /music_discs.json | def index
@music_discs = MusicDisc.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @music = Music.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @music }\n end\n end",
"def index\n @musics = Music.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mus... | [
"0.66433537",
"0.66346246",
"0.6624503",
"0.65975785",
"0.6589996",
"0.6425613",
"0.6425613",
"0.6425613",
"0.6425613",
"0.63963896",
"0.6370514",
"0.6312383",
"0.62550277",
"0.62399554",
"0.61923176",
"0.6153997",
"0.6124523",
"0.61007077",
"0.6087293",
"0.60776764",
"0.6077... | 0.7271684 | 0 |
GET /music_discs/1 GET /music_discs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @music = Music.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @music }\n end\n end",
"def show\n @music = Music.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render... | [
"0.7170608",
"0.7126237",
"0.7124327",
"0.6898038",
"0.68556786",
"0.68189317",
"0.68025374",
"0.6752313",
"0.6698238",
"0.6689691",
"0.6612132",
"0.6558259",
"0.65356135",
"0.65115935",
"0.6469099",
"0.6469099",
"0.6469099",
"0.6469099",
"0.6455372",
"0.64298964",
"0.6392665... | 0.0 | -1 |
POST /music_discs POST /music_discs.json | def create
@music_disc = MusicDisc.new(music_disc_params)
@music_disc.user = current_user
respond_to do |format|
if @music_disc.save
format.html { redirect_to @music_disc }
format.json { render :show, status: :created, location: @music_disc }
else
format.html { render :new }
format.json { render json: @music_disc.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def music_disc_params\n params.require(:music_disc).permit(:title, :discography, :group_name, { music_category_ids: []}, :image)\n end",
"def create\n @music = Music.new(params[:music])\n\n respond_to do |format|\n if @music.save\n format.html { redirect_to \"/musics\", notice: 'Music w... | [
"0.6636835",
"0.6348932",
"0.6282617",
"0.6282617",
"0.6168037",
"0.6168037",
"0.6167091",
"0.61183494",
"0.6093184",
"0.60146844",
"0.5986225",
"0.59618896",
"0.5864717",
"0.5846669",
"0.58346194",
"0.5820219",
"0.58141947",
"0.58125854",
"0.5804949",
"0.5793953",
"0.5793888... | 0.65569896 | 1 |
PATCH/PUT /music_discs/1 PATCH/PUT /music_discs/1.json | def update
songs_to_remove = @music_disc.songs.select {|song| !music_disc_params[:music_category_ids].include?(song.music_category.id.to_s)}
songs_to_remove.each do | song |
@music_disc.songs.delete(song)
end
respond_to do |format|
if @music_disc.update(music_disc_params)
format.html { redirect_to @music_disc }
format.json { render :show, status: :ok, location: @music_disc }
else
format.html { render :edit }
format.json { render json: @music_disc.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @music = Music.find(params[:id])\n\n respond_to do |format|\n if @music.update_attributes(params[:music])\n format.html { redirect_to @music, :notice => 'Music was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => ... | [
"0.6817732",
"0.68119",
"0.68086284",
"0.6807941",
"0.67412335",
"0.67118347",
"0.6629886",
"0.6629886",
"0.65945536",
"0.6555014",
"0.64799225",
"0.63981086",
"0.6296029",
"0.62937444",
"0.62895614",
"0.6287331",
"0.6286059",
"0.6282151",
"0.6282151",
"0.6282151",
"0.6281662... | 0.66096693 | 8 |
DELETE /music_discs/1 DELETE /music_discs/1.json | def destroy
@music_disc.destroy
respond_to do |format|
format.html { redirect_to music_discs_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @music = Music.find(params[:id])\n @music.destroy\n\n respond_to do |format|\n format.html { redirect_to musics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @music = Music.find(params[:id])\n @music.destroy\n\n respond_to do |format|\n f... | [
"0.729984",
"0.729984",
"0.729984",
"0.7267837",
"0.7264692",
"0.71721333",
"0.7161083",
"0.7139181",
"0.7012895",
"0.6947899",
"0.6940732",
"0.69337344",
"0.69337344",
"0.69007456",
"0.6861175",
"0.6856993",
"0.6849808",
"0.68394935",
"0.68394935",
"0.6828294",
"0.68102556",... | 0.76910615 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_music_disc
id = params[:id].nil? ? params[:music_disc_id] : params[:id]
@music_disc = MusicDisc.find(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def music_disc_params
params.require(:music_disc).permit(:title, :discography, :group_name, { music_category_ids: []}, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /points/1 GET /points/1.xml | def show
@point = Point.find(params[:id])
@user = User.find(:first, :joins => "inner join points on users.id = points.user_id", :conditions => [ "points.id = ?",params[:id]])
# respond_to do |format|
# format.html # show.html.erb
# format.xml { render :xml => @point }
# end
#タイムラインへリダイレクト
redirect_to_timelines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @points = Point.all\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @points }\n end\n end",
"def show\n @point = Point.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { rende... | [
"0.7296532",
"0.7027359",
"0.6543091",
"0.6534514",
"0.6531218",
"0.6466613",
"0.64239246",
"0.6422226",
"0.6357939",
"0.62904483",
"0.6287933",
"0.62184143",
"0.61791235",
"0.6151053",
"0.61253",
"0.6117815",
"0.60879695",
"0.60703325",
"0.60557103",
"0.6047401",
"0.60214186... | 0.0 | -1 |
GET /points/new GET /points/new.xml | def new
@point = Point.new
@users = User.all
@user = User.find(params[:user_id])
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @point }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @point = Point.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point }\n end\n end",
"def new\n @point = Point.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point }\n end\n en... | [
"0.7735251",
"0.7720217",
"0.73190683",
"0.72539216",
"0.71986854",
"0.71568376",
"0.7152423",
"0.71219134",
"0.70359784",
"0.70289856",
"0.6915471",
"0.69087225",
"0.6861539",
"0.68416256",
"0.6807912",
"0.6762097",
"0.67339164",
"0.66980016",
"0.66798794",
"0.6666676",
"0.6... | 0.6863745 | 12 |
POST /points POST /points.xml | def create
@point = Point.new(params[:point])
respond_to do |format|
if @point.save
format.html { redirect_to(@point, :notice => 'Point was successfully created.') }
format.xml { render :xml => @point, :status => :created, :location => @point }
else
format.html { render :action => "new" }
format.xml { render :xml => @point.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @point = Point.new(params[:point])\n\n respond_to do |format|\n if @point.save\n format.html { redirect_to(@point, :notice => 'Point added') }\n format.xml { render :xml => @point, :status => :created, :location => @point }\n else\n format.html { render :action =>... | [
"0.65661246",
"0.63137096",
"0.6232738",
"0.62048274",
"0.6202215",
"0.6144506",
"0.60958636",
"0.60784113",
"0.5952932",
"0.5941154",
"0.5929124",
"0.5846992",
"0.58336085",
"0.58318824",
"0.58300966",
"0.57990026",
"0.5783145",
"0.57431936",
"0.5743137",
"0.5733619",
"0.572... | 0.65305614 | 1 |
PUT /points/1 PUT /points/1.xml | def update
# @point = params[:point]
# @date = date[:date]
# render :text => 'hoge'
@point = Point.find(params[:id])
respond_to do |format|
if @point.update_attributes(params[:point])
format.html { redirect_to(@point, :notice => 'Point was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @point.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @point = Point.find(params[:id])\n \n respond_to do |format|\n if @point.update_attributes(params[:point])\n format.html { redirect_to(@point, :notice => 'Point was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"e... | [
"0.6753766",
"0.6726449",
"0.66405857",
"0.661021",
"0.6510128",
"0.6332157",
"0.62724084",
"0.6266412",
"0.61282796",
"0.60895413",
"0.6084915",
"0.6059456",
"0.5927656",
"0.59264714",
"0.59192646",
"0.59190047",
"0.5906212",
"0.58911043",
"0.5883149",
"0.58527255",
"0.58349... | 0.60382855 | 12 |
DELETE /points/1 DELETE /points/1.xml | def destroy
@point = Point.find(params[:id])
@point.destroy
respond_to do |format|
format.html { redirect_to(points_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @point = Point.find(params[:id])\n @point.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @route_point = RoutePoint.find(params[:id])\n @route_point.destroy\n\n respond_to do |format|... | [
"0.6914002",
"0.67853105",
"0.6729424",
"0.6709959",
"0.6658105",
"0.65791404",
"0.65650725",
"0.65502757",
"0.650488",
"0.64979625",
"0.6478945",
"0.6455987",
"0.6444124",
"0.6424723",
"0.6391033",
"0.63118327",
"0.6302658",
"0.63005275",
"0.6248994",
"0.6241289",
"0.6234498... | 0.72460157 | 2 |
manage local jar dependency | def jar(name, **opts)
opts = {} if opts.nil?
opts = JSON[JSON[opts], symbolize_names: true]
opts[:vendor_path] = 'vendor/checkouts'
opts[:checkout_path] = File.join(opts[:vendor_path], name)
opts[:jar_path] = File.join(
opts[:checkout_path],
'target',
"#{name}-#{opts[:version]}.jar"
)
raise ArgumentError, "can't use path and git together" if opts[:git] && opts[:path]
system "mkdir -p #{opts[:vendor_path]}" unless Dir.exist?(opts[:vendor_path])
if opts[:git]
system "git clone #{opts[:git]} #{opts[:checkout_path]}" unless Dir.exist?(
opts[:checkout_path]
)
end
if opts[:build]
puts 'building...'
script = ''
script += "cd #{opts[:checkout_path]}"
script += "\n"
script += opts[:build]
system script
system "rm -rf ./lib/ext/*"
system "cp -r #{File.join(opts[:jar_path])} ./lib/ext"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |... | [
"0.63151515",
"0.6307941",
"0.6174609",
"0.6017502",
"0.6017384",
"0.59447604",
"0.59206504",
"0.5870142",
"0.5844417",
"0.582656",
"0.5812739",
"0.5796482",
"0.57960397",
"0.5780335",
"0.57800645",
"0.5756384",
"0.5736056",
"0.57155585",
"0.5715019",
"0.5683574",
"0.5664403"... | 0.5855401 | 8 |
GET /store_managers GET /store_managers.json | def index
@store_managers = StoreManager.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managers\n response = request(:get, \"/manager\")\n response_to_array(response, \"managers\", KontaktIo::Resource::Manager)\n end",
"def _manager_list\n\t\t\t# Author\n\t\t\treturn render json: { status: 6 } if cannot? :manage, User\n\t\t\t\n\t\t\t# Check unless exists is_add, type\n\t\t\treturn... | [
"0.7572758",
"0.71441805",
"0.6855907",
"0.6815052",
"0.66974133",
"0.6695657",
"0.6676692",
"0.6665478",
"0.6645525",
"0.6615003",
"0.6614031",
"0.6568612",
"0.6517625",
"0.64856637",
"0.6463473",
"0.6438148",
"0.6399849",
"0.6394502",
"0.63829434",
"0.6374996",
"0.6374236",... | 0.76231325 | 0 |
GET /store_managers/1 GET /store_managers/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @store_managers = StoreManager.all\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manager }\n end\n end",
"def show\n @manager = Manager.find(params[:id])\n end",
"def show\n @store_manager_statistic = Store::Mana... | [
"0.73541504",
"0.71646",
"0.695529",
"0.6889706",
"0.68418545",
"0.68341535",
"0.6814278",
"0.67253274",
"0.67013144",
"0.667647",
"0.66573733",
"0.6656402",
"0.66502243",
"0.6604766",
"0.65105337",
"0.6472337",
"0.6472337",
"0.6472337",
"0.6472337",
"0.6467869",
"0.64596945"... | 0.0 | -1 |
POST /store_managers POST /store_managers.json | def create
@store_manager = StoreManager.new(store_manager_params)
respond_to do |format|
if @store_manager.save
format.html { redirect_to @store_manager, notice: 'Store manager was successfully created.' }
format.json { render :show, status: :created, location: @store_manager }
else
format.html { render :new }
format.json { render json: @store_manager.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @manager = Manager.new(manager_params)\n\n if @manager.save\n render :show, status: :created, location: @manager\n else\n render json: @manager.errors, status: :unprocessable_entity\n end\n end",
"def create\n @manager = Manager.new(params[:manager])\n\n respond_to do |f... | [
"0.69857246",
"0.6829435",
"0.6551086",
"0.6466746",
"0.6425457",
"0.6420798",
"0.6373931",
"0.63274926",
"0.62881345",
"0.62680864",
"0.62455356",
"0.62400454",
"0.6219898",
"0.6170301",
"0.61547476",
"0.6133173",
"0.61242354",
"0.6064748",
"0.60476995",
"0.60435224",
"0.603... | 0.75044817 | 0 |
PATCH/PUT /store_managers/1 PATCH/PUT /store_managers/1.json | def update
respond_to do |format|
if @store_manager.update(store_manager_params)
format.html { redirect_to @store_manager, notice: 'Store manager was successfully updated.' }
format.json { render :show, status: :ok, location: @store_manager }
else
format.html { render :edit }
format.json { render json: @store_manager.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @manager.update(manager_params)\n render :show, status: :ok, location: @manager\n else\n render json: @manager.errors, status: :unprocessable_entity\n end\n end",
"def update\n @manager = Manager.find(params[:id])\n\n respond_to do |format|\n if @manager.update_attr... | [
"0.68259954",
"0.67671925",
"0.67176247",
"0.654345",
"0.64958966",
"0.6468298",
"0.6430893",
"0.64291024",
"0.64241815",
"0.63655216",
"0.63577807",
"0.635734",
"0.63391775",
"0.63195163",
"0.6317951",
"0.6317951",
"0.6317951",
"0.6317951",
"0.63138616",
"0.63138616",
"0.630... | 0.72280097 | 0 |
DELETE /store_managers/1 DELETE /store_managers/1.json | def destroy
@store_manager.destroy
respond_to do |format|
format.html { redirect_to store_managers_url, notice: 'Store manager was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @admin_store = Admin::Store.find(params[:id])\n @admin_store.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manager = Manager.find(params[:id])\n @manager.destroy\n\n ... | [
"0.75522566",
"0.74253094",
"0.7415629",
"0.74060535",
"0.72904855",
"0.7289748",
"0.7289748",
"0.7289748",
"0.7289748",
"0.72742367",
"0.72742367",
"0.72742367",
"0.72742367",
"0.72740823",
"0.72718334",
"0.72522384",
"0.7247328",
"0.71995854",
"0.71833086",
"0.7179625",
"0.... | 0.7751048 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_store_manager
@store_manager = StoreManager.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def store_manager_params
params.require(:store_manager).permit(:email, :phone, :name, :location_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Show Current User's Profile | def show_current
user = current_user
profile = Profile.find_by user_id: user.id
render json: profile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile\n @user = @current_user\n\n render :show\n\n end",
"def profile\n\t\t@user = User.find(current_user)\n\tend",
"def profile\n\t\t\n\t\tif !current_user\n\t\t\tredirect_to root_url and return\n\t\tend\n\t\t\n\t\t@user = current_user\n\t\t\n\tend",
"def profile\n\t\t@user = current_user\n\ten... | [
"0.82534546",
"0.81467056",
"0.8145606",
"0.8032345",
"0.80232215",
"0.7981136",
"0.7885248",
"0.7856213",
"0.77986467",
"0.77817374",
"0.7776848",
"0.7709753",
"0.7695782",
"0.7595749",
"0.7578902",
"0.7562654",
"0.756189",
"0.7434994",
"0.73932105",
"0.7388019",
"0.7363732"... | 0.752924 | 17 |
Public: Mark a course completed Returns the save state. true means success | def complete!
self.is_completed = true
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_completed!\n mark_state_complete!\n end",
"def save_completed\n self.status = :completed\n self.save!\n\n StudentMailer.application_completed(student, self).deliver_later\n StudentMessenger.new.application_completed(student, self)\n\n true\n end",
"def mark_as_complete_a... | [
"0.7193529",
"0.70810956",
"0.7052469",
"0.6901005",
"0.6878384",
"0.6779308",
"0.6746624",
"0.6745381",
"0.6730323",
"0.66763574",
"0.6670148",
"0.6591815",
"0.6591056",
"0.654552",
"0.65284604",
"0.65116674",
"0.6428214",
"0.6416912",
"0.63879466",
"0.63848895",
"0.636623",... | 0.7039356 | 3 |
Public: whether a course is marked completed Returns the state, true means completed. | def completed?
self.is_completed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed?\n self.state == :completed\n end",
"def completed?\n @completed\n end",
"def completed?\n @completed\n end",
"def completed?\n @state.to_s =~ /finished|aborted|failed/\n end",
"def completed?\n !!completed\n end",
"def completed?\n status.comple... | [
"0.8017763",
"0.7988873",
"0.7971955",
"0.7916201",
"0.78749657",
"0.7863431",
"0.7859596",
"0.7812236",
"0.7801383",
"0.7801383",
"0.77808994",
"0.77301496",
"0.7711255",
"0.7711255",
"0.77064085",
"0.7663645",
"0.76507324",
"0.76351213",
"0.76351213",
"0.7623263",
"0.762226... | 0.7650922 | 16 |
Public: Search for schedules that was already overdued Returns the Mongoid::Criteria | def overdue
schedules.where(:when.lte => Time.now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersecting_event_schedules\n room.event_schedules.where(start_time: start_time, schedule: schedule).where.not(id: id)\n end",
"def possibly_coliding_schedules\n Schedule.where(possibly_coliding_schedules_query)\n end",
"def existing_reservations\n start_dt = self.start_dt.try(:to_datetime).try... | [
"0.6640494",
"0.61551124",
"0.5504792",
"0.54813284",
"0.5408912",
"0.5375715",
"0.536107",
"0.5329269",
"0.52939874",
"0.52747977",
"0.52722156",
"0.5187178",
"0.51775956",
"0.5169996",
"0.5168714",
"0.5148303",
"0.51482743",
"0.51025355",
"0.5051192",
"0.5040364",
"0.502870... | 0.60602003 | 2 |
Public: Search for schedules that will soon overdue range The overdue time, must be UTC int (Default: 4.days) Returns the Mongoid::Criteria | def soon range=4.days
schedules.where(:when.lte => range.from_now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overdue\n schedules.where(:when.lte => Time.now)\n end",
"def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end",
"def future from=7.days\n schedules.where(:when.gte => from.from_now)\n end",
"def overdue?\n if is_appoint... | [
"0.7787857",
"0.6186143",
"0.5992936",
"0.56769466",
"0.566428",
"0.5557885",
"0.555084",
"0.55211115",
"0.5510264",
"0.5500905",
"0.5485369",
"0.53618103",
"0.5327263",
"0.52653277",
"0.5250627",
"0.5248456",
"0.5218757",
"0.5200439",
"0.51879436",
"0.5132213",
"0.51033014",... | 0.6626659 | 1 |
Public: Search for schedules that will not due so soon range The overdue time, must be UTC int (Default: 7.days) Returns the Mongoid::Criteria | def future from=7.days
schedules.where(:when.gte => from.from_now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overdue\n schedules.where(:when.lte => Time.now)\n end",
"def soon range=4.days\n schedules.where(:when.lte => range.from_now)\n end",
"def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end",
"def available_criteria\n @av... | [
"0.7614393",
"0.6538048",
"0.62380904",
"0.5976157",
"0.55274296",
"0.5461416",
"0.54331154",
"0.5427395",
"0.54065764",
"0.5353948",
"0.5310081",
"0.5299713",
"0.52915895",
"0.5232938",
"0.52284855",
"0.52060425",
"0.51913404",
"0.5183644",
"0.5140631",
"0.5137245",
"0.51347... | 0.6211193 | 3 |
Lazily fetches all builds. | def builds(filters = {})
fetch_resources_lazily("builds", filters)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_all\n response_json = @client.api_get_request(\"/api/build\")\n\n return nil unless response_json\n\n response_json[\"builds\"].map do |build|\n {\n :name => build[\"uri\"].sub(/^\\//,''),\n :uri => build[\"uri\"],\n :lastStarted => build[\"la... | [
"0.7296129",
"0.6667138",
"0.6655257",
"0.64318824",
"0.64318824",
"0.6394068",
"0.6388178",
"0.63228804",
"0.6315594",
"0.63138396",
"0.62459344",
"0.62009",
"0.61851406",
"0.6077386",
"0.60382944",
"0.6001163",
"0.5963967",
"0.5928858",
"0.59113204",
"0.5886723",
"0.588318"... | 0.75809765 | 0 |
find node by full node_name or by matching prefix of node_name | def find_node(node_name)
puts "*"*80
raise(Thor::Error, "Node not specified.") if node_name.nil? || node_name.empty?
return {node_name => nodes_in_stage[node_name]} if nodes_in_stage[node_name]
puts "-"*80
nodes_in_stage.each do |key, value|
puts key
return {key => value} if key.start_with?(node_name)
end
raise(Thor::Error, "Not found: #{node_name} in #{stage_name}.")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node(node_name)\n nodes(node_name).first\nend",
"def find_node(root,path)\n name_array = path.split('.')\n node = root[name_array[0]]\n name_array.each do |n|\n node.children.each do |c|\n if c.name == n\n node = c\n break\n end\n end\n end\n node... | [
"0.6563202",
"0.64931077",
"0.6474571",
"0.63965887",
"0.63177985",
"0.62740976",
"0.62528414",
"0.6174903",
"0.6162795",
"0.61566484",
"0.6149624",
"0.61342674",
"0.6101362",
"0.60712624",
"0.5991016",
"0.5983769",
"0.5922772",
"0.59211916",
"0.59132427",
"0.59070194",
"0.58... | 0.5686777 | 37 |
ENV['PVC_DEPLOY_TO_BASE'] = stage_data[:deploy_to] || '/sites' | def deploy_to_base_dir
# stage[:deploy_to] || '/sites' # TODO: verify if server setup supports `:deploy_to` override
Pvcglue.configuration.web_app_base_dir # TODO: server setup does not yet support `:deploy_to` override, and would have to be refactored at a higher level than stage.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deploy_to\n fetch(:deploy_to, nil) || \"/opt/apps/#{fetch(:application)}\"\n end",
"def deploy_to\n \"/data/#{app_name.downcase}/app\"\n end",
"def deploy?; run_options[:deploy]; end",
"def defaults \n default_run_options[:pty] = true\n\tset :deploy_to, \"/usr/local/www/#{application}-... | [
"0.736962",
"0.6881185",
"0.64545506",
"0.63965285",
"0.6289924",
"0.62297416",
"0.6101152",
"0.60693705",
"0.6054623",
"0.60220146",
"0.60220146",
"0.6010095",
"0.5999325",
"0.5978251",
"0.59468144",
"0.58942914",
"0.5858668",
"0.5810374",
"0.5801588",
"0.57986265",
"0.57815... | 0.80964094 | 0 |
GET /cooperatives GET /cooperatives.json | def index
@cooperatives = Cooperative.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @coasters = Coaster.all\n\n render json: @coasters\n end",
"def index\n @creatives = @org.creatives\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktail... | [
"0.6678411",
"0.6565149",
"0.6411777",
"0.63552314",
"0.63453263",
"0.6303329",
"0.6295732",
"0.6292242",
"0.6262387",
"0.6251463",
"0.62386984",
"0.62302285",
"0.6222405",
"0.6180417",
"0.61521375",
"0.6135253",
"0.61308223",
"0.61206263",
"0.6118713",
"0.61167467",
"0.60735... | 0.7567936 | 0 |
GET /cooperatives/1 GET /cooperatives/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cooperatives = Cooperative.all\n end",
"def index\n @coasters = Coaster.all\n\n render json: @coasters\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cock... | [
"0.7288006",
"0.68301636",
"0.6526426",
"0.643757",
"0.6427576",
"0.6426255",
"0.629142",
"0.62764746",
"0.6247336",
"0.6244709",
"0.6234328",
"0.6234245",
"0.61898535",
"0.61868864",
"0.61759335",
"0.61556685",
"0.6153337",
"0.6150835",
"0.6149681",
"0.6143451",
"0.61296695"... | 0.0 | -1 |
POST /cooperatives POST /cooperatives.json | def create
@cooperative = Cooperative.new(cooperative_params)
respond_to do |format|
if @cooperative.save
format.html { redirect_to @cooperative, notice: 'Cooperative was successfully created.' }
format.json { render :show, status: :created, location: @cooperative }
else
format.html { render :new }
format.json { render json: @cooperative.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @congresso = Congresso.new(congresso_params)\n\n respond_to do |format|\n if @congresso.save\n format.html { redirect_to @congresso, notice: 'Congresso was successfully created.' }\n format.json { render :show, status: :created, location: @congresso }\n else\n form... | [
"0.5972425",
"0.5955439",
"0.58297646",
"0.57903653",
"0.57780814",
"0.5767716",
"0.5766921",
"0.5761265",
"0.57344115",
"0.5729172",
"0.57279915",
"0.5706497",
"0.56831455",
"0.56721836",
"0.5669756",
"0.5666183",
"0.5648887",
"0.5643536",
"0.5633182",
"0.5628177",
"0.562293... | 0.6995013 | 0 |
PATCH/PUT /cooperatives/1 PATCH/PUT /cooperatives/1.json | def update
respond_to do |format|
if @cooperative.update(cooperative_params)
format.html { redirect_to @cooperative, notice: 'Cooperative was successfully updated.' }
format.json { render :show, status: :ok, location: @cooperative }
else
format.html { render :edit }
format.json { render json: @cooperative.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entit... | [
"0.64254296",
"0.6286189",
"0.61793596",
"0.6178764",
"0.6149227",
"0.6079479",
"0.6067912",
"0.60595495",
"0.605646",
"0.6055527",
"0.602482",
"0.6000337",
"0.5922706",
"0.59148216",
"0.59128577",
"0.59127146",
"0.591116",
"0.5909698",
"0.5906518",
"0.5878436",
"0.58767176",... | 0.66824746 | 0 |
DELETE /cooperatives/1 DELETE /cooperatives/1.json | def destroy
@cooperative.destroy
respond_to do |format|
format.html { redirect_to cooperatives_url, notice: 'Cooperative was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n resp... | [
"0.70096076",
"0.6769179",
"0.6762237",
"0.6703216",
"0.6689681",
"0.66804343",
"0.664934",
"0.6637919",
"0.6627466",
"0.6621922",
"0.66214293",
"0.66147023",
"0.66145146",
"0.6606146",
"0.6596792",
"0.6576839",
"0.65711504",
"0.65647215",
"0.6559654",
"0.6548392",
"0.6541989... | 0.7141181 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_cooperative
@cooperative = Cooperative.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def cooperative_params
params.require(:cooperative).permit(:nombre)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
string Paired api key username | def username
@attributes[:username]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key\n\t\t\t@username || 'unknown'\n\t\tend",
"def key\n return \"#{user}\"\n end",
"def apikey(username, password)\n md5 = Digest::MD5.new\n digest = md5.update(password).hexdigest\n\n query = { action: 'apikey', userName: username, password: digest }\n get('apikey', query) { |x| x[... | [
"0.8133858",
"0.7506096",
"0.7257325",
"0.7124224",
"0.7124224",
"0.68401325",
"0.6829724",
"0.6785307",
"0.66959405",
"0.66836804",
"0.6682597",
"0.66704744",
"0.6655688",
"0.66376173",
"0.6620571",
"0.66049427",
"0.6597253",
"0.6581595",
"0.6581595",
"0.6564794",
"0.6546738... | 0.0 | -1 |
string Paired api key password | def password
@attributes[:password]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key(aliaz, password)\n\n end",
"def apikey(username, password)\n md5 = Digest::MD5.new\n digest = md5.update(password).hexdigest\n\n query = { action: 'apikey', userName: username, password: digest }\n get('apikey', query) { |x| x['apikey'] }\n end",
"def password\n conf['api']['pass... | [
"0.76322424",
"0.74670136",
"0.7402092",
"0.69810885",
"0.6953416",
"0.6923486",
"0.68666655",
"0.67905957",
"0.67512745",
"0.6733115",
"0.67294115",
"0.6706941",
"0.6698854",
"0.66882193",
"0.6661806",
"0.66404915",
"0.66352046",
"0.6596681",
"0.65833783",
"0.65703666",
"0.6... | 0.0 | -1 |
string Unique nickname for this api key | def nickname
@attributes[:nickname]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key\n\t\t\t@username || 'unknown'\n\t\tend",
"def api_name\n return @api_name if @api_name\n sanitized = @username.gsub(/[\\W_]+/, '_')\n @api_name ||= sanitized[0..15]\n end",
"def generate_unique_name\n SecureRandom.uuid\n end",
"def secret_username\n return nil if gml_... | [
"0.7100706",
"0.70127875",
"0.6987943",
"0.6924053",
"0.68550587",
"0.6836947",
"0.6804843",
"0.6804661",
"0.6743886",
"0.6739026",
"0.6735404",
"0.67320806",
"0.6666806",
"0.66276205",
"0.66276205",
"0.6582242",
"0.6569239",
"0.6568734",
"0.65567404",
"0.6542322",
"0.6528566... | 0.62490976 | 57 |
This should possibly be in either lib/inspec/cli.rb or Registry | def exit_on_load_error
if registry.any_load_failures?
Inspec::Log.error "Errors were encountered while loading plugins..."
registry.plugin_statuses.select(&:load_exception).each do |plugin_status|
Inspec::Log.error "Plugin name: " + plugin_status.name.to_s
Inspec::Log.error "Error: " + plugin_status.load_exception.message
if ARGV.include?("--debug")
Inspec::Log.error "Exception: " + plugin_status.load_exception.class.name
Inspec::Log.error "Trace: " + plugin_status.load_exception.backtrace.join("\n")
end
end
Inspec::Log.error("Run again with --debug for a stacktrace.") unless ARGV.include?("--debug")
exit 2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_cli(cli); end",
"def cli_path; end",
"def parse_cli\n raise \"Undefined interface for the command line of #{cli.task}\"\n end",
"def inspec_runner\n # When running under inspec-cli, we have an 'inspec' method that\n # returns the runner. When running under unit tests, we don't\n # have ... | [
"0.64625376",
"0.61597776",
"0.599794",
"0.5968242",
"0.5968242",
"0.5934769",
"0.5897523",
"0.58849317",
"0.5793868",
"0.5793868",
"0.5761598",
"0.5743322",
"0.57210445",
"0.5632632",
"0.5627167",
"0.5612879",
"0.5547858",
"0.55191875",
"0.549387",
"0.54871917",
"0.5483253",... | 0.0 | -1 |
'Activating' a gem adds it to the load path, so 'require "gemname"' will work. Given a gem name, this activates the gem and all of its dependencies, respecting version pinning needs. | def activate_managed_gems_for_plugin(plugin_gem_name, version_constraint = "> 0")
# TODO: enforce first-level version pinning
plugin_deps = [Gem::Dependency.new(plugin_gem_name.to_s, version_constraint)]
managed_gem_set = Gem::Resolver::VendorSet.new
list_managed_gems.each { |spec| managed_gem_set.add_vendor_gem(spec.name, spec.gem_dir) }
# TODO: Next two lines merge our managed gems with the other gems available
# in our "local universe" - which may be the system, or it could be in a Bundler microcosm,
# or rbenv, etc. Do we want to merge that, though?
distrib_gem_set = Gem::Resolver::CurrentSet.new
installed_gem_set = Gem::Resolver.compose_sets(managed_gem_set, distrib_gem_set)
# So, given what we need, and what we have available, what activations are needed?
resolver = Gem::Resolver.new(plugin_deps, installed_gem_set)
begin
solution = resolver.resolve
rescue Gem::UnsatisfiableDependencyError => gem_ex
# If you broke your install, or downgraded to a plugin with a bad gemspec, you could get here.
ex = Inspec::Plugin::V2::LoadError.new(gem_ex.message)
raise ex
end
solution.each do |activation_request|
next if activation_request.full_spec.activated?
activation_request.full_spec.activate
# TODO: If we are under Bundler, inform it that we loaded a gem
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activate_gem(gem_name, library_name = nil)\n if !defined?(::Gem)\n begin\n require 'rubygems'\n rescue LoadError\n end\n end\n if Kernel.respond_to?(:gem, true)\n begin\n gem(gem_name)\n rescue Gem::LoadError\n end\n end\n req... | [
"0.8087241",
"0.7445291",
"0.7396846",
"0.69495565",
"0.69286793",
"0.68840724",
"0.6837962",
"0.6800851",
"0.6800851",
"0.6800851",
"0.67125195",
"0.6707811",
"0.66649485",
"0.65723765",
"0.64063674",
"0.6296348",
"0.62947893",
"0.6237528",
"0.6192786",
"0.61912787",
"0.6155... | 0.6941849 | 4 |
Constructs and initializes the board of given size | def initialize(size, startPlayer, discColor)
# validate arguments
if size < 4 || size > 8 || size % 2 != 0
raise ArgumentError.new('Invalid value for board size.')
end
if startPlayer < 1 || startPlayer > 2
raise ArgumentError.new('Invalid value for player number.')
end
if discColor != WHITE && discColor != BLACK
raise ArgumentError.new('Invalid value for disc.');
end
# set instance variables
@board = []
@size = size
@turn = startPlayer
@disc = discColor
# set two more instance variables @p1Disc and @p2Disc
if @turn == 1
@p1Disc = @disc
@p2Disc = @disc == WHITE ? BLACK : WHITE
else
@p2Disc = @disc
@p1Disc = @disc == WHITE ? BLACK : WHITE;
end
# create the grid (as array of arrays)
@board = Array.new(@size)
for i in (0...@board.length)
@board[i] = Array.new(@size)
@board[i].fill(0)
end
# initialize the grid
initializeBoard()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(size)\n @board_size = size\n @board = []\n @board_size.times { @board << Array.new(@board_size, EMPTY_SYMBOL) }\n end",
"def fill_board(size)\n board = []\n board_rows = []\n size.times {|i| board_rows << i}\n size.times {board << board_rows}\n @board =... | [
"0.8501538",
"0.82990074",
"0.8266954",
"0.82005614",
"0.7659927",
"0.7646631",
"0.76348144",
"0.75880367",
"0.7577868",
"0.75086474",
"0.7475693",
"0.74493164",
"0.74374884",
"0.73475176",
"0.7257581",
"0.7231857",
"0.72154176",
"0.71931386",
"0.7189941",
"0.7189941",
"0.717... | 0.7160554 | 21 |
Initializes the board with start configuration of discs | def initializeBoard()
# TO DO: COMPLETE THIS METHOD
maxMid = @size / 2
minMid = @size / 2 - 1
for i in 0..size-1
for j in 0..size-1
if i == maxMid && j == maxMid
@board[i][j] = "B"
elsif i == minMid && j == minMid
@board[i][j] = "B"
elsif (i == minMid || i == maxMid) && (j == maxMid || j == minMid)
@board[i][j] = "W"
else
@board[i][j] = "-";
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n\t\treset_board\n\tend",
"def init_board\n @board =\n if board_state.present?\n Board.new(width: rows, height: cols, mines_count: mines).tap do |b|\n b.load_state!(board_state)\n end\n else\n Board.new(width: rows, height: cols, mines_count: mines).tap d... | [
"0.71676415",
"0.7138115",
"0.7001502",
"0.6974499",
"0.6963097",
"0.6906531",
"0.68870723",
"0.6814357",
"0.67899317",
"0.6783577",
"0.6701555",
"0.6688985",
"0.6668739",
"0.66623276",
"0.6644056",
"0.66363126",
"0.6607749",
"0.65625876",
"0.6547501",
"0.65209615",
"0.651993... | 0.58712435 | 96 |
Returns true if placing the disc of current player at row,col is valid; else returns false | def isValidMove(row, col)
return isValidMoveForDisc(row, col, @disc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidMove(row, col)\n \treturn isValidMoveForDisc(row, col, @disc)\n end",
"def isValidMove(row, col)\n \treturn isValidMoveForDisc(row, col, @disc)\n end",
"def valid?(position)\n row, col = position\n position.all? {|i| i >= 0 && i< @grid.length}\n \n end",
"def position_is_va... | [
"0.761069",
"0.761069",
"0.75943315",
"0.7530692",
"0.7323183",
"0.73206013",
"0.73101395",
"0.73069",
"0.72853434",
"0.7222364",
"0.7211012",
"0.72028327",
"0.7196116",
"0.71937877",
"0.71914446",
"0.71454304",
"0.71157956",
"0.70852625",
"0.70471156",
"0.7043656",
"0.698560... | 0.7534997 | 3 |
functions for seeing if moves are valid Top | def canMoveTop(row,col,disc)
max = @size -1
min = 0
notDisc = ""
c = 1
if disc == "B"
notDisc = "W"
end
if disc == "W"
notDisc = "B"
end
if row-c >= min && @board[row-c][col] == notDisc
while row-c >= min && @board[row-c][col] != "-"
if @board[row-c][col] == disc
return true
end
c = c + 1
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend",
"def valid_moves\n\n end",
"def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend",
"def valid_moves\n moves.reject { |end_pos| move_into_check?(end_pos) ... | [
"0.670112",
"0.66919005",
"0.6688539",
"0.6680369",
"0.6636218",
"0.6625445",
"0.6602211",
"0.66011834",
"0.65814084",
"0.6576568",
"0.65746796",
"0.6574358",
"0.6570878",
"0.6560727",
"0.65515715",
"0.6547356",
"0.6546352",
"0.6546008",
"0.65457726",
"0.6535237",
"0.6533379"... | 0.7201266 | 0 |
Returns true if placing the specified disc at row,col is valid; else returns false | def isValidMoveForDisc(row, col, disc)
# TO DO: COMPLETE THIS PART OF THE METHOD
if canMoveTop(row,col,disc)
return true
end
if canMoveTopRight(row,col,disc)
return true
end
if canMoveTopLeft(row,col,disc)
return true
end
if canMoveLeft(row,col,disc)
return true
end
if canMoveRight(row,col,disc)
return true
end
if canMoveBottom(row,col,disc)
return true
end
if canMoveBottomLeft(row,col,disc)
return true
end
if canMoveBottomRight(row,col,disc)
return true
end
# DO NOT DELETE - if control reaches this statement, then it is not a valid move
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid(row, col)\n if check_row(row) and check_col(col) and check_diag(row, col)\n return true\n else\n return false\n end\n end",
"def isValidMove(row, col)\n \treturn isValidMoveForDisc(row, col, @disc)\n end",
"def isValidMove(row, col)\n \treturn isValidMoveForDisc(row, col, @disc... | [
"0.76600814",
"0.7609696",
"0.7609696",
"0.75011873",
"0.74154174",
"0.72540426",
"0.72275454",
"0.71698076",
"0.7149026",
"0.70524174",
"0.6981378",
"0.6978048",
"0.688359",
"0.6878643",
"0.6874307",
"0.6853557",
"0.6846965",
"0.6845033",
"0.68435013",
"0.68350655",
"0.68286... | 0.7539409 | 3 |
Places the disc of current player at row,col and flips the opponent discs as needed | def placeDiscAt(row, col)
if (!isValidMove(row, col))
return
end
# place the current player's disc at row,col
@board[row][col] = @disc
# TO DO: COMPLETE THIS PART OF THE METHOD
c = 1
notDisc = ""
if @disc == "B"
notDisc = "W"
end
if @disc == "W"
notDisc = "B"
end
#Top
if canMoveTop(row,col,@disc)
while @board[row-c][col] == notDisc
@board[row-c][col] = @disc
c = c + 1
end
c = 1 #reset c
end
#Top Right
if canMoveTopRight(row,col,@disc)
while @board[row-c][col+c] == notDisc
@board[row-c][col+c] = @disc
c = c + 1
end
c = 1 #reset c
end
#Top Left
if canMoveTopLeft(row,col,@disc)
while @board[row-c][col-c] == notDisc
@board[row-c][col-c] = @disc
c = c + 1
end
c = 1 #reset c
end
#Left
if canMoveLeft(row,col,@disc)
while @board[row][col-c] == notDisc
@board[row][col-c] = @disc
c = c + 1
end
c = 1 #reset c
end
#Right
if canMoveRight(row,col,@disc)
while @board[row][col+c] == notDisc
@board[row][col+c] = @disc
c = c + 1
end
c = 1 #reset c
end
#Bottom Left
if canMoveBottomLeft(row,col,@disc)
while @board[row+c][col-c] == notDisc
@board[row+c][col-c] = @disc
c = c + 1
end
c = 1 #reset c
end
#Bottom
if canMoveBottom(row,col,@disc)
while @board[row+c][col] == notDisc
@board[row+c][col] = @disc;
c = c + 1
end
c = 1 #reset c
end
#Bottom Right
if canMoveBottomRight(row,col,@disc)
while @board[row+c][col+c] == notDisc
@board[row+c][col+c] = @disc;
c = c + 1
end
c = 1 #reset c
end
# DO NOT DELETE - prepares for next turn if game is not over
if (!isGameOver())
prepareNextTurn();
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def placeDiscAt(row, col)\n\t\tif (!isValidMove(row, col))\n\t\t\treturn\n\t\tend\n\n #\n # TO DO: add your code below\n\t\t#\n\t\t@board[row][col] = @disc;\n\t\t# flips any opponent discs down\n\t\tr = row + 1\n\t\tc = col\n\t\twhile r < @size && @board[r][c] != EMPTY && @board[r][c] != @disc do\n\t\t\t\tr ... | [
"0.76008284",
"0.6716554",
"0.6695476",
"0.65508103",
"0.63319093",
"0.6143951",
"0.61018014",
"0.607248",
"0.60643834",
"0.59181416",
"0.591742",
"0.5902453",
"0.5868368",
"0.5852522",
"0.58520985",
"0.58352107",
"0.5818336",
"0.58010536",
"0.57892674",
"0.5773215",
"0.57570... | 0.6882374 | 1 |
Returns true if a valid move for current player is available; else returns false | def isValidMoveAvailable()
isValidMoveAvailableForDisc(@disc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moves_available?(player)\n !@board.moves(player).empty?\n end",
"def move_valid_for?(player_id)\n return false if last_player_id == player_id\n\n true\n end",
"def move_available?\n total_available_moves > 0\n end",
"def valid_move?(move)\n new_position = @current_player.position_after_... | [
"0.8317002",
"0.78873295",
"0.7811226",
"0.77638197",
"0.77509844",
"0.77024466",
"0.7641454",
"0.763153",
"0.7595033",
"0.7590222",
"0.75645244",
"0.755246",
"0.7516679",
"0.7514879",
"0.746704",
"0.74664044",
"0.74664044",
"0.74557984",
"0.74546593",
"0.74406874",
"0.743523... | 0.7459572 | 17 |
Returns true if a valid move for the specified disc is available; else returns false | def isValidMoveAvailableForDisc(disc)
# TO DO: COMPLETE THIS PART OF THE METHOD
for i in 0..@size-1
for j in 0..@size-1
if isValidMoveForDisc(i,j,disc) && @board[i][j] == "-"
return true
end
end
end
# DO NOT DELETE - if control reaches this statement, then a valid move is not available
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidMoveAvailable()\n\t\tisValidMoveAvailableForDisc(@disc)\n end",
"def isValidMoveAvailable()\n\t\tisValidMoveAvailableForDisc(@disc)\n end",
"def isValidMoveAvailable()\n isValidMoveAvailableForDisc(@disc)\n end",
"def isValidMoveAvailableForDisc(disc)\n #\n # TO DO: add your code... | [
"0.86856645",
"0.86856645",
"0.8631769",
"0.83926356",
"0.8166335",
"0.79253185",
"0.7809717",
"0.7609814",
"0.7609814",
"0.7605387",
"0.726411",
"0.7055995",
"0.69903004",
"0.6904715",
"0.68830246",
"0.6870403",
"0.6860742",
"0.68529695",
"0.6848695",
"0.68158495",
"0.680849... | 0.8367985 | 4 |
Returns true if the board is fully occupied with discs; else returns false | def isBoardFull()
# TO DO: COMPLETE THIS PART OF THE METHOD
counter = 0
totalSpaces = @size * @size
for i in 0..@size-1
for j in 0..@size-1
if @board[i][j] != "-"
counter = counter + 1
end
end
end
if counter == totalSpaces
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full?\n @board.all?{|occupied| occupied != \" \"}\n end",
"def board_full?(brd)\n empty_squares(brd).empty?\n end",
"def board_full?(brd)\n empty_squares(brd).empty?\nend",
"def board_full?(brd)\n empty_squares(brd).empty?\nend",
"def isBoardFull()\n #\n # TO DO: add your code below... | [
"0.82167774",
"0.8075867",
"0.7902185",
"0.7902185",
"0.78788847",
"0.7866243",
"0.7854012",
"0.7836874",
"0.78315777",
"0.7821679",
"0.7821679",
"0.7790783",
"0.7768844",
"0.7711425",
"0.77066225",
"0.77058244",
"0.7667365",
"0.7651848",
"0.76508766",
"0.7647774",
"0.7611108... | 0.78141826 | 11 |
Returns true if either the board is full or a valid move is not available for either disc | def isGameOver()
return isBoardFull() ||
(!isValidMoveAvailableForDisc(WHITE) &&
!isValidMoveAvailableForDisc(BLACK))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidMoveAvailableForDisc(disc)\n #\n # TO DO: add your code below\n\t\t#\n\t\tfor i in (0...@board.size)\n\t\t\tfor j in (0...@board.size)\n\t\t\t\tif isValidMoveForDisc(i, j, disc)\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n # DO NOT DELETE THE LINE BELOW\n\t\treturn false;\n\tend"... | [
"0.8122413",
"0.8038092",
"0.79418665",
"0.79418665",
"0.7899868",
"0.7865162",
"0.77940035",
"0.77940035",
"0.7751973",
"0.7735239",
"0.7733963",
"0.7708545",
"0.7695681",
"0.7616508",
"0.7592034",
"0.757207",
"0.7547722",
"0.7543782",
"0.7538912",
"0.7522495",
"0.7521987",
... | 0.7407721 | 38 |
If there is a winner, it returns Othello::WHITE or Othello::BLACK. In case of a tie, it returns Othello::TIE | def checkWinner()
# TO DO: COMPLETE THIS METHOD
bCounter = 0
wCounter = 0
for i in 0..@size-1
for j in 0..@size-1
if @board[i][j] == "B"
bCounter = bCounter + 1
end
if @board[i][j] == "W"
wCounter = wCounter + 1
end
end
end
if wCounter > bCounter
return WHITE;
end
if bCounter > wCounter
return BLACK
end
if bCounter == wCounter
return TIE
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner\n if type == :basic\n basic_winner\n elsif type == :war\n war_winner\n elsif type == :mutally_assured_destruction\n \"No Winner\"\n end\n end",
"def loser\n return winner == :player_a ? :player_b : :player_a\n end",
"def winner\n won = won?()\n if won != false\... | [
"0.7752766",
"0.7526196",
"0.74279565",
"0.7403889",
"0.74030495",
"0.7380257",
"0.73765326",
"0.7353286",
"0.73485935",
"0.73174196",
"0.7286403",
"0.7229853",
"0.7227314",
"0.72198904",
"0.72132814",
"0.7209583",
"0.72057503",
"0.7202321",
"0.7193683",
"0.71885407",
"0.7186... | 0.0 | -1 |
Returns a string representation of the board | def to_s()
str = "\n "
for i in (0...@size)
str << (i+1).to_s + ' '
end
str << "\n";
for i in (0...@size)
str << (i+1).to_s + ' ';
str << @board[i].join(' ') + "\n";
end
return str;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @board.map { |row| row.join (' ') }.join(\"\\n\")\n end",
"def to_s\n @board_array.flatten.join(\"\")\n end",
"def to_s()\n\t\t@board.to_s\n\tend",
"def to_s\n string_board = \"\"\n @board.each do |row|\n row.each do |square|\n string_board << \" #{square.number} \"\n... | [
"0.87569886",
"0.8606402",
"0.85789233",
"0.8512254",
"0.8458669",
"0.8455167",
"0.84469885",
"0.8446652",
"0.8440508",
"0.8375333",
"0.8341328",
"0.83300054",
"0.8306895",
"0.8301309",
"0.8301309",
"0.82764673",
"0.82700515",
"0.8255491",
"0.8235811",
"0.8235756",
"0.8196552... | 0.82416296 | 18 |
Returns command to replace or append configuration | def set_command
[grep_cmd, '&&', replace_cmd, '||', append_cmd].join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_command(cmd)\n end",
"def config(command)\n ensure_mode(:configuration)\n run(command)\n end",
"def replace_command(command)\n return @apps[command] if @apps.has_key?(command)\n return command\n end",
"def command_config(str_opts)\n command :config do |c|\n ... | [
"0.70006484",
"0.6455611",
"0.64460176",
"0.61871654",
"0.6170531",
"0.61379653",
"0.6052118",
"0.6047923",
"0.59832275",
"0.5964551",
"0.58868384",
"0.58862174",
"0.5873381",
"0.5865697",
"0.585982",
"0.5750056",
"0.57091177",
"0.56871325",
"0.5682299",
"0.56749403",
"0.5664... | 0.61103785 | 6 |
Returns command to remove line from configuration | def unset_command
[grep_cmd, '&&', unset_cmd].join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_command(name)\n @commands ||= {}\n @commands.delete name\n end",
"def unset_cmd\n sprintf 'sed -i /%s/d %s', key_set_string, @file\n end",
"def remove_config(name)\n\t\tend",
"def remove_command(command, resize=true)\n @commands.delete(command)\n @item_max = @command... | [
"0.648653",
"0.62402755",
"0.61489886",
"0.60996914",
"0.60476494",
"0.5989397",
"0.594207",
"0.59270114",
"0.59146637",
"0.5878863",
"0.58686227",
"0.5851612",
"0.5824469",
"0.58132344",
"0.58082014",
"0.57268524",
"0.5697975",
"0.56960917",
"0.56915903",
"0.56839556",
"0.56... | 0.6232845 | 2 |
Returns command to grep config file for assignment | def grep_cmd
sprintf 'grep -Fq "%s" %s', key_set_string, @file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_config(file); end",
"def getconf(target)\n\t\t@log.info \"--util.rb : util.getconf(\" + target + \") \"\n\t\tFile.foreach(@config_file) do |line|\n\t\t#File.foreach(\"../../config.txt\") do |line|\n\t\t\tconf = line.chomp\n\t\t\tif(conf.index(target)) then\n\t\t\t\t@log.debug \"return \" + conf.split[1]... | [
"0.5852091",
"0.5773518",
"0.57331246",
"0.5667553",
"0.5643085",
"0.5566762",
"0.55313295",
"0.5511817",
"0.5504865",
"0.5457773",
"0.5404175",
"0.53757",
"0.53671145",
"0.5356291",
"0.53178984",
"0.5289387",
"0.5241179",
"0.5232754",
"0.5229069",
"0.52215624",
"0.5180762",
... | 0.6838154 | 0 |
Returns command to replace assignment | def replace_cmd
sprintf 'sed -i "s/%s.*/%s%s/" %s', key_set_string, key_set_string, @config[:value], @file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commandalias(command, a)\r\n\t\t\t@commands[a] = @commands[command]\r\n\t\tend",
"def assignment\n @name = get_name\n match '='\n expression\n emit_ln \"LEA #{@name} (PC),A0\"\n emit_ln 'MOVE D0,(A0)'\nend",
"def set_command\n [grep_cmd, '&&', replace_cmd, '||', append_cmd].join(' ')\n end... | [
"0.57952",
"0.57925004",
"0.57658553",
"0.5744737",
"0.5702929",
"0.5698701",
"0.5654884",
"0.5598732",
"0.55923104",
"0.551631",
"0.550902",
"0.54576415",
"0.54512185",
"0.5422192",
"0.5418369",
"0.54174066",
"0.5400889",
"0.5389654",
"0.53807616",
"0.53190607",
"0.5291826",... | 0.57441646 | 4 |
Returns command to append assignment to config file | def append_cmd
sprintf 'echo "%s%s" >> %s', key_set_string, @config[:value], @file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setconfig(str)\n add_cmd str\n end",
"def configure_command(cmd)\n end",
"def add_new_config\n name = @options.new_config[0]\n path = @options.new_config.length == 2 ? @options.new_config[1] : nil\n # makes a call to generate a default configuration file\n new_file = OutputOperator.new_d... | [
"0.6018097",
"0.60125196",
"0.59455025",
"0.5894086",
"0.5713274",
"0.55858445",
"0.5501646",
"0.54982245",
"0.5494143",
"0.548474",
"0.5477435",
"0.5427472",
"0.53431004",
"0.5334085",
"0.5334061",
"0.52811843",
"0.5267606",
"0.5255126",
"0.52521455",
"0.5226453",
"0.5225942... | 0.72833645 | 0 |
Returns command to remove assignment from config file | def unset_cmd
sprintf 'sed -i /%s/d %s', key_set_string, @file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_command(name)\n @commands ||= {}\n @commands.delete name\n end",
"def remove_config(name)\n\t\tend",
"def removeCommandAliases(repo)\n config = repo.config(true, '--list').lines.each do |line|\n next unless line.start_with? 'alias.' and line.match /\\!_git\\-bpf/\n a = /ali... | [
"0.65352476",
"0.6505543",
"0.61993665",
"0.615171",
"0.61218435",
"0.612007",
"0.6094497",
"0.6053946",
"0.6038202",
"0.59354615",
"0.5923372",
"0.5921481",
"0.5908367",
"0.5841326",
"0.58399504",
"0.5825802",
"0.57967013",
"0.5787193",
"0.57484883",
"0.5747127",
"0.5722159"... | 0.664374 | 0 |
This action is update exam details at the time of exam group create bacause it have a dependancies; | def update_exam(exam_group, p)
return unless p.present?
p.each do |s|
exam = Exam.where(subject_id: s, exam_group_id: exam_group.id).take
exam.destroy unless exam.nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @exam_group = ExamGroup.shod(params[:id])\n @exam_group.update(params_exam_group)\n @batch = @exam_group.batch\n @subjects = @batch.subjects.exam\n @exam_group.exams.build\n end",
"def update\n @exam = Exam.shod(params[:id])\n if @exam.update(params_exam)\n flash[:notice] ... | [
"0.7148046",
"0.6666313",
"0.65075696",
"0.64741886",
"0.643703",
"0.62673664",
"0.62630004",
"0.6207287",
"0.6192626",
"0.6178154",
"0.61411303",
"0.6140417",
"0.6131471",
"0.6131471",
"0.6131471",
"0.6131471",
"0.6131471",
"0.6131471",
"0.6131471",
"0.6131471",
"0.6131471",... | 0.6345654 | 5 |
This action perform the operation on previous exam details. exam array is created for storing the previous exam details. | def exam_details(ex)
exams_data = ex.exams.all
flag = false
exams_data.each do |exam|
exam.exam_scores.each do |es|
flag = true if es.is_failed?
end
exams << exam if flag == true
end
exams
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def previous_exam_scores\n @exam = Exam.shod(params[:format])\n @exam_scores = @exam.is_failed\n # authroize! :update, @exam\n end",
"def prev\n\t\t\t\t@index -= 1\n\t\t\t\tself._update\n\t\t\t\tself\n\t\t\tend",
"def store_previous\n end",
"def previous_history()\r\n @history_offset!=0 ? @the_... | [
"0.7099587",
"0.6062366",
"0.5898293",
"0.58408016",
"0.5803944",
"0.580328",
"0.579849",
"0.56985885",
"0.5676732",
"0.5665027",
"0.56191283",
"0.55863595",
"0.5566228",
"0.5560191",
"0.5552402",
"0.5546334",
"0.5533822",
"0.5528557",
"0.5526977",
"0.55164504",
"0.551188",
... | 0.5326191 | 35 |
This action called when user publish the result of student. In this action date is also checking i.e. result is published only if exam end date is less than today's date. | def publish(ex)
flag = false
unless ex.exams.nil?
ex.exams.each do |exam|
next if exam.end_time.nil?
flag = true if exam.end_time >= Date.today
end
end
flag
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish_result\n @exam_group = ExamGroup.shod(params[:format])\n if @exam_group.is_published?\n flag = @exam_group.publish(@exam_group)\n publish_res(flag)\n else\n flash[:alert] = 'Exam scheduled not published'\n end\n redirect_to exams_exam_group_path(@exam_group)\n end",
"de... | [
"0.7487951",
"0.66681635",
"0.66058266",
"0.64313954",
"0.63741964",
"0.63505787",
"0.63464093",
"0.6343912",
"0.6281331",
"0.61958647",
"0.6177673",
"0.61198205",
"0.60273725",
"0.6012654",
"0.6001256",
"0.5989017",
"0.5879786",
"0.58782697",
"0.57414556",
"0.5736971",
"0.56... | 0.64466536 | 3 |
find out the weightage for first record of the exam | def weightage
return unless exams.first.nil?
exams.first.weightage
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def weight\n return @weight\n end",
"def weight; end",
"def weight\n 0\n end",
"def weight\n return data.weight\n end",
"def weight\n if @weight\n @weight\n else\n @co... | [
"0.6543537",
"0.63375103",
"0.62807703",
"0.6257638",
"0.611474",
"0.60140914",
"0.60140914",
"0.59837097",
"0.59794754",
"0.59682655",
"0.5942232",
"0.5917063",
"0.5903843",
"0.58963495",
"0.58960855",
"0.5851221",
"0.58236784",
"0.5816772",
"0.57607096",
"0.57357216",
"0.56... | 0.7843295 | 0 |
Generate the result by subject id and exam group id. | def exam_data(subject)
Exam.result(subject.id, id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @exam_group = ExamGroup.shod(params[:exam_group_id])\n @batch = @exam_group.batch\n @subjects = @batch.subjects.where(no_exams: false)\n @exam = @exam_group.exams.new(params_exam)\n exam_create\n end",
"def get_group\n if params[:stu].present? && params[:sub].present?\n stude... | [
"0.5998218",
"0.59294164",
"0.5825492",
"0.56342965",
"0.55390203",
"0.54909605",
"0.54435915",
"0.5425885",
"0.53993165",
"0.5381499",
"0.53383166",
"0.53188086",
"0.53066975",
"0.53012055",
"0.52827716",
"0.5275306",
"0.5266171",
"0.5252848",
"0.52089965",
"0.52079445",
"0.... | 0.6695062 | 0 |
This action generate the result for particular student with his subject. | def exam_marks(subject, student)
exam = exam_data(subject)
exam_score = exam.scores(student)
unless exam_score.nil?
if exam.nil?
result = 'NA'
else
exam_score.nil? ? result = '-' : result = type_result(exam, exam_score)
end
result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exam_data(subject)\n Exam.result(subject.id, id)\n end",
"def get_subjects\n if params[:s].present?\n s_id = params[:s].to_i\n subjects_by_student = Subject.joins(\"INNER JOIN school_cycle_has_subjects ON subjects.id = school_cycle_has_subjects.subject_id INNER JOIN student_has_subjects ON s... | [
"0.63951766",
"0.6393098",
"0.6243874",
"0.62334514",
"0.6139165",
"0.61361897",
"0.6117635",
"0.61086035",
"0.60716087",
"0.6052132",
"0.60311127",
"0.5965464",
"0.59487104",
"0.59451336",
"0.5895375",
"0.5881867",
"0.58758503",
"0.5858257",
"0.58528626",
"0.58441246",
"0.58... | 0.5429369 | 93 |
This action manage the type of exam result i.e.Grades or Marks. | def type_result(e, es)
if exam_type == 'Grades'
es.grading_level.name || 'AB'
elsif exam_type == 'Marks'
[es.marks || 'AB', e.maximum_marks].join('/')
else
[[es.marks || 'AB', e.maximum_marks].join('/'), es.grading_level.name || '-'].join('|')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_exam_result\n @exam_result = ExamResult.find(params[:id])\n end",
"def set_results\n @exam = Exam.find(params[:exam_id])\n end",
"def result\n @exam = current_exam(params)\n\n @exam_reporter = @exam.evaluate(params[:answers])\n end",
"def exam_result\n if params[:exam_id]\n ... | [
"0.620552",
"0.6189071",
"0.6129202",
"0.60192055",
"0.5950334",
"0.59310293",
"0.58985204",
"0.58715355",
"0.58357334",
"0.57796127",
"0.576083",
"0.57585895",
"0.57585895",
"0.56722754",
"0.565495",
"0.5603482",
"0.55952436",
"0.5567693",
"0.55228853",
"0.54315674",
"0.5425... | 0.64122814 | 0 |
Calculate the total score for subject. | def exam_total(subject, total)
exam = exam_data(subject)
return if exam.nil?
total.to_f + exam.maximum_marks.to_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score\n @subject.score\n end",
"def total_score\n\t\t0 + score_one.to_i + score_two.to_i + score_three.to_i + score_four.to_i\n\tend",
"def total_score\n plays.inject(0) { |sum, word| sum + Scoring.score(word) }\n end",
"def get_total_score\n scores.map(&:score).sum\n end",
"def get_tot... | [
"0.7412788",
"0.7293385",
"0.7287903",
"0.7121858",
"0.7106809",
"0.702995",
"0.69775045",
"0.69596213",
"0.69345564",
"0.68649745",
"0.6834966",
"0.6789869",
"0.67487013",
"0.6735753",
"0.6709669",
"0.6680427",
"0.6653593",
"0.6645651",
"0.6567231",
"0.6567094",
"0.6565219",... | 0.72159237 | 3 |
Calculating the exam marks. | def exam_mar(subject, student, marks)
exam = exam_data(subject)
exam_score = exam.scores(student)
return if exam.nil?
marks.to_f + exam_score.marks.to_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exam_marks(subject, student)\n exam = exam_data(subject)\n exam_score = exam.scores(student)\n unless exam_score.nil?\n if exam.nil?\n result = 'NA'\n else\n exam_score.nil? ? result = '-' : result = type_result(exam, exam_score)\n end\n result\n end \n end",
... | [
"0.7437175",
"0.69961363",
"0.6912861",
"0.66114014",
"0.6560791",
"0.6390787",
"0.63760436",
"0.62102973",
"0.6148726",
"0.5929783",
"0.5929743",
"0.58902735",
"0.5840896",
"0.58071953",
"0.5787153",
"0.5777845",
"0.5758071",
"0.57267874",
"0.57106924",
"0.5695518",
"0.56823... | 0.70685697 | 1 |
GET /posts GET /posts.json | def index
@posts = Post.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n ... | [
"0.7865315",
"0.7494904",
"0.7494433",
"0.7494433",
"0.7488696",
"0.74314564",
"0.728645",
"0.728645",
"0.728645",
"0.72562826",
"0.72522277",
"0.7247287",
"0.7246305",
"0.72221965",
"0.72042215",
"0.72039723",
"0.7169929",
"0.71689725",
"0.71644753",
"0.7121855",
"0.71152896... | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
@post = Post.find(params[:id])
f= open("#{root_url}#{@post.image}")
@picture = EXIFR::JPEG.new(f)
@latitude=convert_to_google(@picture.exif.to_hash[:gps_latitude],
@picture.exif.to_hash[:gps_latitude_ref])
@longitude=convert_to_google(@picture.exif.to_hash[:gps_longitude],
@picture.exif.to_hash[:gps_longitude_ref])
if geo = Geocoder.search("#{@latitude},#{@longitude}").first
@city = geo.city || ""
@state = geo.state || ""
@zipcode = geo.postal_code || ""
end
# and in the view : <% @picture.exif.to_hash.each do |key, value| %>
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
... | [
"0.77110183",
"0.73537844",
"0.73433185",
"0.73379177",
"0.73228735",
"0.7293139",
"0.7275997",
"0.7256934",
"0.7161576",
"0.7158913",
"0.71552676",
"0.71552676",
"0.7119547",
"0.7094749",
"0.7094749",
"0.7094749",
"0.70943594",
"0.7071599",
"0.70607626",
"0.70452625",
"0.703... | 0.0 | -1 |
GET /posts/new GET /posts/new.json | def new
@post = Post.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n @post = Post.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\... | [
"0.8041974",
"0.80156785",
"0.79855186",
"0.7931169",
"0.79215",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(params[:post].merge!(:user => current_user))
if @post.save
flash[:notice] = 'Your post has been created.'
redirect_to root_path
else
render action: "new"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74463975",
"0.73221767",
"0.73072433",
"0.7123966",
"0.7015686",
"0.701327",
"0.69841874",
"0.6939327",
"0.69313824",
"0.69053805",
"0.68196476",
"0.6812792",
"0.6793222",
"0.6792862",
"0.6779654",
"0.6779654",
"0.67625546",
"0.67602354",
"0.67515427",
"0.6735786",
"0.6698... | 0.0 | -1 |
PUT /posts/1 PUT /posts/1.json | def update
@post = Post.find(params[:id])
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n title = params[:title]\n body ... | [
"0.7308219",
"0.7123652",
"0.68159384",
"0.66432106",
"0.66181636",
"0.6607148",
"0.6583982",
"0.6564183",
"0.6552021",
"0.6532697",
"0.6511846",
"0.64877653",
"0.6446283",
"0.64321554",
"0.64155626",
"0.638547",
"0.63833165",
"0.63661736",
"0.63641906",
"0.6363359",
"0.63632... | 0.6165114 | 64 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"... | 0.7428427 | 54 |
GET /venue_products/1 GET /venue_products/1.json | def show
@venue_product = VenueProduct.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @venue_product }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end",
"def show\n json_response(@api_v1_product)\n end",
"def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\n #@vendors = Vendor.find(params[:id])\n #@vendors = Vendor.al... | [
"0.743204",
"0.730987",
"0.7213589",
"0.70481384",
"0.7044168",
"0.7021765",
"0.6987864",
"0.69718915",
"0.69664615",
"0.68962646",
"0.68946964",
"0.68872815",
"0.68672884",
"0.6861995",
"0.6859079",
"0.6854056",
"0.68468815",
"0.6840597",
"0.6788395",
"0.6785125",
"0.6762956... | 0.77853984 | 0 |
GET /venue_products/new GET /venue_products/new.json | def new
@venue_product = VenueProduct.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @venue_product }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @product = Product.new\n\n render json: @product\n end",
"def new\n @product = ProductProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product }\n end\n end",
"def new\n @product = Product.new\n\n respond_to do |format|... | [
"0.7708331",
"0.75812113",
"0.7542354",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
"0.7541824",
... | 0.79925734 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.