View Single Post
Old Yesterday, 05:38 AM   #923
Feoras
Member
Feoras began at the beginning.
 
Posts: 13
Karma: 10
Join Date: May 2023
Device: Kobo Glo
Quote:
Originally Posted by thiago.eec View Post
- Bug fix: sort the records dict treating the idx as integer, instead of text, avoiding the wrong order like '0, 1, 10 ,11, 2, 3,...9'

If you test this version, please leave your feedback. Does the page count show when hovering? Does the records editing work perfectly? Any other suggestions?

Thank you so much for your work, adapting my proposal and making it even better.

Sadly it is not working for me. I think this might be a local thing.


The issue I could find out is, that the month names are lower case (from daily_page_count):
Quote:
daily_page_count[m[_month].lower()][str(_day)] = 0
But inside get_month_stats function the read_pages_month_count is initialized from m
Quote:
from calendar import month_abbr as m
However, these abbr are capital case.

This results in the for loop:
for month in daily_page_count to insert new month into read_pages_month_count instead of replacing the existing once.

This is how read_pages_month_count looks like after:
Quote:
{'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 'Dec': 0, 'jan': 0, 'feb': 0, 'mar': 0, 'apr': 0, 'may': 0, 'jun': 0, 'jul': 0, 'aug': 573, 'sep': 231, 'oct': 0, 'nov': 0, 'dec': 0}
So either daily_page_count should not be lower case or month_page_stats has to be (but month_book_stats is not lower case either).

To be consistent I modified daily_page_count to be capitalized only in the function get_month_stats to be consistent with everything else:
Quote:
def get_month_stats(self, _data: dict[str, dict]) -> tuple[dict[str, list], dict[str, list]]:
month_page_stats = {}
month_book_stats = {}

read_pages_month_count = {
m[1]: 0, m[2]: 0, m[3]: 0, m[4]: 0, m[5]: 0, m[6]: 0,
m[7]: 0, m[8]: 0, m[9]: 0, m[10]: 0, m[11]: 0, m[12]: 0
}
daily_page_count = self.daily_page_count()
daily_page_count = {k.capitalize(): v for k, v in daily_page_count.items()}
Now it works!
Pages are shown correctly and books read when hovering if the settings is set or vise verse if not.

Sorry for the long post and thanks again for implementing this feature <3
Feoras is offline   Reply With Quote