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 |
|---|---|---|---|---|---|---|
when :no_raise => true and the validation fails, an array is returned listing the 'deviations' | def test_no_raise
r = Ruote.filter(
[ { 'field' => 'x', 't' => 'hash', 'has' => 'a' } ],
{ 'x' => %w[ a b c ] },
:no_raise => true)
assert_equal(
[ [ { "has" => "a", "field" => "x", "t" => "hash"}, "x", [ "a", "b", "c" ] ] ],
r)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_invalids\n\t\treturn @invalids\n\tend",
"def validations\n []\n end",
"def get_validate data\n data.values.flatten\n end",
"def validate(_options = 0)\n []\n end",
"def invalidations\n if @solver and invalidations = @solver.invalidations\n invalidations\n ... | [
"0.63097167",
"0.6293907",
"0.61331475",
"0.6056487",
"0.6026165",
"0.5996127",
"0.597741",
"0.5968141",
"0.5892118",
"0.5881377",
"0.58289206",
"0.5689792",
"0.5637729",
"0.561269",
"0.5610069",
"0.5550691",
"0.55502665",
"0.5539877",
"0.5533672",
"0.55164504",
"0.5509881",
... | 0.0 | -1 |
Data passes through the filter untouched. | def test_no_raise_empty_result
r = Ruote.filter(
[ { 'field' => 'x', 't' => 'array', 'has' => 'a' } ],
{ 'x' => %w[ a b c ] },
:no_raise => true)
assert_equal(
{ 'x' => %w[ a b c ] },
r)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filter\n end",
"def filter (data)\n # leave the data untouched if we don't support the required filter\n return data if @filter.nil?\n\n # decode the data\n self.send(@filter, data)\n end",
"def filter\n end",
"def filter\n super\n end",
"def preprocess_data\n... | [
"0.73198223",
"0.727851",
"0.6986365",
"0.69258344",
"0.68093973",
"0.67999554",
"0.67747253",
"0.67747253",
"0.67747253",
"0.66480863",
"0.6638826",
"0.65939313",
"0.6557193",
"0.64786696",
"0.6453575",
"0.6348987",
"0.63480335",
"0.63480335",
"0.6346679",
"0.6346679",
"0.63... | 0.0 | -1 |
Returns a list of repository names which match `regexp` | def repository_names
list_repos
.select { |repo| repo["name"] =~ regexp }
.map { |repo| repo["name"] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(*pattern)\n pattern = pattern.join('*')\n pattern << '*' unless pattern =~ /\\*$/\n \n packages = []\n @repositories.select{|label,_| @active.include? label }.each do |label, repos|\n repos.each do |repo|\n packages.concat(repo.scan(pattern))\n end\n en... | [
"0.6415419",
"0.5925132",
"0.5876544",
"0.5816987",
"0.58096206",
"0.5753673",
"0.57511854",
"0.573421",
"0.5671197",
"0.5576498",
"0.55317396",
"0.5436508",
"0.5408711",
"0.5378251",
"0.53703976",
"0.53390735",
"0.53325284",
"0.53101224",
"0.5300954",
"0.52593154",
"0.523897... | 0.7954824 | 0 |
TODO: figure out a way to only fetch cloudplatform repos deduplicate the code filter out archived repos filter out disabled repos | def list_repos
repos = []
end_cursor = nil
data = get_repos(end_cursor)
repos = repos + data.fetch("nodes")
next_page = data.dig("pageInfo", "hasNextPage")
end_cursor = data.dig("pageInfo", "endCursor")
while next_page do
data = get_repos(end_cursor)
repos = repos + data.fetch("nodes")
next_page = data.dig("pageInfo", "hasNextPage")
end_cursor = data.dig("pageInfo", "endCursor")
end
repos.reject { |r| r.dig("isArchived") || r.dig("isDisabled") }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end",
"def get_qualifying_repos\n if !authe... | [
"0.7197054",
"0.716235",
"0.70380896",
"0.7015823",
"0.698643",
"0.6893655",
"0.6891649",
"0.6846303",
"0.6794351",
"0.6733624",
"0.6726266",
"0.66737413",
"0.6654283",
"0.6618503",
"0.657773",
"0.65514547",
"0.65508056",
"0.6537788",
"0.65242136",
"0.65232396",
"0.6492289",
... | 0.6827068 | 8 |
TODO: it should be possible to exclude disabled/archived repos in this query, but I don't know how to do that yet, so I'm just fetching everything and throwing away the disabled/archived repos later. We should also be able to only fetch repos whose names match the pattern we're interested in, at this stage. | def repositories_query(end_cursor)
after = end_cursor.nil? ? "" : %[, after: "#{end_cursor}"]
%[
{
organization(login: "#{organization}") {
repositories(first: #{PAGE_SIZE} #{after}) {
nodes {
id
name
isLocked
isArchived
isDisabled
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_repo(query)\n repos = load_and_cache_user_repos\n results = repos.select do |repo|\n repo['name'] =~ Regexp.new(query, 'i')\n end\n results += search_all_repos(query) if query =~ %r{\\/}\n results.uniq\n end",
"def all\n repos = self.class.load_json(repos_url)\n repos.map! {... | [
"0.68310064",
"0.62287444",
"0.61612755",
"0.615109",
"0.61489034",
"0.60716134",
"0.6066253",
"0.6058215",
"0.60254276",
"0.6024868",
"0.5990243",
"0.59705055",
"0.5933787",
"0.592065",
"0.5862471",
"0.5850512",
"0.5804467",
"0.5788592",
"0.576378",
"0.574639",
"0.57455117",... | 0.0 | -1 |
POST /resume_responses POST /resume_responses.json | def create
@resume_response = ResumeResponse.new(params[:resume_response])
@resume = Resume.find(params[:id])
@resume_response.resume = @resume
@resume_response.sender = @current_user
@resume_response.recipient = @resume.user
respond_to do |format|
if @resume_response.save
format.html { redirect_to home_path, notice: 'Отклик на резюме отправлен.' }
format.json { render json: @resume_response, status: :created, location: @resume_response }
else
format.html { render action: "new" }
format.json { render json: @resume_response.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @resume = Resume.new(complete_params)\n\n if @resume.save\n render json: @resume, status: :created, location: @resume\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end",
"def create\n # puts \"params: #{params}\"\n @resume = Resume.new(resum... | [
"0.62504464",
"0.6080155",
"0.608008",
"0.5836236",
"0.56991637",
"0.5662001",
"0.56454825",
"0.559175",
"0.5591531",
"0.55848736",
"0.55781996",
"0.55646473",
"0.54927504",
"0.54587626",
"0.5437681",
"0.54322886",
"0.5403665",
"0.5387826",
"0.53571653",
"0.534868",
"0.532208... | 0.66263586 | 0 |
PUT /resume_responses/1 PUT /resume_responses/1.json | def update
@resume_response = ResumeResponse.find(params[:id])
respond_to do |format|
if @resume_response.update_attributes(params[:resume_response])
format.html { redirect_to @resume_response, notice: 'Resume response was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @resume_response.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @resume = Resume.find(params[:id])\n\n if @resume.update(resume_params)\n head :no_content\n else\n render json: @resume.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @resume.update(resume_params)\n render :show, status: :ok, location: @resume\n ... | [
"0.69537973",
"0.670963",
"0.66101074",
"0.6558063",
"0.65337616",
"0.6533588",
"0.6477582",
"0.64378995",
"0.64275306",
"0.64152503",
"0.6326686",
"0.6326686",
"0.61933714",
"0.6096429",
"0.6090138",
"0.60326844",
"0.60326844",
"0.60326844",
"0.5991478",
"0.5970573",
"0.5932... | 0.6987272 | 0 |
DELETE /resume_responses/1 DELETE /resume_responses/1.json | def destroy
@resume_response = ResumeResponse.find(params[:id])
@resume_response.destroy
respond_to do |format|
format.html { redirect_to resume_responses_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @resume.destroy\n respond_to do |format|\n format.html { redirect_to resumes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resume = Resume.find(params[:id])\n @resume.destroy\n\n respond_to do |format|\n format.html { redirect_to resumes_ur... | [
"0.7259041",
"0.7218649",
"0.706997",
"0.70453155",
"0.69963515",
"0.682667",
"0.6775077",
"0.6739571",
"0.671595",
"0.6699357",
"0.66386527",
"0.65893275",
"0.6587377",
"0.6587377",
"0.6586315",
"0.6581614",
"0.6569374",
"0.6550289",
"0.65401787",
"0.65401787",
"0.6531026",
... | 0.7750977 | 0 |
Create a network of adjacency information from the text. | def initialize(*args)
super
# Save parameters
if focal_word
self.focal_word = focal_word.mb_chars.downcase.to_s
self.focal_word_stem = focal_word.stem
end
# Extract the stop list if provided
self.stop_words = []
if language
self.stop_words = RLetters::Analysis::StopList.for(language)
end
# Clear final attributes
self.nodes = []
self.edges = []
# Run the analysis for each of the gaps
gaps.each_with_index do |g, i|
add_nodes_for_gap(g)
progress&.call((i + 1).to_f / gaps.size.to_f * 100.0)
end
# Final progress tick
progress&.call(100)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_graph(input)\n dg = RGL::AdjacencyGraph[]\n lines = input.split(\"\\n\")\n n = lines[0].to_i\n for i in 1..n do\n data = lines[i].split(\" \")\n next if data[0].to_i <= 0\n data.shift # break data\n data.each{|v| dg.add_edge i, v.to_i }\n end\n dg\nend",
"def build_graph\n gr... | [
"0.65148467",
"0.60605776",
"0.60012543",
"0.59061736",
"0.5707614",
"0.5691291",
"0.5586348",
"0.55596614",
"0.5475822",
"0.54417366",
"0.5420953",
"0.5388463",
"0.52574134",
"0.52276725",
"0.52225196",
"0.5193617",
"0.51821226",
"0.51821226",
"0.5180534",
"0.51776534",
"0.5... | 0.0 | -1 |
Find a word by its id or its word coverage | def find_node(options)
options[:id] = options.delete(:stem) if options[:stem]
unless options[:word] || options[:id]
raise ArgumentError, 'no find option specified'
end
if options[:word]
word = options[:word].mb_chars.downcase.to_s
nodes.find do |n|
n.words.include?(word)
end
else
id = options[:id].mb_chars.downcase.to_s
nodes.find do |n|
n.id == id
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(word)\n findBy :word_text, word\n end",
"def find_by_word(word)\n @wordlist[word] if word_exists?(word)\n end",
"def search(word)\n \n end",
"def get_word_id\n word = @text.downcase.singularize\n @word_id = EnglishWords.find_by(english_meaning: word)\n return @word_id\... | [
"0.7096285",
"0.67018825",
"0.6616555",
"0.65546274",
"0.65493053",
"0.6429672",
"0.64178467",
"0.64008355",
"0.63831544",
"0.63143986",
"0.6227664",
"0.62243813",
"0.62014973",
"0.61573446",
"0.6040242",
"0.60146827",
"0.6007114",
"0.60044944",
"0.5981046",
"0.5947938",
"0.5... | 0.5525924 | 62 |
Find the edge connecting the two specified nodes, if it exists Note that our edges are undirected, so the order of the parameters `one` and `two` is not meaningful. | def find_edge(one, two)
edges.find do |e|
(e.one == one && e.two == two) || (e.two == one && e.one == two)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_edge(node_1, node_2)\n @edges[node_1][node_2] if @edges[node_1]\n end",
"def find_or_add_edge(one, two)\n edge = find_edge(one, two)\n if edge\n edge.weight += 1\n edge\n else\n edges << Edge.new(one: one, two: two, weight: 1)\n ... | [
"0.7645755",
"0.7172728",
"0.68479484",
"0.66183007",
"0.6327788",
"0.6204899",
"0.6167555",
"0.61288065",
"0.6118278",
"0.61089617",
"0.60141027",
"0.60141027",
"0.60116744",
"0.5994023",
"0.5950963",
"0.5850298",
"0.58221346",
"0.58221346",
"0.5820249",
"0.5803314",
"0.5759... | 0.8362846 | 0 |
Return the maximum edge weight in the graph | def max_edge_weight
edges.map(&:weight).max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_max_score\n max_score * weight\n end",
"def maxweight(w)\n @weight = w if w>@weight\n end",
"def edge_weight(start_node, end_node)\n relationships = @adj_list[start_node]\n relationships.length.times do |r|\n relationship = relationships.read(r)\n return relationship.we... | [
"0.7142364",
"0.7119911",
"0.6974494",
"0.6931505",
"0.6800333",
"0.6675541",
"0.655177",
"0.64820033",
"0.6364242",
"0.6350356",
"0.6324943",
"0.6283164",
"0.6260426",
"0.6222856",
"0.6222856",
"0.6164321",
"0.6162874",
"0.61587054",
"0.61587054",
"0.6118615",
"0.61082864",
... | 0.92122024 | 0 |
Add nodes and edges for a given gap This function adds nodes and edges to the graph for a given size of sliding window. | def add_nodes_for_gap(gap)
analyzer = Frequency.call(
dataset: dataset,
ngrams: gap,
num_blocks: 1,
split_across: true,
progress: ->(p) { progress&.call((p.to_f / 100 * 33).to_i + 33) }
)
ngrams = analyzer.blocks[0]
ngrams.each do |(gram, _)|
gram_words = gram.split(' ')
stemmed_gram_words = gram_words.map(&:stem)
next if focal_word && !stemmed_gram_words.include?(focal_word_stem)
nodes = stemmed_gram_words.zip(gram_words).map do |w|
find_or_add_node(*w)
end
nodes.combination(2).each do |pair|
find_or_add_edge(pair[0].id, pair[1].id)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increase_gap\n\n @gap = @gap + 50\n\n end",
"def increase_gap\n\n @gap = @gap + 50\n\n end",
"def create_knight_tour_graph(board_size)\n new_graph = Graph.new()\n board_size.times do |x|\n board_size.times do |y|\n new_graph.add_vertex([x,y])\n end\n end\n knight_legal_moves(new_grap... | [
"0.552551",
"0.552551",
"0.5385118",
"0.4994156",
"0.49828216",
"0.49427024",
"0.4939581",
"0.48757485",
"0.48162365",
"0.47926322",
"0.47401768",
"0.47324634",
"0.47183073",
"0.4689046",
"0.46799418",
"0.46649724",
"0.4655176",
"0.4638918",
"0.46381128",
"0.46278125",
"0.462... | 0.6652222 | 0 |
Find a node and return it, or add it if needed | def find_or_add_node(id, word)
node = find_node(id: id)
if node
node.words << word unless node.words.include?(word)
node
else
nodes << Node.new(id: id, words: [word])
nodes.last
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_node(*args)\n node = @nodes.find_node(*args)\n node if context?(node)\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n ... | [
"0.7215733",
"0.70468134",
"0.70468134",
"0.70105124",
"0.6986623",
"0.679843",
"0.67912114",
"0.6739654",
"0.6701905",
"0.6690912",
"0.66753453",
"0.66639364",
"0.6650414",
"0.6626188",
"0.6600094",
"0.6599497",
"0.6557516",
"0.655419",
"0.6541449",
"0.64871466",
"0.64793766... | 0.69655776 | 5 |
Find an edge and increment its weight, or add it if needed | def find_or_add_edge(one, two)
edge = find_edge(one, two)
if edge
edge.weight += 1
edge
else
edges << Edge.new(one: one, two: two, weight: 1)
edges.last
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hyperball_on_edge(edge)\n update_node = @counters.get_counter(edge[1])\n neighbor_node = @counters.get_counter(edge[0])\n\n update_node.merge(neighbor_node)\n end",
"def add_edge(node, weight)\n @adjacent_nodes[node.value] = { weight: weight, node: node }\n self\n end",
"def add_edge(sou... | [
"0.68839383",
"0.68835115",
"0.68623716",
"0.6738664",
"0.66191673",
"0.65683854",
"0.65471256",
"0.6526162",
"0.6449443",
"0.644654",
"0.64417714",
"0.6428381",
"0.6422983",
"0.6420932",
"0.63979197",
"0.6375651",
"0.6351983",
"0.6310793",
"0.62784505",
"0.6257984",
"0.62551... | 0.74529654 | 0 |
The algorithm adds leaf nodes in order | def addLeaf(node, value, offset)
result = newChild(node, value, @suffixOffset, offset, Node::CURRENT_ENDING_OFFSET)
# optional configuration based properties
result.leafCount = 1 if (@configuration[:leafCount])
result.previousValue = (@dataSource.valueAt(@suffixOffset - 1)) if ((@suffixOffset > 0) && @configuration[:previousValue])
result.dataSourceBit = @dataSourceBit if @configuration[:dataSourceBit]
@suffixOffset += 1
if ((@nextDataSourceSwitch != nil) && ((@suffixOffset % @nextDataSourceSwitch) == 0)) then
self.nextDataSourceBit
end
persist(result)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_leaf(leaf, defer_update = false)\n raise \"node is not lowest level and can therefore not get a leaf: #{self}\" unless lowest_level?\n children.insert(children.find_index {|child| child.shash > leaf.shash} || -1, leaf) #insertion_sort here\n leaf.parent = self\n divide_if_needed... | [
"0.7001168",
"0.692979",
"0.6651891",
"0.6468201",
"0.63526684",
"0.6251386",
"0.6214225",
"0.6214225",
"0.62011975",
"0.6180848",
"0.61718875",
"0.61216074",
"0.60703385",
"0.60478944",
"0.6040133",
"0.60288537",
"0.60275966",
"0.5959344",
"0.59506744",
"0.5942456",
"0.59424... | 0.0 | -1 |
return a sequence of all values on the path to this node | def valuePath(node, delimiter=' ')
result = []
while (node.parent != nil) do
reverseAddValues(result, node.incomingEdgeStartOffset, node.incomingEdgeEndOffset)
node = node.parent
end
result.reverse!
return result.join(delimiter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values\n @children\n end",
"def values\n root.values\n end",
"def values\n attribute_nodes.map(&:value)\n end",
"def each\n return [] if root.nil?\n root.traverse do |node|\n yield node.value\n end\n end",
"def values\n if node_type == :leaf\n ... | [
"0.7139397",
"0.6800723",
"0.66421354",
"0.6624869",
"0.654528",
"0.6463912",
"0.6463803",
"0.6463803",
"0.64038974",
"0.6389843",
"0.6373345",
"0.6357579",
"0.6349133",
"0.63451654",
"0.6336964",
"0.63289005",
"0.6327196",
"0.6311051",
"0.63000196",
"0.62671226",
"0.6247252"... | 0.6242129 | 21 |
return edge value sequence in reverse (used when getting path to root from a node) | def reverseAddValues(result, startOffset, endOffset)
if (endOffset == Node::CURRENT_ENDING_OFFSET) then
result << @dataSource.valueAt(startOffset)
else
scanner = endOffset
while (scanner >= startOffset) do
result << @dataSource.valueAt(scanner)
scanner -= 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse\n\t self.class.new(*(edges.reverse.map! {|edge| edge.reverse! }))\n\tend",
"def reverse_direction node\n case node\n when :up\n :down\n when :down\n :up\n when :left\n :right\n when :right\n :left\n else\n nil\n end\n end",
... | [
"0.66804945",
"0.6627718",
"0.6606265",
"0.6590033",
"0.6417159",
"0.6351281",
"0.6344506",
"0.62929296",
"0.6169757",
"0.60766906",
"0.604789",
"0.6007824",
"0.600764",
"0.600764",
"0.6007551",
"0.5992082",
"0.59778845",
"0.5970679",
"0.59269124",
"0.5868154",
"0.5859796",
... | 0.0 | -1 |
1 84 12 76 451 089 46 46 = (97 1841276451089) % 97 remainder of the division of (97 ssn_without_key) by 97 | def valid_key?(match_data)
match_data[:key].to_i == (97 - match_data[1..-2].join.to_i) % 97
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(key, size)\n #true_index = hash(key) % k\n code = 0\n key.split(%r{\\s*}).each do |letter|\n code += letter.ord \n end\n puts code\n return code % size\n\n end",
"def ssn_key_valid?(ssn_number)\n key = ssn_number[-2..-1].to_i\n ssn_without_key = ssn_number[0..-3].delete(\" \")... | [
"0.68382895",
"0.680752",
"0.6728683",
"0.66868496",
"0.6550961",
"0.6449259",
"0.6264985",
"0.6228745",
"0.62222534",
"0.6213291",
"0.61714464",
"0.61265904",
"0.6108481",
"0.6100893",
"0.60812724",
"0.60812724",
"0.60565156",
"0.60534143",
"0.60465074",
"0.60419214",
"0.602... | 0.56110144 | 72 |
Returns an array of items which have a paid quantity greater than zero. That is, any items which have nonbonus components. | def candidate_items
sku_items.select {|i| i.paid_quantity > 0}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items_no_sale\r\n sale = Array.new\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (!val.is_active )\r\n sale.push(val)\r\n end\r\n }\r\n end\r\n\r\n return sale\r\n end",
"def get_products_bought\n res = []\n\n @data.p... | [
"0.6286385",
"0.61376476",
"0.61366105",
"0.60251176",
"0.58752483",
"0.5799775",
"0.5756575",
"0.57485896",
"0.57201076",
"0.57199156",
"0.5716697",
"0.5714918",
"0.56775546",
"0.565848",
"0.5619463",
"0.56134444",
"0.56097525",
"0.55814415",
"0.55751985",
"0.5562453",
"0.55... | 0.7494559 | 0 |
The promotions that have been applied since the order was last serialised. | def new_promotions
@new_promotions ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promotions\n @promotions ||= order.promotions\n end",
"def pending_promotions\n @pending_promotions ||= []\n end",
"def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert ... | [
"0.74322355",
"0.64474356",
"0.6032609",
"0.5961645",
"0.59524673",
"0.58857894",
"0.5866804",
"0.5596451",
"0.55283207",
"0.54836804",
"0.54635763",
"0.5424442",
"0.53949225",
"0.53949225",
"0.53160316",
"0.52711594",
"0.526471",
"0.5252012",
"0.5236463",
"0.52051806",
"0.51... | 0.62009275 | 2 |
Checks to see if any new promotions have been applied to the order. | def new_promotions?
!new_promotions.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def existing_promotions?\n !existing_promotions.empty?\n end",
"def pending_promotions?\n !pending_promotions.empty?\n end",
"def checkout_promotions?\n !checkout_promotions.empty?\n end",
"def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).cal... | [
"0.70721054",
"0.7056001",
"0.69980675",
"0.6493094",
"0.63931346",
"0.63828385",
"0.6347391",
"0.61738896",
"0.60555255",
"0.59602386",
"0.5910393",
"0.5874006",
"0.5748538",
"0.5730938",
"0.5692966",
"0.5688312",
"0.5688093",
"0.56499726",
"0.56438255",
"0.56414473",
"0.563... | 0.7135606 | 0 |
Retrieve the promotions that have been applied, but before the order is persisted. | def pending_promotions
@pending_promotions ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promotions\n @promotions ||= order.promotions\n end",
"def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promot... | [
"0.80131304",
"0.7216369",
"0.6728518",
"0.6685051",
"0.6642239",
"0.6181208",
"0.6127939",
"0.60987204",
"0.5899521",
"0.5784074",
"0.5725257",
"0.548562",
"0.5454655",
"0.5454505",
"0.54490453",
"0.54270303",
"0.54270303",
"0.54270303",
"0.5412441",
"0.5309505",
"0.52762616... | 0.6606123 | 5 |
Checks to see if there are any promotions pending/applied to the order. | def pending_promotions?
!pending_promotions.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout_promotions?\n !checkout_promotions.empty?\n end",
"def existing_promotions?\n !existing_promotions.empty?\n end",
"def pending_promotions\n @pending_promotions ||= []\n end",
"def related_promotions?\n !related_promotions.empty?\n end",
"def new_promotions?\n !new_pr... | [
"0.7250044",
"0.6820905",
"0.67420924",
"0.6575087",
"0.63620156",
"0.62685466",
"0.6214691",
"0.62023866",
"0.6189956",
"0.61802685",
"0.61587554",
"0.61482704",
"0.614073",
"0.61390716",
"0.61282104",
"0.61171407",
"0.6091816",
"0.60823596",
"0.6051234",
"0.6018808",
"0.600... | 0.7923248 | 0 |
Any promotions that have been previously applied to the order. | def existing_promotions
@existing_promotions ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promotions\n @promotions ||= order.promotions\n end",
"def apply_promotions!\n raise PromotionApplyError unless pending_promotions.empty?\n @promotion_results = Promotion.active.apply!(self)\n apply_adjustments!\n\n # Convert all the applied promotions into an array of decorated\n # promot... | [
"0.7774569",
"0.71423966",
"0.64846826",
"0.64373976",
"0.6110704",
"0.6079696",
"0.59247124",
"0.5845418",
"0.57443726",
"0.56175625",
"0.5494148",
"0.5487398",
"0.54260784",
"0.5349717",
"0.53291535",
"0.5309231",
"0.52346736",
"0.5227379",
"0.52169615",
"0.52048796",
"0.51... | 0.6589946 | 2 |
Checks for any promotions that have already been applied to the order. | def existing_promotions?
!existing_promotions.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promotions\n @promotions ||= order.promotions\n end",
"def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end",
"def checkout_promotions?\n !checkout_promotions.empty?\n end",
"def pending_promotions?\n ... | [
"0.66147894",
"0.6596519",
"0.65890914",
"0.65631324",
"0.6498255",
"0.634031",
"0.6302131",
"0.62207687",
"0.60311466",
"0.6003467",
"0.5800548",
"0.5784076",
"0.5779233",
"0.57785434",
"0.56835026",
"0.5454023",
"0.5436384",
"0.5376852",
"0.53672314",
"0.5353282",
"0.529693... | 0.6743173 | 0 |
Returns the results from checking promotions. | def promotion_results
@promotion_results ||= Promotions::CheckResultCollection.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_promotions\n line_items.each do |item|\n Spree::ItemAdjustments.new(item).calculate_promo_total\n end\n end",
"def result_of_checking; end",
"def effects\n results = []\n \n if @difficulty\n results << \"Success\" if result >= @difficulty\n end\n \n... | [
"0.6750584",
"0.620899",
"0.5768815",
"0.5749897",
"0.5721719",
"0.5678921",
"0.56720024",
"0.5670942",
"0.5648633",
"0.5573138",
"0.5554325",
"0.5480299",
"0.5477295",
"0.54757434",
"0.5419931",
"0.53364265",
"0.53291214",
"0.5318578",
"0.5292041",
"0.5289208",
"0.5272878",
... | 0.58418167 | 2 |
An array of IDs of the promotions that have been applied, used to dump the previous promotion state to session. | def promotion_id_dump
pending_promotions.map(&:id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def previous_promotion_ids\n @previous_promotion_ids ||= []\n end",
"def promotion_id_dump=(ids)\n @previous_promotion_ids = ids.map(&:to_i)\n end",
"def existing_promotions\n @existing_promotions ||= []\n end",
"def pending_promotions\n @pending_promotions ||= []\n end",
"def promotions\n ... | [
"0.69574535",
"0.6845519",
"0.6559235",
"0.6446942",
"0.64211804",
"0.64093024",
"0.63725805",
"0.6210528",
"0.60376173",
"0.5691419",
"0.56717986",
"0.56485",
"0.55175287",
"0.55175287",
"0.55175287",
"0.5483183",
"0.546651",
"0.54416454",
"0.54339087",
"0.54246724",
"0.5387... | 0.71284246 | 0 |
When loading up an order from session, this accessor is used to cache the previous promotion state: | def promotion_id_dump=(ids)
@previous_promotion_ids = ids.map(&:to_i)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_order\n @current_order ||= load_order_from_session unless @current_order == false\n end",
"def store!\n session['order'] = unpromoted_order.dump\n end",
"def unpromoted_order\n @unpromoted_order ||= if session['order']\n OrderBasket.load(session['order'])\n else\n ... | [
"0.6729885",
"0.65770745",
"0.64915246",
"0.6378865",
"0.6232437",
"0.6157209",
"0.6114791",
"0.6102917",
"0.6048155",
"0.5995375",
"0.57756704",
"0.5747136",
"0.5747136",
"0.5727835",
"0.572282",
"0.5688659",
"0.5673539",
"0.5666001",
"0.5639347",
"0.562938",
"0.5616615",
... | 0.0 | -1 |
Returns the IDs of promotions that were previously applied to the order. | def previous_promotion_ids
@previous_promotion_ids ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promotions\n @promotions ||= order.promotions\n end",
"def promotion_id_dump\n pending_promotions.map(&:id)\n end",
"def existing_promotions\n @existing_promotions ||= []\n end",
"def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end",
"def pending... | [
"0.70147043",
"0.60357255",
"0.60298723",
"0.5873947",
"0.57972443",
"0.5661478",
"0.56314117",
"0.55912",
"0.55706793",
"0.55138034",
"0.5462903",
"0.5376086",
"0.5363145",
"0.5344974",
"0.5310175",
"0.52990013",
"0.5268256",
"0.5255847",
"0.5232396",
"0.52301896",
"0.520399... | 0.66303337 | 1 |
Checks to see if there is a code promotion applied to the order and that it is successful. | def code_promotion_successful?
promotion_results.code_based.successful?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code_promotion_failed?\n !promo_code.blank? and promotion_results.code_based.failed?\n end",
"def test_say_if_is_discounted\n setup_new_order_with_items()\n promo = promotions(:percent_rebate)\n \n assert !@order.is_discounted?\n @order.promotion_code = promo.code\n assert @order.is_dis... | [
"0.6988479",
"0.6475755",
"0.6407527",
"0.63245493",
"0.6290344",
"0.6088696",
"0.5954468",
"0.58843946",
"0.58774066",
"0.58522063",
"0.5848439",
"0.5763855",
"0.5736762",
"0.5692154",
"0.5674695",
"0.5666807",
"0.5659416",
"0.5636786",
"0.5635909",
"0.5598773",
"0.55513275"... | 0.7242866 | 0 |
Checks to see if there is a promotion code set against this order. If it is nil, then code promotions are pending i.e. haven't been checked yet. | def code_promotion_unchecked?
promo_code.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code_promotion_failed?\n !promo_code.blank? and promotion_results.code_based.failed?\n end",
"def code_promotion_successful?\n promotion_results.code_based.successful?\n end",
"def check_for_coupon\n coupon = self.orders.where(state: \"paused\").first.coupon\n valid_coupon = Coupon.is_valid?(... | [
"0.63372177",
"0.6250729",
"0.6246687",
"0.6083889",
"0.6052146",
"0.60324043",
"0.60162807",
"0.6010615",
"0.59483963",
"0.5901427",
"0.5697834",
"0.56523883",
"0.5642045",
"0.5545806",
"0.54634845",
"0.5440411",
"0.5435848",
"0.54229414",
"0.5417677",
"0.53852314",
"0.53498... | 0.68784934 | 0 |
Checks to see if a promotion code has been entered, promotions have been applied and that the order has failed to qualify for any code based promotions. | def code_promotion_failed?
!promo_code.blank? and promotion_results.code_based.failed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_and_standalone_promo?\n # Guard clause to ensure promo code is definitely a standalone promo\n return unless promotion.stand_alone_promo(self[:promotion_id])\n if !promotions.empty? && !promotions.map(&:standalone).include?(true)\n return errors.add(:promotion_id, '..other promo exists!')\... | [
"0.66064394",
"0.6550816",
"0.6235409",
"0.6210746",
"0.6102948",
"0.6055292",
"0.6046318",
"0.58865774",
"0.5851954",
"0.5834576",
"0.5752221",
"0.5730365",
"0.57057464",
"0.5651144",
"0.56200117",
"0.56192803",
"0.55841076",
"0.55555713",
"0.5551097",
"0.55111104",
"0.55062... | 0.74688196 | 0 |
Attempts to apply promotions to this order. It'll return any promotions it successfully applies. | def apply_promotions!
raise PromotionApplyError unless pending_promotions.empty?
@promotion_results = Promotion.active.apply!(self)
apply_adjustments!
# Convert all the applied promotions into an array of decorated
# promotions.
@pending_promotions = applied_promotions.map {|p| ::Promotions::Decorator.new(p.promotion)}
# If no promotions have been added to the order, they're all new.
# Otherwise generate a new collection which is the difference between the
# existing ones and the new ones.
if previous_promotion_ids.empty?
@new_promotions = pending_promotions
else
@new_promotions = pending_promotions.reject {|p| previous_promotion_ids.include?(p.id)}
@existing_promotions = pending_promotions.select {|p| previous_promotion_ids.include?(p.id)}
end
pending_promotions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def promotions\n @promotions ||= order.promotions\n end",
"def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.tr... | [
"0.64268756",
"0.61746866",
"0.60649604",
"0.5835612",
"0.55584973",
"0.55160064",
"0.54326624",
"0.53392017",
"0.5239044",
"0.5236701",
"0.51956725",
"0.51830184",
"0.5129507",
"0.51139766",
"0.50788236",
"0.5071204",
"0.5035513",
"0.49953207",
"0.4930564",
"0.49168912",
"0.... | 0.8107721 | 0 |
Dc(p;q) ==> if p.nullable then Dc(p);q | Dc(q) else Dc(p);q | def Sequence(from)
n = from.elements.length
alt = @factory.Alt()
for i in 0...n
first = recurse(from.elements[i])
if first
p = @factory.Sequence()
p.elements << first unless first.Epsilon?
for j in i+1...n
p.elements << @copier.copy(from.elements[j])
end
alt.alts << p
else
break
end
break unless @nullable.recurse(from.elements[i])
end
alt.alts.empty? ? nil : alt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def or_d\n end",
"def mark_nullable\n rules.each do |prod|\n if prod.empty?\n prod.nullable = true\n else\n # If all rhs members are all nullable, then rule is nullable\n prod.nullable = prod.rhs.members.all?(&:nullable?)\n end\n end\... | [
"0.6111057",
"0.55405974",
"0.5517789",
"0.54893196",
"0.5447858",
"0.54364324",
"0.5403116",
"0.53899294",
"0.5335949",
"0.52456355",
"0.52122486",
"0.5193818",
"0.513197",
"0.51035094",
"0.5073621",
"0.5058647",
"0.5007375",
"0.49914598",
"0.49744928",
"0.49601877",
"0.4957... | 0.0 | -1 |
Dc(p) ==> if p.nullable then Dc(p) else Dc(p);p | def Regular(from)
d = recurse(from.arg)
nil if d.nil?
if !from.many
return d
else
s = @factory.Sequence()
s.elements << d
s.elements << @factory.Regular(@copier.copy(from.arg), true, true)
return s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null?; @null; end",
"def nullable\n self['nullable']\n end",
"def null?; false end",
"def mark_nullable\n rules.each do |prod|\n if prod.empty?\n prod.nullable = true\n else\n # If all rhs members are all nullable, then rule is nullable\n p... | [
"0.56643915",
"0.54442513",
"0.53735656",
"0.53655064",
"0.5306141",
"0.525573",
"0.5211456",
"0.5209688",
"0.5204604",
"0.5204604",
"0.5204604",
"0.51663",
"0.51604635",
"0.5147444",
"0.5140661",
"0.5118258",
"0.5118258",
"0.5064584",
"0.502612",
"0.5008557",
"0.49975446",
... | 0.0 | -1 |
Dc(p?) ==> if Dc(p) != error then Dc(p)? else empty | def Opt(from)
p = recurse(from.arg)
p ? @factory.Opt(p) : @factory.Epsilon()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pdc?\n false\n end",
"def debit_factype_null_perdu\n test = init_test('Debit (Facture) avec factype NULL mais sans labour ni pulve associes', LOW)\n Debit.find(:all).each do |facture| \n if facture.factype_id.equal?(Factype.find_by_name('null').id) && facture.pulves.empty? && facture.lab... | [
"0.55279815",
"0.537246",
"0.52150273",
"0.5210245",
"0.5210245",
"0.5196373",
"0.5165818",
"0.5144689",
"0.5063147",
"0.5058004",
"0.5054476",
"0.5034367",
"0.5015428",
"0.5010071",
"0.50047207",
"0.4997223",
"0.49520013",
"0.4928947",
"0.49130532",
"0.48762658",
"0.4871541"... | 0.0 | -1 |
identifier representing a remote object | def Ref(from)
return checkToken(Symbol)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remote_id; end",
"def object_id() end",
"def __object_unique_id__\n name\n end",
"def __object_unique_id__\n name\n end",
"def obj_id\n uri.split('/').last\n end",
"def obj_id\n uri.split('/').last\n end",
"def object_identifier\n [\"#{self.class.name}\", (id.nil? ? nil... | [
"0.7822269",
"0.76745987",
"0.7253405",
"0.7253405",
"0.7185132",
"0.7185132",
"0.7117979",
"0.7068104",
"0.7068056",
"0.70438373",
"0.69918555",
"0.69797593",
"0.69503766",
"0.6900533",
"0.6888203",
"0.6877489",
"0.68690765",
"0.6815677",
"0.67677283",
"0.67413914",
"0.67413... | 0.0 | -1 |
create [num] SHF applications in the given state return the list of SHF applications created | def create_shf_apps_in_state(num, state, create_date: Time.current)
shf_apps = []
num.times do
shf_apps << create(:shf_application, state: state, created_at: create_date,
updated_at: create_date)
end
shf_apps
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_apps_in_states(create_date: Time.current)\n\n NUM_APPS_IN_STATE.each_pair do |state, number|\n create_shf_apps_in_state(number, state, create_date: create_date)\n end\n\n end",
"def get_recent_shf_apps(start_date, end_date)\n\n @recent_shf_apps = ShfApplication.updated_in_date_range(s... | [
"0.7199402",
"0.59144616",
"0.5414188",
"0.53837156",
"0.5303373",
"0.52989286",
"0.52305746",
"0.52006435",
"0.519886",
"0.5156555",
"0.50491333",
"0.5034245",
"0.499946",
"0.49726558",
"0.4949552",
"0.49459392",
"0.49261197",
"0.49163422",
"0.49084094",
"0.48974708",
"0.485... | 0.8624569 | 0 |
create applications in all states and set the created_at: and updated_at dates to create_date default create_date = Time.zone.now | def create_apps_in_states(create_date: Time.current)
NUM_APPS_IN_STATE.each_pair do |state, number|
create_shf_apps_in_state(number, state, create_date: create_date)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_shf_apps_in_state(num, state, create_date: Time.current)\n shf_apps = []\n\n num.times do\n shf_apps << create(:shf_application, state: state, created_at: create_date,\n updated_at: create_date)\n end\n\n shf_apps\n end",
"def apps_by_creation_date(createdat)\... | [
"0.67802423",
"0.6033695",
"0.5781957",
"0.5771342",
"0.57342434",
"0.57287693",
"0.56911033",
"0.56450516",
"0.5643362",
"0.56431955",
"0.5642254",
"0.56245863",
"0.55921745",
"0.5544943",
"0.5516274",
"0.54866517",
"0.5482571",
"0.54647434",
"0.54512715",
"0.54324293",
"0.5... | 0.7496882 | 0 |
add an uploaded file to the SHF application | def add_uploaded_file(shf_app)
shf_app.uploaded_files << create(:uploaded_file, actual_file: File.open(UPLOAD_PNG_FILE))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file\n #TODO\n end",
"def upload\n self._create params[:upfile], params[:pictitle]\n end",
"def upload\r\n \r\n end",
"def save_file_entry\n @user.search_files.create!(file_path: uploaded_file_path.result, file_name: @file.original_filename, status: 'initialized')\n end... | [
"0.7202717",
"0.7095032",
"0.68771875",
"0.6794102",
"0.6717206",
"0.6717206",
"0.6666275",
"0.66188914",
"0.65814596",
"0.6578944",
"0.65714294",
"0.65434194",
"0.6533004",
"0.6514539",
"0.65074474",
"0.6497595",
"0.648155",
"0.6434443",
"0.6428496",
"0.6428496",
"0.64201474... | 0.8243698 | 0 |
create a member with a membership fee payment, branding fee paid return the member | def create_member_with_member_and_branding_payments_expiring(member_pay_expires = Time.zone.today + 1.year,
payment_create_date: Time.zone.now,
membership_status: :current_member)
u = create(:member, last_day: member_pay_expires, membership_status: membership_status)
u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)
create(:payment,
user: u,
payment_type: Payment::PAYMENT_TYPE_BRANDING,
status: SUCCESSFUL_PAYMENT,
expire_date: member_pay_expires,
created_at: payment_create_date,
updated_at: payment_create_date)
u.payments.each { |payment| payment.update(created_at: payment_create_date, updated_at: payment_create_date) }
u
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @member = Member.new(member_params)\n #@member.card_id = SecureRandom.uuid\n @member.magma_coins = 0\n add_abo_types_to_member(@member)\n respond_to do |format|\n if @member.save\n format.html { redirect_to current_user.present? ? @member : members_path, notice: t('flash.not... | [
"0.69762033",
"0.6961654",
"0.6950737",
"0.6841401",
"0.68327266",
"0.67581135",
"0.6729609",
"0.6715025",
"0.669848",
"0.6658047",
"0.66500276",
"0.64890933",
"0.6476469",
"0.6470372",
"0.6454703",
"0.64526945",
"0.6439926",
"0.64303267",
"0.6428765",
"0.6383507",
"0.6378504... | 0.7537223 | 0 |
create a paid up member with a given company number, make a payment with the expire date. | def create_co_and_payment(company_number, payment_exp_date, member_pay_expires: Time.zone.today + 1.year, payment_create_date: Time.zone.now)
u = create(:member_with_membership_app, company_number: company_number)
u.shf_application.update(created_at: payment_create_date, updated_at: payment_create_date)
co = u.shf_application.companies.first
create(:payment,
user: u,
payment_type: Payment::PAYMENT_TYPE_MEMBER,
status: SUCCESSFUL_PAYMENT,
expire_date: member_pay_expires,
created_at: payment_create_date,
updated_at: payment_create_date)
branding_payment = create(:payment,
user: u,
payment_type: Payment::PAYMENT_TYPE_BRANDING,
status: SUCCESSFUL_PAYMENT,
expire_date: payment_exp_date,
created_at: payment_create_date,
updated_at: payment_create_date)
co.payments << branding_payment
co
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_member_with_member_and_branding_payments_expiring(member_pay_expires = Time.zone.today + 1.year,\n payment_create_date: Time.zone.now,\n membership_status: :current_member)\n u ... | [
"0.69060594",
"0.64355946",
"0.6358454",
"0.63414973",
"0.6306214",
"0.623397",
"0.6134724",
"0.6095739",
"0.60889095",
"0.60676795",
"0.6065046",
"0.6063734",
"0.60517734",
"0.602945",
"0.6026668",
"0.6022899",
"0.601373",
"0.6005469",
"0.59579885",
"0.5949564",
"0.5937691",... | 0.71493685 | 0 |
DELETE /event_registrations/1 DELETE /event_registrations/1.json | def destroy
@registration = Registration.find(params[:id])
@event = @registration.event
@registration.destroy
respond_to do |format|
format.html { redirect_to manage_event_path(@event), notice: 'Event registration was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @event_registration.destroy\n respond_to do |format|\n format.html { redirect_to event_registrations_path}\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_registration.destroy\n\n respond_to do |format|\n format.html { redirect_to event_url(@eve... | [
"0.78776497",
"0.75545466",
"0.72664815",
"0.7233993",
"0.7121077",
"0.71203524",
"0.7118392",
"0.7118392",
"0.7118392",
"0.71130234",
"0.7070225",
"0.7033818",
"0.70054746",
"0.70037514",
"0.6978001",
"0.696753",
"0.6967277",
"0.6949586",
"0.6947828",
"0.6946387",
"0.6945035... | 0.77075 | 1 |
Only allow a trusted parameter "white list" through. | def banner_params
params.require(:banner).permit(:name, :title, :description, :image_id, :url, :is_active, :start_date, :expiry_date, page_ids:[])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.71230334",
"0.70530915",
"0.69479465",
"0.6902122",
"0.67367256",
"0.67172784",
"0.6689043",
"0.66784793",
"0.6660117",
"0.6555213",
"0.6528485",
"0.6458438",
"0.6452378",
"0.6451654",
"0.64478326",
"0.6433326",
"0.6413599",
"0.6413599",
"0.63907677",
"0.63787645",
"0.6378... | 0.0 | -1 |
why does this method go in the child instead of the parent? self.column_names.each do |col_name| iterate over the column names stored in the column_names class method... attr_accessor col_name.to_sym ...set an attr_accessor for each one, making sure to convert the column name string into a symbol with the to_sym method, since attr_accessors must be named with symbols end | def initialize(options={}) #define method to take in an argument of options, which defaults to an empty hash
options.each do |property, value| #iterate over the options hash...
self.send("#{property}=", value) #and use our fancy metaprogramming #send method to interpolate the name of each hash key as a method that we set equal to that key's value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_column_accessor(*columns)\n clear_setter_methods_cache\n columns, bad_columns = columns.partition{|x| /\\A[A-Za-z_][A-Za-z0-9_]*\\z/.match(x.to_s)}\n bad_columns.each{|x| def_bad_column_accessor(x)}\n im = instance_methods.map(&:to_s)\n columns.each do |column|\n ... | [
"0.7025443",
"0.7012534",
"0.6787528",
"0.6774966",
"0.6454685",
"0.6454685",
"0.64290965",
"0.64285654",
"0.64096135",
"0.63136846",
"0.6311516",
"0.63050693",
"0.62708807",
"0.62708807",
"0.6192178",
"0.61917186",
"0.6177599",
"0.6170156",
"0.61513346",
"0.61242086",
"0.611... | 0.0 | -1 |
conventional ORM methods below::: | def table_name_for_insert
self.class.table_name #inside an instance method, self will refer to the instance of the class, not the class itself
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orm; end",
"def alchemy\r\n end",
"def single_object_db; end",
"def prerecord(klass, name); end",
"def query; end",
"def subscribe_sql_active_record; end",
"def find_by()\n\n end",
"def query\n super\n end",
"def find\n self.db.query(\"\n select * \n from dogs\n \"... | [
"0.78273743",
"0.6617537",
"0.66127664",
"0.63570035",
"0.62702",
"0.6155334",
"0.5970101",
"0.5968911",
"0.5930408",
"0.5920892",
"0.58345324",
"0.58260137",
"0.580654",
"0.58004534",
"0.5797007",
"0.5797007",
"0.5797007",
"0.5797007",
"0.5797007",
"0.5797007",
"0.5797007",
... | 0.0 | -1 |
Instructions when there is missing license information, but the user has specified disableapi preventing remote license sources being used. | def no_remote_instructions(unlicensed)
puts <<-INST
There is no license defined for #{counter(unlicensed)}. You are running with the `--disable-api`
option. If you remove this option, gemterms will attempt to use RubyGems and
other sources for license information.
INST
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_license()\n return true\n end",
"def opted_out?(api_name)\n if @is_opted_out\n @logger.log(\n LogLevelEnum::INFO,\n 'API_NOT_ENABLED',\n {\n '{file}' => FILE,\n '{api}' => api_name\n }\n )\n end\n @is_opted_out\n end",
"def api_onl... | [
"0.65706086",
"0.6272512",
"0.609993",
"0.609993",
"0.609993",
"0.59620357",
"0.59411335",
"0.5854937",
"0.58096164",
"0.5787622",
"0.5754711",
"0.5726572",
"0.5716209",
"0.5688357",
"0.5678192",
"0.56603557",
"0.56530493",
"0.565202",
"0.565202",
"0.56110483",
"0.5603035",
... | 0.81446695 | 0 |
POST /birds POST /birds.json Add new bird in data Sanctuary | def create
@bird = Bird.new(bird_params)
if @bird.save
render json: @bird, status: :created
else
render json: @bird.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_bird\n bird_obj = bird_params\n continent = params['continents']\n unless continent.nil?\n continent = continent.split(',').map { |v| v.strip } if continent.is_a?(String)\n if continent.is_a?(Array) && !continent.blank?\n continent = continent[0].split... | [
"0.7714612",
"0.75363326",
"0.7342247",
"0.73273396",
"0.7292651",
"0.7231101",
"0.7071595",
"0.6567158",
"0.6535382",
"0.632883",
"0.62607706",
"0.6230511",
"0.62067455",
"0.61623937",
"0.6154507",
"0.6017123",
"0.5993737",
"0.5970231",
"0.5929623",
"0.5923371",
"0.5912476",... | 0.7564016 | 1 |
GET /birds GET /birds.json Returns all the available birds in sanctuary | def total_visible_birds
@birds = Bird.all(visible: true)
render json: @birds, status: :ok
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def birds_list\n birds = ::Bird.all\n render status: HttpCodes::OK,json: birds.extend(BirdRepresenter).to_a.as_json unless birds.empty?\n render status: HttpCodes::OK,json: {} if birds.empty?\n end",
"def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n ... | [
"0.76453465",
"0.7624405",
"0.73643875",
"0.6947235",
"0.6882653",
"0.6882653",
"0.6737538",
"0.6672589",
"0.66622317",
"0.66176736",
"0.6583566",
"0.651511",
"0.64983344",
"0.6469395",
"0.6394985",
"0.63911265",
"0.63898486",
"0.6365461",
"0.6365438",
"0.63297385",
"0.632919... | 0.6563176 | 11 |
GET /birds/1 GET /birds/1.json Return specific bird provided by bird id | def bird_specification
@bird = Bird.find(params[:id])
if @bird
@bird = JSON.parse(@bird.to_json)
@bird["id"]=params[:id]
render json: @bird.except("_id"), status: :ok
else
render :nothing => true, status: :not_found
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bird\n bird = Api::V1::Bird.find(params[:id])\n render json: {\n status: 200,\n message: \"OK\",\n bird: Api::V1::BirdSerializer.new(bird) \n }\n \n end",
"def show\n @bird = Bird.find(params[:id])\n end",
"def show \n bird = Bird.find_by... | [
"0.7842902",
"0.75328666",
"0.7532793",
"0.73402125",
"0.72267026",
"0.71068805",
"0.70877093",
"0.69594675",
"0.69594675",
"0.69594675",
"0.6863208",
"0.6838396",
"0.67940015",
"0.6771479",
"0.6771479",
"0.6751278",
"0.6612028",
"0.6603761",
"0.64625204",
"0.64274997",
"0.63... | 0.7864114 | 0 |
DELETE /birds/1 DELETE /birds/1.json | def remove
@bird = Bird.find(params[:id])
if @bird
@bird.destroy
render :nothing => true, status: :ok
else
render :nothing => true, status: :not_found
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @bird.destroy\n respond_to do |format|\n format.html { redirect_to birds_url, notice: 'Bird was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bird.destroy\n \n begin\n respond_to do |format|\n format.json { r... | [
"0.6887387",
"0.68635166",
"0.6820788",
"0.6808459",
"0.680432",
"0.6740291",
"0.6725452",
"0.66929066",
"0.6681796",
"0.6652052",
"0.66318506",
"0.66247386",
"0.6568351",
"0.6554738",
"0.6544394",
"0.6531139",
"0.6516086",
"0.6516086",
"0.6512393",
"0.6499316",
"0.64837694",... | 0.67570484 | 5 |
Never trust parameters from the scary internet, only allow the white list through. | def bird_params
params.require(:name)
params.require(:family)
params.require(:continents)
params.permit(:name, :family , :added, :visible, :continents => [])
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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
If a chunk represents an integer such as the sum of the cubes of its digits is divisible by 2, reverse that chunk; otherwise rotate it to the left by one position. Put together these modified chunks and return the result as a string. If sz is ) than the length of str it is impossible to take a chunk of size sz hence return "". Examples: revrot("123456987654", 6) > "234561876549" revrot("123456987653", 6) > "234561356789" revrot("66443875", 4) > "44668753" revrot("66443875", 8) > "64438756" revrot("664438769", 8) > "67834466" revrot("123456779", 8) > "23456771" revrot("", 8) > "" revrot("123456779", 0) > "" revrot("563000655734469485", 4) > "0365065073456944" | def divisible_by_two?(num_str)
num_str.split("").reduce(0) {|sum, num| sum += num.to_i * num.to_i } % 2 == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revrot(str, sz)\r\n\r\n if str.empty? || sz <= 0 || sz > str.length\r\n \"\"\r\n else\r\n\r\n chunk_array = str.scan(/.{#{sz}}/)\r\n\r\n chunk_array.map do |chunk|\r\n split_chunk = chunk.split('')\r\n chunk_cubed = split_chunk.map { |d| (d.to_i)**3 }\r\n chunk_sum = chunk_cubed... | [
"0.85434216",
"0.84711236",
"0.82055515",
"0.80406415",
"0.7997467",
"0.6016435",
"0.59622145",
"0.5934973",
"0.5916981",
"0.5877696",
"0.5857657",
"0.57538456",
"0.5753773",
"0.5729776",
"0.5729776",
"0.5729776",
"0.5711763",
"0.56774753",
"0.56655705",
"0.5657272",
"0.56495... | 0.0 | -1 |
end ======================================================================================== Problem 2: Golden Ratio Golden Ratio is ratio between consecutive Fibonacci numbers calculate the golden ratio up to specified precision validate using MiniTest unit tests module Assignment08 | def golden_ratio(precision)
x = fib(99)/fib(98).to_f
x.round(precision)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_exercise_1119\n expected_result = nil\n time_span = time_block { expected_result = calc_all_fibonacci 20 }\n verify_method :exercise_1119,\n :with => {param: 20, expect: expected_result}\n\n actual_time_span = time_block { @target.exercise_1119 20 }\n\n ... | [
"0.6329578",
"0.6120972",
"0.604802",
"0.60390025",
"0.6032825",
"0.6017206",
"0.60041684",
"0.5998652",
"0.5917522",
"0.591311",
"0.59097296",
"0.5905226",
"0.5897867",
"0.5875491",
"0.58643633",
"0.5861391",
"0.5860039",
"0.58598614",
"0.5812934",
"0.5812185",
"0.5807329",
... | 0.7249214 | 0 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_mailer.new_price_quote.subject | def send_price_quote(price_quote)
@price_quote = price_quote
mail to: @price_quote.request.user.email, subject: 'New price quote on Stabstr'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_subject=(value)\n @message_subject = value\n end",
"def subject=(subject); @message_impl.setSubject subject; end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject (recipient)\n subject_variables = aler... | [
"0.6757123",
"0.66477495",
"0.6615914",
"0.6599148",
"0.65804195",
"0.655499",
"0.6492605",
"0.645177",
"0.6394896",
"0.63842005",
"0.63827956",
"0.6353556",
"0.6348274",
"0.63079405",
"0.6298014",
"0.62972003",
"0.62779576",
"0.626582",
"0.6253665",
"0.62525433",
"0.6207085"... | 0.61353564 | 29 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge with Abe and Brian. 0. total Pseudocode make sure all pseudocode is commented out! Input: an array of numbers Output: sum of all numbers within the array Steps to solve the problem. define variable result=0 add each number to the result 1. total initial solution each or while loop | def total(my_array)
result=0
my_array.each { |a| result= result + a }
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(a)\n return 0 if a.uniq.size != a.size\n \n max = a.size \n sum = (1 + max) * max / 2\n \n array_sum = a.inject(0, &:+) \n sum == array_sum ? 1 : 0 \nend",
"def solution(a)\n return 1 if a.count == 0\n \n real_sum = a.inject(:+)\n expected_sum = (a.count + 1) * (a.count + 2) / 2.0\n (... | [
"0.6719396",
"0.66952485",
"0.66764003",
"0.66593844",
"0.65953165",
"0.6582857",
"0.65276414",
"0.65183413",
"0.6490501",
"0.6457219",
"0.6447671",
"0.6379239",
"0.6360184",
"0.63583905",
"0.6345708",
"0.6326957",
"0.6326957",
"0.63077205",
"0.6297719",
"0.6270918",
"0.62664... | 0.0 | -1 |
3. total refactored solution Works in Ruby on Rails | def total(my_array)
my_array.sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def appraisals; end",
"def appraisals; end",
"def formation; end",
"def suivre; end",
"def intensifier; end",
"def schubert; end",
"def romeo_and_juliet; end",
"def probers; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def strategy; end",
"def apply\n\t\t\t... | [
"0.588194",
"0.55688155",
"0.55688155",
"0.55438113",
"0.55015033",
"0.54975283",
"0.5438975",
"0.5419278",
"0.5357542",
"0.5338416",
"0.5338416",
"0.5334146",
"0.5320993",
"0.53050125",
"0.5247769",
"0.51455414",
"0.51272094",
"0.50639933",
"0.50485283",
"0.50030184",
"0.500... | 0.0 | -1 |
Make use of .reduce: | def total(my_array)
my_array.reduce( :+ )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend",
"def _reduce_1(val, _values, result); end",
"def _reduce_378(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n ... | [
"0.75614583",
"0.74612826",
"0.7459427",
"0.7388131",
"0.7363048",
"0.7363048",
"0.73142934",
"0.7293636",
"0.7264736",
"0.7264736",
"0.7263576",
"0.72578144",
"0.72475827",
"0.7245283",
"0.72423506",
"0.7241427",
"0.7230415",
"0.72184974",
"0.7216164",
"0.7215201",
"0.721520... | 0.0 | -1 |
4. sentence_maker pseudocode make sure all pseudocode is commented out! Input: an array of strings Output: a sentence with all of the words from the array. Steps to solve the problem. define variable result=empty string add space after each element, add next word. 5. sentence_maker initial solution | def sentence_maker(my_sentence)
result=my_sentence.shift
my_sentence.each { |x| result= result + " " + x.to_s }
result=result + "."
result.capitalize!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend",
"def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_ar... | [
"0.7697035",
"0.7641277",
"0.7627471",
"0.7609692",
"0.7601866",
"0.75048286",
"0.75048286",
"0.75048286",
"0.74929297",
"0.7455897",
"0.74304205",
"0.74223495",
"0.7393547",
"0.7369137",
"0.7360743",
"0.73604906",
"0.73482585",
"0.7324801",
"0.73005855",
"0.7293622",
"0.7277... | 0.688388 | 65 |
6. sentence_maker refactored solution | def sentence_maker(my_sentence)
result=my_sentence.join(" ")
result=result.capitalize + "."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def\n \nend\n\n\n# 6. sentence_maker refactored solution",
"def generate_sentence\n\n if @array_words.length < 3\n return \"Length of the input_file is too small to produce trigrams\"\n\n # This function results in an error message if there are no capital\n # words or no end of s... | [
"0.8855467",
"0.7072183",
"0.7007714",
"0.7006025",
"0.69965297",
"0.6969853",
"0.68722224",
"0.68363017",
"0.6817278",
"0.68010527",
"0.6796742",
"0.67929393",
"0.67922384",
"0.67889005",
"0.67810446",
"0.67709756",
"0.6766261",
"0.6727445",
"0.66979486",
"0.6686248",
"0.666... | 0.65363246 | 30 |
before_action :set_resource, only: %i[show update destroy] GET /contacts | def index
authorize @model, :index?
# @collection = @model.all
render json: Oj.dump(
collection: @model.all
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_contact\n @category = \"Contact\"\n @contact = resource_owner.contacts.find(params[:id])\n end",
"def show\n @contact_action = ContactAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact_action }\n end\n end",
... | [
"0.7048773",
"0.64073664",
"0.63425845",
"0.63355905",
"0.6326527",
"0.63066614",
"0.62955564",
"0.6271615",
"0.62338173",
"0.6223006",
"0.61480844",
"0.6124371",
"0.6107699",
"0.6092012",
"0.6057428",
"0.60533947",
"0.6043033",
"0.60406184",
"0.6031699",
"0.6028119",
"0.6024... | 0.0 | -1 |
Row explanation: [ "language", prs ] Output: [ ["Ruby", 3], ... ["CSS", 1] ] | def language_prs
languages.map do |language|
[language.fetch("language").name, language.fetch("prs")]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row\n [\n \"Theme\",\n \"Question\",\n { value: \"Average Score\", alignment: :right },\n { value: \"No. Scores Submitted\", alignment: :right }\n ]\n end",
"def reformat_languages(languages)\n new_hash = {}\n java_style_array = Array.new... | [
"0.559313",
"0.5516747",
"0.5369649",
"0.53510374",
"0.5305311",
"0.52974373",
"0.5261206",
"0.5224807",
"0.51573884",
"0.5136142",
"0.51236105",
"0.5122372",
"0.51097256",
"0.508731",
"0.5048546",
"0.50386214",
"0.5018835",
"0.5017918",
"0.5006626",
"0.4990945",
"0.49556917"... | 0.6034796 | 0 |
LOADS ONLY RECENT TWEETS FOR A USER | def load_tweets_for_user(user_id)
authenticate
max_id = Tweet.get_max_tweet_id(user_id) || @@max_id
response = []
puts max_id
result = @@client.user_timeline(user_id.to_i, :since_id => max_id)
result.each do |tweet|
begin
newTweet = Tweet.new
newTweet = newTweet.init(tweet)
unless newTweet.is_retweet_or_mention
newTweet.save!
else
puts "Found Retweet #{newTweet.text}"
end
rescue
puts "COULD NOT SAVE"
else
t = TweetViewModel.new
response << t.initFromActiveRecord(newTweet)
end
end
response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_tweets!\n Twitter.user_timeline(username).each do |tweet|\n unless Tweet.where(twitter_user_id: self.id).find_by_content(tweet.text) \n self.tweets << Tweet.create(content: tweet.text)\n end\n end\n end",
"def load\n params.permit!\n @user = current_user\n @users = []\... | [
"0.6006903",
"0.5871958",
"0.5849025",
"0.58081084",
"0.5807453",
"0.5796438",
"0.5772522",
"0.57509166",
"0.5738463",
"0.57040185",
"0.5701107",
"0.5685649",
"0.5683876",
"0.5667632",
"0.56216335",
"0.5615163",
"0.5575764",
"0.55688995",
"0.556537",
"0.5555986",
"0.55252117"... | 0.5619067 | 15 |
LOAD ALL TWEETS FOR A USER | def load_bulk_tweets(user_id)
authenticate
response = []
result = @@client.user_timeline(user_id.to_i)
result.each do |tweet|
begin
newTweet = Tweet.new
newTweet = newTweet.init(tweet)
newTweet.save!
rescue
puts "COULD NOT SAVE"
else
t = TweetViewModel.new
response << t.initFromActiveRecord(newTweet)
end
end
response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_users\n\n $test_logger.log(\"Loading users...\")\n\n #Delete all users from terminal DB\n @@cmd_proc.delete_all_uers\n\n #Fetch finger images from resource\n finger1 = Resource.get_content(\"N1.pklite\", true)\n finger2 = Resource.get_content(\"N2.pklite\", true)\n\n #Create required ... | [
"0.6613841",
"0.66098845",
"0.6590403",
"0.624021",
"0.5994971",
"0.5949833",
"0.57905906",
"0.5728993",
"0.56339604",
"0.56163824",
"0.55906844",
"0.5581066",
"0.5577806",
"0.5559744",
"0.5550515",
"0.552597",
"0.54965323",
"0.54870754",
"0.54638827",
"0.5461878",
"0.5457871... | 0.63790214 | 3 |
Transforms a SQLiX embedded XML Document. Takes a valid XML document as either a string or url, including local filename, or REXML::Document. Use the seeds hash to feed the references of the initial row element. Returns the resulting XML Document as a string, or as an REXML::Document if that was given. sqlix:query elements are in this format: | def transform(xml_source, seeds={})
if xml_source.is_a?(REXML::Document)
xml_document = xml_source
else
src = fetch_xml(xml_source)
xml_document = REXML::Document.new(src)
end
queries = REXML::XPath.match(xml_document.root,'//x:query', {'x' => 'http://www.transami.net/namespace/sqlix'})
queries.each do |element|
listener = SQLiX_Listener.new(@dbi, seeds)
el_str = ''
element.write(el_str)
REXML::Document.parse_stream(el_str, listener)
new_element = listener.build_document
new_element.elements.each do |el|
element.parent.add_element(el)
end
element.remove
end
# return output
if xml_source.is_a?(REXML::Document)
return xml_document
else
xml_string = ""
xml_document.write(xml_string)
xml.gsub!(/>\s+</,'><') # clean poor rexml whitespace handling
return xml_string
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_solr\n puts \"transforming #{self.filename}\"\n solr_doc = Nokogiri::XML(\"<add></add>\")\n @csv.each do |row|\n if !row.header_row?\n doc = Nokogiri::XML::Node.new(\"doc\", solr_doc)\n # row_to_solr should return an XML::Node object with children\n doc = row_to_sol... | [
"0.5513982",
"0.51492333",
"0.5118726",
"0.50949293",
"0.48850235",
"0.48745278",
"0.48360753",
"0.46812204",
"0.46770287",
"0.46688595",
"0.46593094",
"0.46211913",
"0.4581038",
"0.4566015",
"0.4557557",
"0.45343542",
"0.45343143",
"0.45018125",
"0.449809",
"0.44949844",
"0.... | 0.7102761 | 0 |
q! method, she's an odd one, takes a query and returns an array of Row objects produced but also inserts those Row objects into this Row's (self) children it is also neccessary to pass the DBConnection object the query will be run against this actually pisses me off in that the whole point of having this class | def q!(query, db)
# build bindings from references
bindings = []
if query.references
query.references.each do |reference|
bindings << @row[reference]
end
end
# query
qry = query.query.gsub(''',"'").gsub('"','"') # replace single and double quotes that rexml substituted out.
if bindings.empty?
rows = db.connection.select_all(qry)
else
rows = db.connection.select_all(qry, *bindings)
end
result_rows = []
rows.each do |row|
result_rows << Row.new(query.name, row, query.attributes)
end
result_rows.each do |row|
self << row
end
return result_rows
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drillthrough(query)\n RowSet.new @connection.create_statement.execute_query(query.to_s)\n end",
"def insert_in_database\n Fetch.new(insertion_query).array\n end",
"def node_query_mapping_insert\n # binding.pry\n branches.each do |br|\n br.nodes.each do |nd|\n nodeName ... | [
"0.63389015",
"0.6150857",
"0.56682765",
"0.5638703",
"0.5631739",
"0.5565175",
"0.554424",
"0.55289435",
"0.55239236",
"0.5510129",
"0.54968923",
"0.54849654",
"0.54802024",
"0.5435421",
"0.5407851",
"0.53947794",
"0.5382071",
"0.53806543",
"0.5377896",
"0.5330029",
"0.53206... | 0.70666033 | 0 |
this is a mesh builder which returns this Row (self) as xml | def xml
base = REXML::Element.new(@name)
if @row.class == DBI::Row # only if we have a row otherwise return an empty xml node
# prime
context = nil
rowcontext = base
# loop through each column
@row.each_with_name do |val, colpath|
context = rowcontext # start at the top of the row for each column
parents = colpath.split('/') # split on any path dividers, i.e. parent/parent/child
child = parents.pop # get the child off the parents
# loop through all the parents
parents.each.each do |p|
found = REXML::XPath.first(context, p) # does the element already exist?
if not found # if not...
el = p.gsub(/[[].*[]]$/,'') # remove index if there is one
found = context.add_element(el) # add the element
end
context = found # this parent is now our new context
end
# do the child (the end of the tree branch)
if child =~ /^@(.*)/ # is it labeled an attribute with @?
context.add_attribute($1, val.to_s) # add attribute
elsif @attributes.include?(child) # or is it in the attributes list?
context.add_attribute(child, val.to_s) # add attribute
else
found = REXML::XPath.first(context, child) # does it already exist?
if not found # if not...
el = child.gsub(/[[].*[]]$/,'') # remove index if there is one
found = context.add_element(el) # add the element
end
context = found # the child is now our new context
context.add_text(val.to_s) # insert the text node as val
end
end
end
return base
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_xml(builder, include_dims=true)\n builder.grid do |xml|\n xml.cube\n dims_to_xml(xml) if include_dims\n xml.slices do |xml|\n xml.slice :rows => @row_count, :cols => @col_count do |xml|\n xml.data do |xml|\n ... | [
"0.67881894",
"0.64383596",
"0.6252738",
"0.6088256",
"0.60743666",
"0.6060757",
"0.59958315",
"0.5992822",
"0.59912175",
"0.59912175",
"0.59912175",
"0.5930447",
"0.5930447",
"0.59286547",
"0.5905474",
"0.58934057",
"0.5868874",
"0.58656883",
"0.5779803",
"0.5759905",
"0.575... | 0.6755729 | 1 |
build query tree, listener required methods | def xmldecl ver, enc, stand
# ignore xml declaration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_classic_query(options)\n raise ArgumentError, \"Query name is not present\" unless options[:query_name]\n raise ArgumentError, \"Parent list id is not present\" unless options[:parent_list_id]\n raise ArgumentError, \"Criteria is required\" unless options[:criteria]\n\n options[:visibility] ... | [
"0.61193997",
"0.6111638",
"0.6072295",
"0.59630275",
"0.59165335",
"0.58392924",
"0.5824635",
"0.58225507",
"0.57200986",
"0.57007927",
"0.56901294",
"0.5676976",
"0.56269515",
"0.55952084",
"0.5530375",
"0.55196667",
"0.54879797",
"0.54466045",
"0.53911716",
"0.5385983",
"0... | 0.0 | -1 |
Perform HTTP GET request | def get(path, params={})
RestClient.get request_base+path, {params: params}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end",
"def do_get\n Net::HTTP.get(URI.parse(api_url))\n end",
"def do_get url\n\t\turi = URI.par... | [
"0.8169531",
"0.81619596",
"0.81461626",
"0.81273323",
"0.80387366",
"0.7898414",
"0.78717077",
"0.78717077",
"0.7795393",
"0.7720315",
"0.77144223",
"0.77144223",
"0.76941705",
"0.7624536",
"0.7618683",
"0.758023",
"0.7574224",
"0.7571272",
"0.7539143",
"0.753509",
"0.752772... | 0.0 | -1 |
Perform HTTP POST request | def post(path, params={})
RestClient.post request_base+path, params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end",
"def post()\n return @http.request(@req)\n end",
"def post(url, ... | [
"0.8005528",
"0.7863485",
"0.7784612",
"0.76306975",
"0.761245",
"0.75891095",
"0.7472876",
"0.7463129",
"0.7410558",
"0.7406992",
"0.73663586",
"0.73638415",
"0.7342552",
"0.7334187",
"0.73337",
"0.7293983",
"0.7286432",
"0.7272447",
"0.72401774",
"0.7210085",
"0.7208627",
... | 0.0 | -1 |
Perform HTTP PUT request | def put(path, params={})
RestClient.put request_base+path, params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def _http_put resource, path\n ur... | [
"0.79793304",
"0.7931324",
"0.79307526",
"0.7918318",
"0.78683215",
"0.78636295",
"0.78534824",
"0.78447163",
"0.77293915",
"0.7729186",
"0.7683448",
"0.76762205",
"0.76661795",
"0.7662284",
"0.7611254",
"0.7611254",
"0.7608692",
"0.75811964",
"0.7579723",
"0.7560995",
"0.754... | 0.72167075 | 71 |
Perform HTTP DELETE request | def delete(path)
RestClient.delete request_base+path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def d... | [
"0.8399885",
"0.83332837",
"0.83332837",
"0.8220235",
"0.8210298",
"0.8210298",
"0.820187",
"0.8188731",
"0.8074704",
"0.8021655",
"0.80212134",
"0.80030185",
"0.7978033",
"0.79605097",
"0.79425305",
"0.79425305",
"0.79425305",
"0.79425305",
"0.7917079",
"0.79062206",
"0.7856... | 0.745061 | 63 |
returns the global unread notification count for a user | def count_for_target
NotifyUser::BaseNotification.for_target(target)
.where('parent_id IS NULL')
.where('state IN (?)', ["sent_as_aggregation_parent", "sent", "pending"])
.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unread_notification_count\n unread_notifications.count\n end",
"def unread_count(user)\n public_replies(user).unread_by(user).size + (unread?(user) ? 1 : 0)\n end",
"def notification_count\n return NotificationReader.where(user: current_user, read_at: nil).count\n end",
"def unread_count\n ... | [
"0.81357384",
"0.8015549",
"0.79157573",
"0.7775203",
"0.7546733",
"0.74842507",
"0.7461307",
"0.7437711",
"0.7395174",
"0.7371511",
"0.73703545",
"0.7270429",
"0.7192974",
"0.7192974",
"0.7192974",
"0.7144261",
"0.7119244",
"0.7015296",
"0.69902104",
"0.68873596",
"0.6881326... | 0.0 | -1 |
Returns all parent notifications with a given group_id | def current_parents
self.class
.for_target(self.target)
.where(group_id: group_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_members\n Notification.where(group_owner_id: id)\n end",
"def parents\n @key.nil? ? [] : [@group.parents, @group].compact.flatten\n end",
"def group_notifications\n @attributes[:group_notifications]\n end",
"def parent_groups(group_id=nil) \n # {{{\n grou... | [
"0.63251024",
"0.60283846",
"0.59159684",
"0.5813343",
"0.55704826",
"0.5561866",
"0.5533756",
"0.5521814",
"0.5468248",
"0.54294735",
"0.53218937",
"0.5301007",
"0.5291579",
"0.5290425",
"0.5253127",
"0.5249965",
"0.5249956",
"0.5203",
"0.5184262",
"0.51752794",
"0.5162705",... | 0.5774728 | 4 |
Sends immediately and without aggregation | def deliver!
if pending_no_aggregation? and not user_has_unsubscribed?
self.mark_as_sent!
self.class.deliver_channels(self.id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_pending; end",
"def send!\n @_sended = true\n self\n end",
"def send!\n return if @buffer.empty?\n recursive_send(@buffer)\n @buffer.clear\n end",
"def sync_send\n sync_write.putc(\"!\")\n sync_write.flush\n end",
"def send_to_acx\n @result[:sent] = @transaction_... | [
"0.76913196",
"0.69535685",
"0.68107665",
"0.6663291",
"0.66390145",
"0.65293276",
"0.6468909",
"0.6455954",
"0.6440212",
"0.64241695",
"0.63724124",
"0.630033",
"0.630033",
"0.6286948",
"0.6219972",
"0.61882526",
"0.61790526",
"0.6154586",
"0.6142397",
"0.61392266",
"0.61225... | 0.0 | -1 |
watch comment user id list without `ignore` option | def watch_comment_by_user_ids
self.watch_comment_by_user_actions.where("action_option is null or action_option != ?", "ignore").pluck(:user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n user_ids += repository.watch_by_user_ids\n user_ids.uniq!\n\n user_ids - unwatch_comment_by_user_ids\n end",
"def notify_watchers(comment_id)\... | [
"0.8032371",
"0.69915086",
"0.67108715",
"0.60207844",
"0.5932253",
"0.58122885",
"0.5720991",
"0.571276",
"0.57055014",
"0.5673911",
"0.5670132",
"0.56651604",
"0.56452847",
"0.564112",
"0.56228155",
"0.5617142",
"0.551847",
"0.550706",
"0.54384184",
"0.5428817",
"0.5418359"... | 0.77821356 | 1 |
Computes the words I have written today on my MEng report | def midnight
86_400 * (Time.now.to_i / 86_400)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_duration_in_words(date)\n if date > DateTime.now\n t('datetime.distance_in_words.in') + ' ' + (distance_of_time_in_words DateTime.current, date)\n else\n t('datetime.distance_in_words.ago')\n end\n end",
"def date_age_in_words(date)\n (distance_of_time_in_words DateTime.current, d... | [
"0.6362605",
"0.6351187",
"0.6284629",
"0.6258469",
"0.6142604",
"0.6124343",
"0.59700376",
"0.5961985",
"0.59395224",
"0.5924927",
"0.58823943",
"0.58823943",
"0.58823943",
"0.5877987",
"0.58677",
"0.58579755",
"0.5851423",
"0.584507",
"0.5830766",
"0.5824773",
"0.58173835",... | 0.0 | -1 |
if (i % 3 == 0 && i % 4 == 0 && i % 5 == 0) puts 'FizzSussBuzz' elsif (i % 3 == 0 && i % 4 == 0) puts 'FizzSuss' elsif (i % 4 == 0 && i % 5 == 0) puts 'SussBuzz' elsif (i % 3 == 0) puts 'Fizz' elsif (i % 4 == 0) puts 'Suss' elsif (i % 5 == 0) puts 'Buzz' else puts i end end | def dynamic_fizz_buzz(range, rules)
range.each do |i|
result = ''
rules.each do |(text, divisor)|
result << text if (i % divisor == 0)
end
puts result == '' ? i : result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fizz_buzz()\n for i in 1..100\n if i % 3 == 0 && i % 5 == 0\n puts 'FizzBuzz'\n elsif i % 3 == 0\n puts 'Fizz'\n elsif i % 5 == 0\n puts 'Buzz'\n else\n puts i\n end\n end\nend",
"def fizz_buzz (i)\n 1.upto 100 do |i|\n if... | [
"0.89109665",
"0.88788414",
"0.8861966",
"0.8715799",
"0.869283",
"0.8648231",
"0.8645187",
"0.86160666",
"0.8597036",
"0.8540557",
"0.85397387",
"0.8529209",
"0.85081273",
"0.84942144",
"0.8493825",
"0.84891117",
"0.8473097",
"0.8465373",
"0.845641",
"0.84555525",
"0.8455552... | 0.0 | -1 |
GET /meetings GET /meetings.json def index | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @meetings = Meeting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meetings }\n end\n end",
"def index\n @meetings = Meeting.all\n end",
"def index\n @meetings = Meeting.all\n end",
"def index\n @meetings = Meeting.all\n ... | [
"0.86881256",
"0.81708425",
"0.81708425",
"0.81708425",
"0.81708425",
"0.81708425",
"0.81708425",
"0.8025989",
"0.7966836",
"0.7900239",
"0.78949094",
"0.7830946",
"0.7798126",
"0.7752799",
"0.7608941",
"0.7580707",
"0.7494635",
"0.7447039",
"0.74112105",
"0.73653543",
"0.730... | 0.0 | -1 |
POST /meetings POST /meetings.json | def create
@team = Team.find(params[:team_id])
@meeting = @team.meetings.new(meeting_params)
respond_to do |format|
if @meeting.save
format.js {render json: @meeting.id}
format.json { render :show, status: :created, location: @meeting }
format.html { redirect_to team_meeting_path(@team, @meeting), notice: 'הפגישה נוצרה בהצלחה.' }
else
format.json { render json: @meeting.errors, status: :unprocessable_entity }
format.js
format.html { render :new }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @meeting = current_user.meetings.new(meeting_params)\n new_event(@meeting)\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to new_event_path, notice: 'Meeting was successfully created.' }\n else\n format.html { render :new }\n format.json { ... | [
"0.70881873",
"0.7059875",
"0.67819774",
"0.67814976",
"0.6768945",
"0.6760446",
"0.6747356",
"0.67396617",
"0.6738901",
"0.67336243",
"0.6678363",
"0.6646479",
"0.66382647",
"0.6622729",
"0.66189617",
"0.6601062",
"0.65877753",
"0.65678734",
"0.6533456",
"0.64769936",
"0.647... | 0.6625905 | 13 |
PATCH/PUT /meetings/1 PATCH/PUT /meetings/1.json | def update
@team = Team.find(params[:team_id])
respond_to do |format|
if @meeting.update(meeting_params)
format.js {render json: @meeting.id}
format.html { redirect_to team_meeting_path(@team, @meeting), notice: 'הפגישה עודכנה בהצלחה.' }
format.json { render :show, status: :ok, location: @meeting }
else
format.html { render :edit }
format.json { render json: @meeting.errors, status: :unprocessable_entity }
format.js {render json: @meeting.id}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @meeting.update(meeting_params)\n format.json { head :no_content }\n else\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meet = Meet.find(params[:id])\n\n respond_t... | [
"0.72733486",
"0.7263451",
"0.720192",
"0.7171919",
"0.7135676",
"0.70852876",
"0.688029",
"0.6860292",
"0.6836023",
"0.681179",
"0.681179",
"0.681179",
"0.681179",
"0.67926973",
"0.67924505",
"0.6791691",
"0.6779588",
"0.6758554",
"0.67407507",
"0.6720899",
"0.67122144",
"... | 0.62381095 | 47 |
DELETE /meetings/1 DELETE /meetings/1.json | def destroy
@team = @meeting.team
@meeting.destroy
respond_to do |format|
format.html { redirect_to team_path(@team), notice: 'הפגישה נמחקה בהצלחה.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end",
"def destroy\n @meeting = Meeting.find(params[:id])\n @meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to meetings_url }\n format.json { head :no_content }\n end\n ... | [
"0.80827785",
"0.7949581",
"0.7949581",
"0.7949581",
"0.793943",
"0.7925257",
"0.7883001",
"0.78429943",
"0.78148264",
"0.7774949",
"0.770833",
"0.770833",
"0.770833",
"0.7698673",
"0.76632965",
"0.7661452",
"0.76605344",
"0.76529425",
"0.76492286",
"0.7649177",
"0.7645561",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_meeting
@meeting = Meeting.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 |
Only allow a list of trusted parameters through. | def meeting_params
params.require(:meeting).permit(:team_id, :content, :privacy, :subject, tag_list: [], attachments: [], user_ids: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.6950644",
"0.68134046",
"0.68034387",
"0.6796522",
"0.674668",
"0.6742105",
"0.6527854",
"0.65214247",
"0.6491907",
"0.64294493",
"0.64294493",
"0.64294493",
"0.64004904",
"0.6356768",
"0.63556653",
"0.6348119",
"0.6344521",
"0.63386923",
"0.632588",
"0.632588",
"0.632588"... | 0.0 | -1 |
in params complete donation needed (with charity, amount, etc.) | def create
@donation = Donation.new(donation_params)
before_donation_creation @donation
if @donation.save
after_donation_creation @donation
set_after_create_flash_message
redirect_to donation_path(@donation)
else
redirect_to charities_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def donation_params\n params.require(:donation).permit(:amount, :donation_date, :contact_id, :payment_purpose_id, :payment_mode_id, :currency_id, :event_id, :bank_name, :cheque_number)\n end",
"def donation_params\n params.require(:donation).permit(:description, :expires, :donor_id, :food_bank_id)\n... | [
"0.7051192",
"0.6878747",
"0.6869624",
"0.6772619",
"0.67369765",
"0.66817933",
"0.6671248",
"0.665159",
"0.66196316",
"0.65792584",
"0.6561108",
"0.65296704",
"0.64958656",
"0.6488371",
"0.6467558",
"0.6453972",
"0.6403663",
"0.6393339",
"0.6380814",
"0.63760096",
"0.6368496... | 0.0 | -1 |
redefine your position_taken? method here, so that you can use it in the valid_move? method above. | def position_taken?(board, index)
if board[index] == " " || board[index] == ""
p false
elsif board[index] == nil
p false
elsif board[index] == "X" || board[index] == "O"
p true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v... | [
"0.84084135",
"0.8163241",
"0.8090029",
"0.8027103",
"0.8012905",
"0.7896375",
"0.7893138",
"0.78846574",
"0.7842956",
"0.7841005",
"0.7831056",
"0.7813726",
"0.78123397",
"0.78094643",
"0.78016865",
"0.7800575",
"0.7799216",
"0.7788002",
"0.7781558",
"0.77737105",
"0.7772456... | 0.0 | -1 |
The ASCII string value is the sum of the ASCII values of every character in the string. (You may use Stringord to determine the ASCII value of a character.) | def ascii_value(string)
sum = 0
string.each_char { |char| sum += char.ord}
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ascii_value(str)\n ascii_sum = 0\n\n str.each_char { |char| ascii_sum += char.ord }\n ascii_sum\nend",
"def ascii_value(string)\n sum = 0\n string.chars.each do |char|\n sum += char.ord\n p char.ord.chr # Further Exploration\n end\n sum\nend",
"def ascii_value(str)\n str.chars.map { |chr| chr... | [
"0.90551573",
"0.901951",
"0.90099114",
"0.9006021",
"0.8973511",
"0.8946076",
"0.8946076",
"0.89357096",
"0.89142203",
"0.8910129",
"0.88800824",
"0.88703007",
"0.88498753",
"0.8836479",
"0.8778884",
"0.8757993",
"0.8751687",
"0.8745328",
"0.8687609",
"0.8637994",
"0.8609859... | 0.8958713 | 5 |
=begin Input: string create a sum variable set to 0 Iterate through each character in the string by using the each_char method add char.ord to sum variable return the sum variable Output: integer sum =end | def ascii_value(string)
value = 0
string.chars.each do |char|
value += char.ord
end
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strsum(str)\n total = 1\n str.chars.each do |c|\n total = total * c.to_i\n end\n total\nend",
"def charsSum (s)\n\t\tsum = 0\n\t\ts.each_char { |c| sum += self.letterToInt(c) }\n\t\treturn sum\n\tend",
"def sumWithFctChar(string)\n sum = 0\n string.each_char do\n |chr|\n sum += chr.to_i\n e... | [
"0.8613297",
"0.83934045",
"0.8299811",
"0.813995",
"0.81080836",
"0.80640167",
"0.80244374",
"0.8006212",
"0.79956317",
"0.79784065",
"0.79538584",
"0.79369724",
"0.79276717",
"0.79276717",
"0.78806394",
"0.7879771",
"0.7860485",
"0.7747146",
"0.7591318",
"0.74320817",
"0.74... | 0.6899766 | 46 |
TODO: some private logic | def private?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def identify; end",
"def refutal()\n end",
"def suivre; end",
"def formation; end",
"def implementation; end",
"def implementation; end",
"def weber;... | [
"0.7482358",
"0.64615995",
"0.62793696",
"0.62793696",
"0.62793696",
"0.62793696",
"0.6171039",
"0.5978112",
"0.5900025",
"0.58132946",
"0.58092445",
"0.57382625",
"0.57382625",
"0.5698134",
"0.56953293",
"0.5670021",
"0.5670021",
"0.56016326",
"0.55965436",
"0.5593278",
"0.5... | 0.0 | -1 |
autofetch coordinates attr_accessible :locations_attributes | def full_street_address
return "#{self.street}, #{self.city}, #{self.state}, #{self.zip}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_coordinates!\n fetch_coordinates(true)\n end",
"def populate_orig_coordinates\n\t\tself.lat_orig = read_attribute(:lat)\n\t\tself.lon_orig = read_attribute(:lon)\n\tend",
"def search_data\n attributes.merge(location: {lat: latitude, lon: longitude})\n end",
"def location= attrs\n self.lo... | [
"0.6653244",
"0.65302724",
"0.6476917",
"0.62029",
"0.6137368",
"0.6108511",
"0.6107448",
"0.60984814",
"0.60765374",
"0.5998545",
"0.5936057",
"0.59213346",
"0.5855976",
"0.5800555",
"0.57760185",
"0.57533",
"0.5731248",
"0.5696278",
"0.5639646",
"0.5636842",
"0.56250894",
... | 0.0 | -1 |
methods for adding to users clipboard | def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paste; clipboard_paste; end",
"def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_v... | [
"0.8140096",
"0.8104369",
"0.78697044",
"0.78418976",
"0.77520657",
"0.71522474",
"0.70974034",
"0.7069569",
"0.70478046",
"0.6902639",
"0.68902194",
"0.68568355",
"0.681232",
"0.6803679",
"0.675421",
"0.6701881",
"0.6697091",
"0.6688792",
"0.66147995",
"0.65574133",
"0.64975... | 0.5217439 | 96 |
This action is called on ajax autocomplete call. It checks if user has rights to view data. URL parameters: [table] Table (collection) model name in lower case indicating table which will be searched. [id] Name of id key field that will be returned. Default is '_id' [input] Search data entered in input field. [search] when passed without dot it defines field name on which search will be performed. When passed with dot class_method.method_name is assumed. Method name will be parsed and any class with class method name can be evaluated. Class method must accept input parameter and return array [ [_id, value],.. ] which will be used in autocomplete field. Return: JSON array [label, value, id] of first 20 documents that confirm to query. | def autocomplete
# return '' unless session[:edit_mode] > 0 #
return render text: t('drgcms.not_authorized') unless dc_user_can(DcPermission::CAN_VIEW)
# TODO Double check if previous line works as it should.
table = params['table'].classify.constantize
id = [params['id']] || '_id'
# call method in class if search parameter has . This is for user defined searches
# result must be returned as array of [id, search_field_value]
a = if params['search'].match(/\./)
name, method = params['search'].split('.')
table.send(method, params['input']).inject([]) do |r,v|
r << { label: v[0], value: v[0], id: v[1].to_s }
end
# simply search which will search and return field_name defined in params['search']
else
table.where(params['search'] => /#{params['input']}/i).limit(20).inject([]) do |r,v|
r << { label: v[params['search']], value: v[params['search']], id: v.id.to_s }
end
end
render inline: a.to_json, formats: 'js'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autocomplete\r\n # table parameter must be defined. If not, get it from search parameter\r\n if params['table'].nil? && params['search'].match(/\\./)\r\n name = params['search'].split('.').first\r\n params['table'] = name.underscore\r\n end\r\n if params['table'].match('_control')\r\n # it must be... | [
"0.74884635",
"0.5927023",
"0.5922668",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.59110004",
"0.5908016",
"0.5892678",
"0.5855081",
"0.583393",
"0.57894963",
"0.5746241",
"0.57433057",
"0.5... | 0.7519833 | 0 |
Register and record click when ad link is clicked. | def ad_click
if (ad = DcAd.find(params[:id]))
ad.clicked += 1
ad.save
DcAdStat.create!(dc_ad_id: params[:id], ip: request.ip, type: 2 )
else
logger.error "ERROR ADS: Invalid ad id=#{params[:id]} ip=#{request.ip}."
end
render :nothing => true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click(link); end",
"def ga_ad_click(advertiser, ad_name, link)\n adv = advertiser.blank? ? \"\" : advertiser\n adv_name = ad_name.blank? ? \"\" : ad_name\n #adv_link = link.blank? ? \"\" : link\n category = adv + \" - Ad Data\"\n action = adv_name + \" - Clicks\"\n\n adv_link = request.url\... | [
"0.74522126",
"0.67892927",
"0.6601028",
"0.6556179",
"0.6340476",
"0.6272195",
"0.625987",
"0.62356323",
"0.6069521",
"0.6012836",
"0.6007723",
"0.5996763",
"0.598204",
"0.5975354",
"0.5946643",
"0.5946271",
"0.5930583",
"0.5930029",
"0.5912502",
"0.5867862",
"0.5839945",
... | 0.5801601 | 28 |
Toggle CMS edit mode.This action is called when user clicks CMS option on top of the browser. | def toggle_edit_mode
session[:edit_mode] ||= 0
# called without logged in
if session[:edit_mode] < 1
dc_render_404
else
session[:edit_mode] = (session[:edit_mode] == 1) ? 2 : 1
redirect_to params[:return_to]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle_editmode\n\t\t@editmode = true\n\t\t$screen.write_message(\"Edit mode\")\n\tend",
"def toggle_edit_mode\r\n session[:edit_mode] ||= 0 \r\n # error when not logged in\r\n return dc_render_404 if session[:edit_mode] < 1\r\n\r\n # if return_to_ypos parameter is present it will forward it and thus scr... | [
"0.7615129",
"0.7475761",
"0.6415849",
"0.63457733",
"0.6326886",
"0.6284163",
"0.62730086",
"0.62044823",
"0.61972916",
"0.6189394",
"0.61700845",
"0.61543614",
"0.6149204",
"0.61425793",
"0.61425793",
"0.61425793",
"0.61425793",
"0.61425793",
"0.61425793",
"0.61425793",
"0.... | 0.63565624 | 3 |
Default user login action. | def process_login
# Somebody is probably playing
return dc_render_404 unless ( params[:record] and params[:record][:username] and params[:record][:password] )
unless params[:record][:password].blank? #password must not be empty
user = DcUser.find_by(username: params[:record][:username])
if user and user.authenticate(params[:record][:password])
fill_login_data(user, params[:record][:remember_me].to_i == 1)
return redirect_to params[:return_to] || '/'
end
end
flash[:error] = t('drgcms.invalid_username')
redirect_to params[:return_to_error] || '/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n\t\tif @current_user != nil\n\t\t\tredirect_to user_path(@current_user.id)\n\t\tend\n\tend",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def logi... | [
"0.7681366",
"0.75321364",
"0.75134134",
"0.75134134",
"0.75134134",
"0.75134134",
"0.75134134",
"0.75134134",
"0.75134134",
"0.75134134",
"0.75134134",
"0.7449341",
"0.741687",
"0.74055105",
"0.74055105",
"0.73951584",
"0.73035514",
"0.71323836",
"0.71318805",
"0.71104413",
... | 0.0 | -1 |
Default user logout action. | def logout
clear_login_data
redirect_to params[:return_to] || '/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout\n call :get, '/user/logout'\n end",
"def logout\n end",
"def logout\n end",
"def logout\n call('User.logout')\n end",
"def logout\n logout_redirect = Settings.logout_redirect\n if logout_redirect == 'NONE'\n page_not_found\n return\n end\n MarkusLogger... | [
"0.81282693",
"0.79186773",
"0.79186773",
"0.78222543",
"0.779935",
"0.7619285",
"0.7612793",
"0.7610782",
"0.7589071",
"0.7501898",
"0.7488113",
"0.74809706",
"0.7478943",
"0.7452222",
"0.7451888",
"0.74513227",
"0.74513227",
"0.74513227",
"0.7428898",
"0.7425069",
"0.741496... | 0.0 | -1 |
Alternative login action with remember_me cookie. If found it will automatically login user otherwise user will be presented with regular login dialog. | def login
if cookies.signed[:remember_me]
user = DcUser.find(cookies.signed[:remember_me])
if user
fill_login_data(user, true)
return redirect_to params[:return_to]
else
clear_login_data # on the safe side
end
end
# Display login
route = params[:route] || 'poll'
redirect_to "/#{route}?poll_id=login&return_to=#{params[:return_to]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_from_cookie\n user = cookies.signed[:remember_me_token] && user_class.sorcery_adapter.find_by_remember_me_token(cookies.signed[:remember_me_token]) if defined? cookies\n if user && user.has_remember_me_token?\n set_remember_me_cookie!(user)\n session[:user_... | [
"0.7886776",
"0.7876253",
"0.7576935",
"0.75066894",
"0.73956376",
"0.73566896",
"0.73438495",
"0.7331722",
"0.7320255",
"0.72132355",
"0.71868324",
"0.71839726",
"0.7167887",
"0.7110418",
"0.7040266",
"0.7032847",
"0.6974125",
"0.6946315",
"0.6893927",
"0.68904424",
"0.68812... | 0.7169219 | 12 |
Action for restoring document data from journal document. | def restore_from_journal
# Only administrators can perform this operation
unless dc_user_has_role('admin')
return render inline: { 'msg_info' => (t ('drgcms.not_authorized')) }.to_json, formats: 'js'
end
# selected fields to hash
restore = {}
params[:select].each {|key,value| restore[key] = value if value == '1' }
result = if restore.size == 0
{ 'msg_error' => (t ('drgcms.dc_journal.zero_selected')) }
else
journal_doc = DcJournal.find(params[:id])
# update hash with data to be restored
JSON.parse(journal_doc.diff).each {|k,v| restore[k] = v.first if restore[k] }
# determine tables and document ids
tables = journal_doc.tables.split(';')
ids = (journal_doc.ids.blank? ? [] : journal_doc.ids.split(';') ) << journal_doc.doc_id
# find document
doc = nil
tables.each_index do |i|
doc = if doc.nil?
(tables[i].classify.constantize).find(ids[i])
else
doc.send(tables[i].pluralize).find(ids[i])
end
end
# restore and save values
restore.each { |field,value| doc.send("#{field}=",value) }
doc.save
# TODO Error checking
{ 'msg_info' => (t ('drgcms.dc_journal.restored')) }
end
render inline: result.to_json, formats: 'js'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_from_journal\r\n # Only administrators can perform this operation\r\n unless dc_user_has_role('admin')\r\n return render plain: { 'msg_info' => (t ('drgcms.not_authorized')) }.to_json\r\n end\r\n # selected fields to hash\r\n restore = {} \r\n params[:select].each { |key,value| restore[key] = ... | [
"0.7390467",
"0.63006765",
"0.62760204",
"0.62753516",
"0.61917746",
"0.6177054",
"0.61600447",
"0.615471",
"0.60448",
"0.59916365",
"0.59766567",
"0.5932643",
"0.58583075",
"0.5843801",
"0.57998765",
"0.57667685",
"0.5734534",
"0.5678913",
"0.56276613",
"0.5625284",
"0.56246... | 0.73040944 | 1 |
Copy current record to clipboard as json text. It will actually ouput an window with data formatted as json. | def copy_clipboard
# Only administrators can perform this operation
return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin')
#
respond_to do |format|
# just open new window to same url and come back with html request
format.json { dc_render_ajax(operation: 'window', url: request.url ) }
format.html do
doc = dc_find_document(params[:table], params[:id], params[:ids])
text = "<br><br>[#{params[:table]},#{params[:id]},#{params[:ids]}]<br>"
render text: text + doc.as_document.to_json
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n format.json { dc_re... | [
"0.62859005",
"0.6171048",
"0.60664254",
"0.5919167",
"0.5677381",
"0.56047636",
"0.5596036",
"0.559588",
"0.54933274",
"0.54467565",
"0.5411955",
"0.5361212",
"0.5313138",
"0.5313138",
"0.5313138",
"0.53060913",
"0.53060913",
"0.53060913",
"0.53060913",
"0.52356064",
"0.5222... | 0.57165 | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.