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

Fix bug in content loading for story queries #25

Merged
merged 1 commit into from
Jun 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backend/python/app/services/implementations/story_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ def __init__(self, logger=current_app.logger):
def get_stories(self):
# Entity is a SQLAlchemy model, we can use convenient methods provided
# by SQLAlchemy like query.all() to query the data
return [result.to_dict() for result in Story.query.all()]
return [
story.to_dict(include_relationships=True) for story in Story.query.all()
]

def get_story(self, id):
# get queries by the primary key, which is id for the Story table
story = Story.query.get(id)
if story is None:
self.logger.error("Invalid id")
raise Exception("Invalid id")
return story.to_dict()
return story.to_dict(include_relationships=True)

def create_story(self, story, content):
# create story
Expand Down