-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoordinator.py
executable file
·43 lines (31 loc) · 1.6 KB
/
Coordinator.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
from MongoManager import *
from WebManager import *
import json
class Coordinator:
def __init__(self):
self.mongoManager = MongoManager()
self.serviceManager = ServiceManager()
def updateSeries(self):
for series in self.mongoManager.getAllSeries():
data = json.loads(self.serviceManager.getSeriesData(series['name']))
if ( data['updated'] > series['updated']):
self.mongoManager.getSeriesRepo.updateSeries(series['id'], data)
episodesData = json.loads(self.serviceManager.getEpisodesData(series['name']))
self.mongoManager.getEpisodeRepo.updateEpisodes(series['id'], episodesData)
def getRecentEpisodes(self):
for series in self.mongoManager.getAllSeries():
_id = series['id']
print(self.mongoManager.getEpisodesRepo.getRecentlyAiredEpisodes(_id))
def bulkInsert(self):
series1 = 'Sherlock'
series2 = 'Kingdom'
series_data1 = self.serviceManager.getSeriesData(series1)
series_data2 = self.serviceManager.getSeriesData(series2)
episodes1 = self.serviceManager.getEpisodesData(series1)
episodes2 = self.serviceManager.getEpisodesData(series2)
self.mongoManager.getSeriesRepo().insertSeries(series_data1)
self.mongoManager.getSeriesRepo().insertSeries(series_data2)
self.mongoManager.getEpisodeRepo().insertEpisodes(episodes1)
self.mongoManager.getEpisodeRepo().insertEpisodes(episodes2)
c = Coordinator()
c.bulkInsert()