|
|
@@ -1,19 +1,18 @@
|
|
|
-from app.bnet_retriever.profile import Profile, RemoteProfile, DBProfile
|
|
|
-from app.bnet_retriever.credential import CredentialManager
|
|
|
-from app.bnet_retriever.stat import CompetitiveStat
|
|
|
-from app.utils.db import Mongo
|
|
|
+from .profile import RemoteProfile, DBProfile
|
|
|
+from .credential import CredentialManager
|
|
|
+from .stat import CompetitiveStat
|
|
|
+from .utils.db import Mongo
|
|
|
from bson import ObjectId
|
|
|
+import logging
|
|
|
+
|
|
|
+logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
class Runner:
|
|
|
callbacks = []
|
|
|
|
|
|
- def __init__(self, username: str):
|
|
|
- record = Mongo.db.user.find_one({'username': username})
|
|
|
- if not record:
|
|
|
- raise Exception('No Such User')
|
|
|
- self.username: str = username
|
|
|
- self._id: ObjectId = record['_id']
|
|
|
+ def __init__(self, _id: ObjectId):
|
|
|
+ self._id: ObjectId = _id
|
|
|
|
|
|
# Plugs
|
|
|
# self.profile: Profile = Profile(self)
|
|
|
@@ -26,5 +25,15 @@ class Runner:
|
|
|
self.new_profile.refresh()
|
|
|
self.latest_profile.refresh()
|
|
|
if self.new_profile > self.latest_profile:
|
|
|
+ logger.info("[%s] Found New Profile!", self._id)
|
|
|
Mongo.db.profile.insert(self.new_profile.to_db_record())
|
|
|
self.competitive_stat.calc()
|
|
|
+
|
|
|
+
|
|
|
+class RunnerProxy(Runner):
|
|
|
+ def __init__(self, username: str):
|
|
|
+ record = Mongo.db.user.find_one({'username': username})
|
|
|
+ if not record:
|
|
|
+ raise Exception('No Such User')
|
|
|
+ self.username: str = username
|
|
|
+ super(RunnerProxy, self).__init__(record['_id'])
|