Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created April 24, 2014 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruprict/11259551 to your computer and use it in GitHub Desktop.
Save ruprict/11259551 to your computer and use it in GitHub Desktop.
def update_sb_for_bad_cards(increment=500)
cmd = OrientDB::SQLCommand.new("select count(*) from card")
res = Oriented.graph.command(cmd).execute
count = res.to_a.first["count"]
loop_count = count/increment
start_id = 0
(0..loop_count).each do |num|
end_id = start_id + increment
sql = "create edge Card__sanctioning_body from " +
"(select from Card where @rid >= #24:#{start_id} " +
"and @rid < #24:#{end_id} and out_Card__sanctioning_body "+
"is null and out_Card__carded_user is not null) to #13:0"
cmd = OrientDB::SQLCommand.new(sql)
Oriented.graph.command(cmd).execute
Oriented.graph.commit
puts "*** #{end_id} complete"
start_id = end_id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment