-
Notifications
You must be signed in to change notification settings - Fork 68
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 second db handle for only for user admin and writes #1184
Conversation
…nnection is used for writes only
…tag engines with id and log those too, and superfluous user method cleanup
64a798c
to
03c27f2
Compare
cherry-picked and force updated to set these changes against the current |
…ng for engine creation
…ove session ctx mgrs to admin page
updated change summary:
|
…newly updated User
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.
Nice work!
@@ -25,7 +25,7 @@ def _default_date_now(): | |||
class User(Base): | |||
__tablename__ = "api_user" | |||
id = Column(Integer, primary_key=True, autoincrement=True) | |||
roles = relationship("UserRole", secondary=association_table) | |||
roles = relationship("UserRole", secondary=association_table, lazy="joined") # last arg does an eager load of this property from foreign tables |
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.
Wow, that is awesome. Didn't know about that param.
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.
🌊 🏄
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.
Some questions about TODOs and when to/not-to use the decorators, but no dealbreakers. Beautiful work!
session.commit() | ||
# retrieve the newly updated User object | ||
return session.query(User).filter(User.id == user.id).first() |
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.
is this still needed if we're using WriteSession for both writes and reads in admin?
oh i see; this is adding back the commit removed from 99, and lets you return directly instead of needing a separate return at 100
carry on
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.
yap!
src/server/admin/models.py
Outdated
) | ||
session.execute(update_stmt) | ||
return User._assign_roles(user, roles, session) | ||
# TODO: else: raise Exception() ?? |
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.
does this TODO need to be resolved before merge, or should we file a ticket for it?
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.
¯\_(ツ)_/¯ im ok with neither because our usage of this seems consistent enough right now. a future caller of this can get the same information by checking for a None
return value instead of catching an exception. but its easy enough to do, so ill just do it. change incoming shortly...
src/server/admin/models.py
Outdated
session.commit() | ||
""") | ||
session.commit() | ||
# TODO: look up and return new role |
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.
does this TODO need to be resolved before merge, or should we file a ticket for it?
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.
¯\_(ツ)_/¯ im ok with neither, esp because create_role()
isnt even used anywhere at the moment. but its easy enough to do, so ill just do it. change incoming shortly...
TODOs done: raise Exception when trying to update non-existent User, return UserRole on creation. also use more appropriate reciever for static method call, and expand comment on static vs bound methods in User.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
👍 🚀
change 'user_engine' to a 'WriteSession' instead, so the master db connection is used for writes only