View Single Post
Old 01-08-2014, 08:31 PM   #603
sengian
Zealot
sengian doesn't littersengian doesn't litter
 
sengian's Avatar
 
Posts: 105
Karma: 132
Join Date: Jul 2010
Location: Roubaix, France
Device: PRS-T1;PRS-650;PocketBook Touch Lux 2
Update of actions.py/update_series_custom_column

Hello Kiwidude,
I am using this pluggin for a while and now that I have moved to a NAS storage (I know I am a sinner, but for me this is working quite well), a problem I had before with removing and adding books is amplified.
Indeed, it takes a very long time to do such a simple operation, so I timed the code and the problem is mostly in action.py, with the update_series_custom_column function and especially the following loop timed up to 261.895619221s in my case:
Code:
for idx, book_id in enumerate(book_ids):
                series_idx = idx + 1
                existing_series_name = db.get_custom(book_id, label=label, index_is_id=True)
                existing_series_idx = db.get_custom_extra(book_id, label=label, index_is_id=True)
                if series_name != existing_series_name or series_idx != existing_series_idx:
                    db.set_custom(book_id, series_name, label=label, commit=False, extra=series_idx)
                    changed_series_book_ids.append(book_id)
                if book_id in existing_series_book_ids:
                    existing_series_book_ids.remove(book_id)
I thought this loop would hugely benefit from the new database optimizations which you are not using currently.

I have modified it a little bit to use the new db api and I have a significant improvement, at least 3 times faster. You will find attached the modified file if you want to include the modifications in the official release.

If you are interested and you think of other parts of the code that could benefits from those improvements and you want me to have a look, please let me know.

I have tested this modification, but mainly for adding/removing a book and not extensively.
Attached Files
File Type: zip action.zip (11.2 KB, 234 views)
sengian is offline   Reply With Quote