-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use chronicler base class to consolidate implementations where supported #138
base: master
Are you sure you want to change the base?
Conversation
blaseball_mike/models/base.py
Outdated
@classmethod | ||
def load_history(cls, id_, order='desc', count=None): | ||
entities = chronicler.get_versions(cls._entity_type, id_=id_, order=order, count=count) | ||
return [cls(dict(e['data'], timestamp=e['validFrom'])) for e in entities] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you use () instead of [] this will produce a generator, which is probably what we actually want
blaseball_mike/models/team.py
Outdated
if getattr(self, "timestamp", None): | ||
return [Player.load_one_at_time(x, self.timestamp) for x in self._lineup_ids] | ||
return [Player.load_one(x, time=self.timestamp) for x in self._lineup_ids] | ||
else: | ||
players = Player.load(*self._lineup_ids) | ||
return [players.get(id_) for id_ in self._lineup_ids] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we can use the same load function for both, we dont need these if/else trees
No description provided.