Skip to content
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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

rgallo
Copy link
Contributor

@rgallo rgallo commented May 27, 2021

No description provided.

@Edgarware Edgarware linked an issue May 27, 2021 that may be closed by this pull request
@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]
Copy link
Collaborator

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

Comment on lines 44 to 48
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]
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model Load changes
2 participants