Limit history to 500 track
To avoid an too large history list, save/restore maximum 500 tracks. 500 tracks a 3 minuts gives 24 hours history.
This commit is contained in:
parent
9d8034869d
commit
3bf6b9896c
@ -60,10 +60,18 @@ class HistoryController(object):
|
|||||||
|
|
||||||
def _export_state(self):
|
def _export_state(self):
|
||||||
"""Internal method for :class:`mopidy.Core`."""
|
"""Internal method for :class:`mopidy.Core`."""
|
||||||
|
|
||||||
|
# 500 tracks a 3 minutes -> 24 hours history
|
||||||
|
count_max = 500
|
||||||
|
count = 1
|
||||||
history_list = []
|
history_list = []
|
||||||
for timestamp, track in self._history:
|
for timestamp, track in self._history:
|
||||||
history_list.append(HistoryTrack(
|
history_list.append(HistoryTrack(
|
||||||
timestamp=timestamp, track=track))
|
timestamp=timestamp, track=track))
|
||||||
|
count += 1
|
||||||
|
if count_max < count:
|
||||||
|
logger.info('Limit history to %s tracks.', count_max)
|
||||||
|
break
|
||||||
return HistoryState(history=history_list)
|
return HistoryState(history=history_list)
|
||||||
|
|
||||||
def _restore_state(self, state, coverage):
|
def _restore_state(self, state, coverage):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user