From ccc1737f2df686b620c772a88f4fa4bff3aba53d Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Fri, 7 Mar 2025 09:30:23 +0000 Subject: [PATCH] Issue 285: additional logging and profiling --- app/playlistmodel.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index 4762033..5571a1a 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -26,6 +26,7 @@ from PyQt6.QtGui import ( ) # Third party imports +import line_profiler from sqlalchemy.orm.session import Session import obswebsocket # type: ignore @@ -729,21 +730,27 @@ class PlaylistModel(QAbstractTableModel): self.reset_track_sequence_row_numbers() self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows)))) + @line_profiler.profile def invalidate_row(self, modified_row: int) -> None: """ Signal to view to refresh invalidated row """ + log.debug(f"issue285: {self}: invalidate_row({modified_row=})") + self.dataChanged.emit( self.index(modified_row, 0), self.index(modified_row, self.columnCount() - 1), ) + @line_profiler.profile def invalidate_rows(self, modified_rows: list[int]) -> None: """ Signal to view to refresh invlidated rows """ + log.debug(f"issue285: {self}: invalidate_rows({modified_rows=})") + for modified_row in modified_rows: self.invalidate_row(modified_row) @@ -1133,6 +1140,7 @@ class PlaylistModel(QAbstractTableModel): self.signals.resize_rows_signal.emit(self.playlist_id) session.commit() + @line_profiler.profile def reset_track_sequence_row_numbers(self) -> None: """ Signal handler for when row ordering has changed. @@ -1143,7 +1151,7 @@ class PlaylistModel(QAbstractTableModel): looking up the playlistrow_id and retrieving the row number from the database. """ - log.debug(f"{self}: reset_track_sequence_row_numbers()") + log.debug(f"issue285: {self}: reset_track_sequence_row_numbers()") # Check the track_sequence.next, current and previous plrs and # update the row number @@ -1267,6 +1275,7 @@ class PlaylistModel(QAbstractTableModel): return header_text + @line_profiler.profile def rowCount(self, index: QModelIndex = QModelIndex()) -> int: """Standard function for view""" @@ -1588,12 +1597,13 @@ class PlaylistModel(QAbstractTableModel): else: self.insert_row(proposed_row_number=row_number, track_id=track_id) + @line_profiler.profile def update_track_times(self) -> None: """ Update track start/end times in self.playlist_rows """ - log.debug(f"{self}: update_track_times()") + log.debug(f"issue285: {self}: update_track_times()") next_start_time: Optional[dt.datetime] = None update_rows: list[int] = []