diff options
-rw-r--r-- | distixlib/plugins/html_plugin.py | 45 | ||||
-rw-r--r-- | distixlib/ticket_store.py | 6 |
2 files changed, 45 insertions, 6 deletions
diff --git a/distixlib/plugins/html_plugin.py b/distixlib/plugins/html_plugin.py index 379a83c..2ee8bd1 100644 --- a/distixlib/plugins/html_plugin.py +++ b/distixlib/plugins/html_plugin.py @@ -84,8 +84,10 @@ class StaticSite(object): 'index.html.j2', 'index.html', self._ticket_is_open) self._render_ticket_list( 'closed.html.j2', 'closed.html', self._ticket_is_closed) - for ticket in self._ticket_store.get_tickets(): + for ticket_id in self._ticket_store.get_ticket_ids(): + ticket = self._ticket_store.get_ticket(ticket_id) self._render_ticket(ticket) + self._ticket_store.clear_ticket_cache() self._copy_static_files() def _format_timestamp(self): @@ -129,11 +131,16 @@ class StaticSite(object): return markdown.markdown(text) def _get_tickets(self, condition): - return [ - ticket - for ticket in self._ticket_store.get_tickets() - if condition(ticket) - ] + for ticket_id in self._ticket_store.get_ticket_ids(): + ticket = self._ticket_store.get_ticket(ticket_id) + self._ticket_store.clear_ticket_cache() + if condition(ticket): + lt = TicketLight() + lt.set_ticket_id(ticket_id) + lt.set_title(ticket.get_title()) + lt.set_newest_message_timestamp( + ticket.get_newest_message_timestamp()) + yield lt def _ticket_is_open(self, ticket): return not self._ticket_is_closed(ticket) @@ -163,6 +170,32 @@ class StaticSite(object): f.write(text.encode('UTF8')) +class TicketLight(object): + + def __init__(self): + self._ticket_id = None + self._title = None + self._timestamp = None + + def set_ticket_id(self, ticket_id): + self._ticket_id = ticket_id + + def set_title(self, title): + self._title = title + + def set_newest_message_timestamp(self, timestamp): + self._timestamp = timestamp + + def get_ticket_id(self): + return self._ticket_id + + def get_title(self): + return self._title + + def get_newest_message_timestamp(self): + return self._timestamp + + class UsageError(distixlib.StructuredError): msg = '"html" command must get exactly one argument: the output directory' diff --git a/distixlib/ticket_store.py b/distixlib/ticket_store.py index 2343e2e..fdf5b02 100644 --- a/distixlib/ticket_store.py +++ b/distixlib/ticket_store.py @@ -74,6 +74,9 @@ class TicketStore(object): return os.listdir(self._dirname) return [] + def clear_ticket_cache(self): # pragma: no cover + self._ticket_cache.clear() + def get_ticket(self, ticket_id_or_prefix): '''Return a distixlib.Ticket for an existing ticket in the store.''' @@ -226,3 +229,6 @@ class _TicketCache(object): def get_all(self): return self._known_tickets.values() + + def clear(self): # pragma: no cover + self._known_tickets.clear() |