Temp changes for profiling
This commit is contained in:
parent
c7253e2211
commit
57765a64a7
@ -92,7 +92,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Ensure row numbers in playlist are contiguous
|
# Ensure row numbers in playlist are contiguous
|
||||||
PlaylistRows.fixup_rownumbers(session, playlist_id)
|
PlaylistRows.fixup_rownumbers(session, playlist_id)
|
||||||
# Populate self.playlist_rows
|
# Populate self.playlist_rows
|
||||||
self.refresh_data(session)
|
self.load_data(session)
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
@ -803,8 +803,10 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
self.invalidate_rows(list(row_map.keys()))
|
self.invalidate_rows(list(row_map.keys()))
|
||||||
|
|
||||||
|
@line_profiler.profile
|
||||||
def move_rows_between_playlists(
|
def move_rows_between_playlists(
|
||||||
self, from_rows: list[int], to_row_number: int, to_playlist_id: int
|
self, from_rows: list[int], to_row_number: int, to_playlist_id: int,
|
||||||
|
dummy_for_profiling=None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Move the playlist rows given to to_row and below of to_playlist.
|
Move the playlist rows given to to_row and below of to_playlist.
|
||||||
@ -1002,6 +1004,33 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Copy to self.playlist_rows
|
# Copy to self.playlist_rows
|
||||||
self.playlist_rows = new_playlist_rows
|
self.playlist_rows = new_playlist_rows
|
||||||
|
|
||||||
|
# Same as refresh data, but only used when creating playslit.
|
||||||
|
# Distinguishes profile time between initial load and other
|
||||||
|
# refreshes.
|
||||||
|
def load_data(self, session: db.session, dummy_for_profiling=None) -> None:
|
||||||
|
"""Populate self.playlist_rows with playlist data"""
|
||||||
|
|
||||||
|
# We used to clear self.playlist_rows each time but that's
|
||||||
|
# expensive and slow on big playlists
|
||||||
|
|
||||||
|
# Note where each playlist_id is
|
||||||
|
plid_to_row: dict[int, int] = {}
|
||||||
|
for oldrow in self.playlist_rows:
|
||||||
|
plrdata = self.playlist_rows[oldrow]
|
||||||
|
plid_to_row[plrdata.playlistrow_id] = plrdata.row_number
|
||||||
|
|
||||||
|
# build a new playlist_rows
|
||||||
|
new_playlist_rows: dict[int, RowAndTrack] = {}
|
||||||
|
for p in PlaylistRows.get_playlist_rows(session, self.playlist_id):
|
||||||
|
if p.id not in plid_to_row:
|
||||||
|
new_playlist_rows[p.row_number] = RowAndTrack(p)
|
||||||
|
else:
|
||||||
|
new_playlist_rows[p.row_number] = self.playlist_rows[plid_to_row[p.id]]
|
||||||
|
new_playlist_rows[p.row_number].row_number = p.row_number
|
||||||
|
|
||||||
|
# Copy to self.playlist_rows
|
||||||
|
self.playlist_rows = new_playlist_rows
|
||||||
|
|
||||||
def refresh_row(self, session, row_number):
|
def refresh_row(self, session, row_number):
|
||||||
"""Populate dict for one row from database"""
|
"""Populate dict for one row from database"""
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user