-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.py
46 lines (32 loc) · 1005 Bytes
/
database.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
from src.config import get_url
from pymongo import MongoClient
cluster = ""
client = MongoClient(cluster)
db = client.valorant
collection = db.player_database
def saved_players():
a = collection.find({}, {'_id': 0, 'player_name': 1})
h = []
for j in a:
h.append(list(j.values())[0])
return h
def get_player_name(username=''):
player_name = get_url(username)[1]
return player_name
def get_saved_info(player_name):
try:
t = collection.find({'player_name': player_name})
saved_match_data = []
for b in t:
for k in b.values():
saved_match_data.append(k)
match_duration = saved_match_data[2][0]['Time']
saved_match_time = saved_match_data[2][0]['Span']
saved_info = [saved_match_time, match_duration]
return saved_info, saved_match_data
except IndexError:
pass
# b = get_player_name('peacemaker#dceu')
# print(b)
# a = get_saved_info('peacemaker-dceu')
# print(a)