Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lars Kruse
aura-engine
Commits
70ffd1a0
Commit
70ffd1a0
authored
Jan 21, 2022
by
David Trattnig
Browse files
Revert short-lived session. #90
parent
52c094d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/scheduling/models.py
View file @
70ffd1a0
...
...
@@ -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
))
...
...
Lars Kruse
@sumpfralle
mentioned in commit
0a675430
·
Jan 22, 2022
mentioned in commit
0a675430
mentioned in commit 0a675430c1b5806b4627f39ed3ccce9d5fbaa669
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment