Commit 70ffd1a0 authored by David Trattnig's avatar David Trattnig
Browse files

Revert short-lived session. #90

parent 52c094d4
Pipeline #1180 passed with stage
in 1 minute and 9 seconds
......@@ -64,10 +64,15 @@ if __sqlalchemy_version < (1, 4):
see https://docs.sqlalchemy.org/en/13/orm/session_basics.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it
"""
session = scoped_session(DB.session_factory)
try:
yield session
finally:
session.close()
# Commented out because of https://gitlab.servus.at/aura/engine/-/issues/90
# try:
# yield session
# finally:
# session.close()
yield session
DB.Session = get_session_context
......@@ -192,27 +197,27 @@ class Timeslot(DB.Model, AuraDatabaseModel):
playlist = relationship("Playlist",
primaryjoin="and_(Timeslot.timeslot_start==Playlist.timeslot_start, \
Timeslot.playlist_id==Playlist.playlist_id, Timeslot.show_name==Playlist.show_name)",
uselist=False, back_populates="timeslot")
uselist=False, back_populates="timeslot", lazy='subquery')
default_schedule_playlist = relationship("Playlist",
primaryjoin="and_(Timeslot.timeslot_start==Playlist.timeslot_start, \
Timeslot.default_schedule_playlist_id==Playlist.playlist_id, Timeslot.show_name==Playlist.show_name)",
uselist=False, back_populates="timeslot")
uselist=False, back_populates="timeslot", lazy='subquery')
default_show_playlist = relationship("Playlist",
primaryjoin="and_(Timeslot.timeslot_start==Playlist.timeslot_start, \
Timeslot.default_show_playlist_id==Playlist.playlist_id, Timeslot.show_name==Playlist.show_name)",
uselist=False, back_populates="timeslot")
uselist=False, back_populates="timeslot", lazy='subquery')
schedule_fallback = relationship("Playlist",
primaryjoin="and_(Timeslot.timeslot_start==Playlist.timeslot_start, \
Timeslot.schedule_fallback_id==Playlist.playlist_id, Timeslot.show_name==Playlist.show_name)",
uselist=False, back_populates="timeslot")
uselist=False, back_populates="timeslot", lazy='subquery')
show_fallback = relationship("Playlist",
primaryjoin="and_(Timeslot.timeslot_start==Playlist.timeslot_start, \
Timeslot.show_fallback_id==Playlist.playlist_id, Timeslot.show_name==Playlist.show_name)",
uselist=False, back_populates="timeslot")
uselist=False, back_populates="timeslot", lazy='subquery')
station_fallback = relationship("Playlist",
primaryjoin="and_(Timeslot.timeslot_start==Playlist.timeslot_start, \
Timeslot.station_fallback_id==Playlist.playlist_id, Timeslot.show_name==Playlist.show_name)",
uselist=False, back_populates="timeslot")
uselist=False, back_populates="timeslot", lazy='subquery')
playlist_id = Column(Integer)
default_schedule_playlist_id = Column(Integer)
......@@ -376,8 +381,8 @@ class Playlist(DB.Model, AuraDatabaseModel):
timeslot_start = Column(DateTime, ForeignKey("timeslot.timeslot_start"))
# Relationships
timeslot = relationship("Timeslot", uselist=False, back_populates="playlist")
entries = relationship("PlaylistEntry", back_populates="playlist")
timeslot = relationship("Timeslot", uselist=False, back_populates="playlist", lazy='subquery')
entries = relationship("PlaylistEntry", back_populates="playlist", lazy='subquery')
# Data
playlist_id = Column(Integer, autoincrement=False)
......@@ -535,8 +540,8 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
artificial_playlist_id = Column(Integer, ForeignKey("playlist.artificial_id"))
# Relationships
playlist = relationship("Playlist", uselist=False, back_populates="entries")
meta_data = relationship("PlaylistEntryMetaData", uselist=False, back_populates="entry")
playlist = relationship("Playlist", uselist=False, back_populates="entries", lazy='subquery')
meta_data = relationship("PlaylistEntryMetaData", uselist=False, back_populates="entry", lazy='subquery')
# Data
entry_num = Column(Integer)
......@@ -683,7 +688,7 @@ class PlaylistEntryMetaData(DB.Model, AuraDatabaseModel):
artificial_entry_id = Column(Integer, ForeignKey("playlist_entry.artificial_id"))
# Relationships
entry = relationship("PlaylistEntry", uselist=False, back_populates="meta_data")
entry = relationship("PlaylistEntry", uselist=False, back_populates="meta_data", lazy='subquery')
# Data
artist = Column(String(256))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment