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:
Jens Luetjen 2016-02-06 16:22:54 +01:00
parent 9d8034869d
commit 3bf6b9896c

View File

@ -60,10 +60,18 @@ class HistoryController(object):
def _export_state(self):
"""Internal method for :class:`mopidy.Core`."""
# 500 tracks a 3 minutes -> 24 hours history
count_max = 500
count = 1
history_list = []
for timestamp, track in self._history:
history_list.append(HistoryTrack(
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)
def _restore_state(self, state, coverage):