def load_tags( q: sqla.sql.Select, user: orm_users.User, tags_joined: bool = False, ) -> sqla.sql.Select: load_tags = load_tags_option(user, tags_joined) q = q.options(load_tags) return q
def load_feed( q: sqla.sql.Select, feed_joined: bool = False, ) -> sqla.sql.Select: item_feed = orm_items.Item.feed if feed_joined: load_feed = sqla.orm.contains_eager(item_feed) else: load_feed = sqla.orm.selectinload(item_feed) q = q.options(load_feed) return q
def load_magic( q: sqla.sql.Select, user: orm_users.User, magic_joined: bool = False, ) -> sqla.sql.Select: item_magic = orm_items.Item.magic.and_( orm_items.Magic.UserID == user.UserID, ) if magic_joined: load_magic = sqla.orm.contains_eager(item_magic) else: load_magic = sqla.orm.selectinload(item_magic) q = q.options(load_magic) return q
def load_like( q: sqla.sql.Select, user: orm_users.User, like_joined: bool = False, ) -> sqla.sql.Select: item_likes = orm_items.Item.likes.and_( orm_items.Like.UserID == user.UserID, ) if like_joined: load_like = sqla.orm.contains_eager(item_likes) else: load_like = sqla.orm.selectinload(item_likes) q = q.options(load_like) return q