mongogems 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/savedPipeline.rb +39 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76e7dbd3e0694f3ad409e13c3530ed907a4d828281bec0f3f964e63cf3cc706c
|
|
4
|
+
data.tar.gz: c59ee55d845c14dac46e17d6dbcf0ba10b2242d9623839c94b212c92b9f7499a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 941bf504d23cb010f8c21293c161788cb45d38e91e85aaaa3bd4dc2c9f5c70c9be0c240823c363889645d8f7d416af92dc380823706a6560a445bb2dc2458918
|
|
7
|
+
data.tar.gz: b9616a4cfd7458dc0bb1deb57b29c4dae8becff446fbef902fab8f00f60e4ce8eec616f70279c4393a9bc1c635b8a9e9fc862cb27a9ff825ca7416922824cd0e
|
data/lib/savedPipeline.rb
CHANGED
|
@@ -32,9 +32,7 @@ def pipeline_to_mongosh_script(infile, outfile)
|
|
|
32
32
|
mongosh_script_out =
|
|
33
33
|
"//Query name: #{data['name']}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
db.#{collname}.aggregate(
|
|
35
|
+
db.getSiblingDB('#{dbname}').#{collname}.aggregate(
|
|
38
36
|
" + the_pipeline + "
|
|
39
37
|
, {allowDiskUse: true}
|
|
40
38
|
);
|
|
@@ -43,4 +41,42 @@ db.#{collname}.aggregate(
|
|
|
43
41
|
File.write(outfile, mongosh_script_out)
|
|
44
42
|
end
|
|
45
43
|
|
|
44
|
+
|
|
45
|
+
def pipeline_to_view_mongosh_script(infile, viewname, outfile)
|
|
46
|
+
txt = File.read(infile)
|
|
47
|
+
data = JSON.parse(txt)
|
|
48
|
+
|
|
49
|
+
ns_split = data['namespace'].split '.', 2
|
|
50
|
+
dbname = ns_split[0]
|
|
51
|
+
collname = ns_split[1]
|
|
52
|
+
|
|
53
|
+
the_pipeline = "[\n"
|
|
54
|
+
is_first = true
|
|
55
|
+
data['pipeline'].each do |pstage|
|
|
56
|
+
if not pstage["isEnabled"]
|
|
57
|
+
next
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if is_first
|
|
61
|
+
is_first = false
|
|
62
|
+
else
|
|
63
|
+
the_pipeline += ', '
|
|
64
|
+
end
|
|
65
|
+
stage_txt = pstage['stage']
|
|
66
|
+
stage_txt = stage_txt.gsub("\\r", "\r").gsub("\\n", "\n")
|
|
67
|
+
the_pipeline += "{ #{pstage['stageOperator']}: " + stage_txt + " }"
|
|
68
|
+
end
|
|
69
|
+
the_pipeline += "\n]"
|
|
70
|
+
|
|
71
|
+
mongosh_script_out =
|
|
72
|
+
"//Query name: #{data['name']}
|
|
73
|
+
|
|
74
|
+
db.getSiblingDB('#{dbname}').createView('#{viewname}', '#{collname}',
|
|
75
|
+
" + the_pipeline + "
|
|
76
|
+
);
|
|
77
|
+
"
|
|
78
|
+
|
|
79
|
+
File.write(outfile, mongosh_script_out)
|
|
80
|
+
end
|
|
81
|
+
|
|
46
82
|
# pipeline_to_mongosh_script filename, '/dev/null'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongogems
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katkam Nitin Reddy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-05-
|
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mongo
|