tg-archive icon indicating copy to clipboard operation
tg-archive copied to clipboard

tg-archive --build fails to build a page if there's no message from the next period

Open 4aiman opened this issue 5 months ago • 1 comments

build.py#L57

In my experience building fails with messages like

jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2025-01-01'

Issue is, it makes it impossible to generate a page for December 2024

All due to a simple fact, the builder somehow expects dayline to have no only messages for 12-2024, but also at least one for 01-2025. Same goes for other months when there's a message on the last date of the month.

I don't know how to fix it properly, but for my purposes it's ok if I have this:

            dayline = OrderedDict()
            for d in self.db.get_dayline(month.date.year, month.date.month, self.config["per_page"]):
                dayline[d.slug] = d
            for d in self.db.get_dayline(month.date.year, month.date.month+1, self.config["per_page"]):
                dayline[d.slug] = d
                break
            for d in self.db.get_dayline(month.date.year+1, 1, self.config["per_page"]):
                dayline[d.slug] = d
                break

Al least it exports everything which was the point.

4aiman avatar Jun 29 '25 16:06 4aiman

yes, it seems I got the same: jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute '2022-12-01'

so let's push issues, notices and updates to https://github.com/knadh/tg-archive/issues/99 even there are some movement is exist... otherwise we will report the same issues again and again and fixing that bug for years...

zv09 avatar Jul 27 '25 15:07 zv09