Performance fix for the main episode list.

When the list of episodes for a channel was displayed, all episodes
were loaded with a single query, then loaded separately by one
inside podcastItem.iter_set_downloading_columns().  This patch
fixes this problem, the TreeModel is built with only one SQL query.

On the same machine a TreeModel for 50 episodes was displayed in
1.915531 seconds, with this patch: 0.236303 (8 times faster).
This commit is contained in:
Justin Forest 2008-10-02 22:40:46 +04:00 committed by Thomas Perl
parent 024094559b
commit 6ddb4b5441

View file

@ -321,12 +321,15 @@ class podcastChannel(object):
log('Returning TreeModel for %s', self.url, sender = self)
return self.items_liststore()
def iter_set_downloading_columns( self, model, iter):
def iter_set_downloading_columns( self, model, iter, episode=None):
global ICON_AUDIO_FILE, ICON_VIDEO_FILE, ICON_BITTORRENT
global ICON_DOWNLOADING, ICON_DELETED, ICON_NEW
url = model.get_value( iter, 0)
episode = db.load_episode(url, factory=lambda x: podcastItem.create_from_dict(x, self))
if episode is None:
url = model.get_value( iter, 0)
episode = db.load_episode(url, factory=lambda x: podcastItem.create_from_dict(x, self))
else:
url = episode.url
if gl.config.episode_list_descriptions:
icon_size = 32
@ -383,7 +386,7 @@ class podcastChannel(object):
new_iter = new_model.append((item.url, item.title, filelength,
True, None, item.cute_pubdate(), description, item.description,
item.local_filename(), item.extension()))
self.iter_set_downloading_columns( new_model, new_iter)
self.iter_set_downloading_columns( new_model, new_iter, episode=item)
self.update_save_dir_size()
return new_model