-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser-1.rb
More file actions
executable file
·61 lines (59 loc) · 2.01 KB
/
Copy pathparser-1.rb
File metadata and controls
executable file
·61 lines (59 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/ruby
#This is Row CDR Madiator which will try to look call legs up and generating Call-CDR
require 'rubygems'
require 'mongo'
require 'bson'
require 'peach'
require 'redis'
require 'awesome_print'
include Mongo
@database = MongoClient.new('localhost',27017,:pool_size => 1, :pool_timeout => 180).db("local")
@coll = @database.collection("row")
cursor=@coll.find({"Ingress" => {'$exists'=>1}})
cursor.each do |rowIn|
callid = rowIn['Ingress'].split(',').to_a[1]
engine = rowIn['Ingress'].split(',').to_a[7]
puts "CallID(Ingress): #{callid}"
######################################
## Egress lookup query
cmd = {
aggregate: 'row',
pipeline:[
{'$match' => {'Egress' => {'$regex' => callid } }},
# {'$project' => {'Egress' => 1}},
]
}
res = @database.command(cmd)['result']
######################################
res.each do |rowEg|
puts "CallID(Egress): #{rowEg['Egress'].split(',').to_a[1]}"
puts "\t#{rowIn['_id']}\n\t#{rowEg['_id']}"
puts rowEg['elemA'].split('{').to_a[1].split(',').to_a[0]
puts rowEg['elemA'].split('{').to_a[2].split(',').to_a[18]
puts rowEg['elemA'].split('{').to_a[2].split(',').to_a[20]
puts rowEg['elemA'].split('{').to_a[2].split(',').to_a[45]
puts rowEg['elemC']#.split(',').to_a[3]
end
puts "Engine: #{engine}"
end
#puts @coll.find({"Egress"=>{'$exists'=>1}}).count()
#puts row['Ingress']
# cmd = {
# aggregate: 'carriers',
# pipeline: [
# {'$project' => {
# 'rates' => 1,
# 'Name' => 1}},
# {'$unwind' => '$rates'},
# {'$match' => {
# 'rates.Prefix' => "#{dnid[0,dnid.length-count]}",
# 'rates.Activation' => "2013-04-21"
# }},
# {'$limit' => 1 },
# ]}
# res = @db.command(cmd)['result']
######################################
#cursor=@coll.find({"Egress"=>{"$exists"=>1}},:fields => {accountcodes: { '$elemMatch' => { id: accountcode }}})
#cursor=@coll.find({"Egress"=>{"$exists"=>1}},:fields => {elemA:1,elemD:1})
#cursor=@coll.find({},:fields => {Ingress:1,Egress:1,elemA:1,elemD:1})
######################################