-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnectMongoDB.py
87 lines (72 loc) · 2.44 KB
/
connectMongoDB.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from pymongo import MongoClient
from bson.objectid import ObjectId
import re
'''
client = MongoClient('mongodb://qaubd1:27017')
db = client.prf
collection = db.builds
a = collection.find().limit(1)
for i in a:
print(i)
'''
def getMongodb():
client = MongoClient('mongodb://qaubd1:27017')
db = client.prf
return db
def getMongoConnections(connection):
db = getMongodb()
conn = ''
if connection == 'builds':
conn = db.builds
elif connection == 'benchmarks':
conn = db.benchmarks
elif connection == 'results':
conn = db.results
return conn
def getBeanchmarks():
conn = getMongoConnections('benchmarks')
# results = conn.find({}, {'id': 1, 'bmark_group': 1, 'bmark_name': 1})
results = conn.find().sort([('bmark_group', -1)]).limit(2)
# results = conn.find()
return results
def getBuilds():
conn = getMongoConnections('builds')
# results = conn.find({},{'_id': 1, 'name': 1})
results = conn.find().sort([('name', -1)]).limit(2)
return results
if __name__ == '__main__':
# benchmarks = getBeanchmarks()
# for benchmark in benchmarks:
# print(benchmark)
# builds = getBuilds()
# for build in builds:
# print(build)
# countbenchmrk = 0
# countbuild = 0
# builds = getBuilds()
# for build in builds:
# countbuild += 1
# benchmarks = getBeanchmarks()
# for benchmark in benchmarks:
# countbenchmrk += 1
# # print(f'{countbuild} - {countbenchmrk}: {build["name"]} | {benchmark["bmark_name"]}')
# print(f'{countbuild} - {countbenchmrk}: {build["name"]}={build["_id"]} | {benchmark["bmark_name"]}={benchmark["_id"]}')
conn1 = getMongoConnections('results')
conn2 = getMongoConnections('builds')
results = conn1.find( { "bmark_id":ObjectId("5b2274ce4fbd0333c3cb1b47") } )
build = 0
build = []
score = []
for result in results:
for x in conn2.find({"_id": ObjectId(result['build_id'])}):
try:
build_no = x['name'].split('-')[2]
if len(build_no) == 4:
# print(f'{result["_id"]} - {result["results"]["RN_loop_results_warmup_time"]}')
# print(build_no)
score.append(result["results"]["RN_loop_results_warmup_time"][0])
build.append(build_no)
else:
continue
except:
pass