Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Auri
funkwhale
Commits
40567d3b
Commit
40567d3b
authored
Jan 04, 2019
by
Auri
Browse files
Credits: migration performance
parent
0955d769
Changes
1
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/music/migrations/0037_track_credit.py
View file @
40567d3b
...
...
@@ -6,17 +6,15 @@ import django.db.models.deletion
def
populate_track_credit
(
apps
,
schema_editor
):
from
funkwhale_api.music.models
import
Credit
TrackCredit
=
apps
.
get_model
(
"music"
,
"TrackCredit"
)
Track
=
apps
.
get_model
(
"music"
,
"Track"
)
for
tk
in
Track
.
objects
.
al
l
():
tc
=
TrackCredit
()
tc
.
artist
=
tk
.
artist
tc
.
track
=
tk
tc
.
credit
=
Credit
.
MAIN
tc
.
save
(
)
tracks
=
Track
.
objects
.
v
al
ues
(
'artist__id'
,
'id'
).
iterator
()
credits
=
[
TrackCredit
(
artist_id
=
track
[
'artist__id'
],
track_id
=
track
[
'id'
],
credit
=
"main"
)
for
track
in
tracks
]
TrackCredit
.
objects
.
bulk_create
(
credits
)
def
rewind
(
apps
,
schema_editor
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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