diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-03-09 15:33:42 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-03-09 16:09:10 +0200 |
commit | a2473f3ce59135196cf48d647b9c9f9837356c06 (patch) | |
tree | 836809da19b4addce23a5cf828bdb817313df4e5 | |
parent | 45e7efd99d3e553af42b3ae7e437f32fcd450457 (diff) | |
download | distix-a2473f3ce59135196cf48d647b9c9f9837356c06.tar.gz |
Change "distix list" to include date in listing
Also, sort by date in the output.
That's date of the newest message in the ticket.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | distixlib/plugins/list_plugin.py | 6 | ||||
-rw-r--r-- | distixlib/templates/list.j2 | 2 | ||||
-rw-r--r-- | yarns/040-new.yarn | 2 | ||||
-rw-r--r-- | yarns/080-import-mail.yarn | 14 |
5 files changed, 17 insertions, 9 deletions
@@ -7,6 +7,8 @@ distix, a distributed ticketing system. Version 0.5+git, not yet released --------------------------------- +* `distix list` now shows the date of the newest message in the + ticket and sorts the tickets by that date. Version 0.5, released 2016-03-08 --------------------------------- diff --git a/distixlib/plugins/list_plugin.py b/distixlib/plugins/list_plugin.py index 433c8c5..33a63d5 100644 --- a/distixlib/plugins/list_plugin.py +++ b/distixlib/plugins/list_plugin.py @@ -16,9 +16,11 @@ # =*= License: GPL-3+ =*= +import email import glob import locale import os +import time import cliapp @@ -42,6 +44,7 @@ class ListPlugin(cliapp.Plugin): tickets_to_list = self._select_tickets(all_tickets, args[0]) else: tickets_to_list = all_tickets + tickets_to_list = self._sort_tickets(tickets_to_list) variables = { 'tickets': tickets_to_list, @@ -68,6 +71,9 @@ class ListPlugin(cliapp.Plugin): metadata = ticket.get_ticket_metadata() return key in metadata and value in metadata.get_all_values(key) + def _sort_tickets(self, tickets): + return sorted(tickets, key=lambda t: t.get_newest_message_timestamp()) + def _get_renderer(self): _, encoding = locale.getdefaultlocale() if encoding is None: diff --git a/distixlib/templates/list.j2 b/distixlib/templates/list.j2 index 2d49824..3bdb486 100644 --- a/distixlib/templates/list.j2 +++ b/distixlib/templates/list.j2 @@ -1,3 +1,3 @@ {% for ticket in tickets %} -{{ ticket.get_ticket_id() }} {{ ticket.get_title() }} +{{ ticket.get_ticket_id() }} {{ ticket.get_newest_message_timestamp()|date }} {{ ticket.get_title() }} {% endfor %} diff --git a/yarns/040-new.yarn b/yarns/040-new.yarn index fc2bff8..ae70656 100644 --- a/yarns/040-new.yarn +++ b/yarns/040-new.yarn @@ -21,4 +21,4 @@ We create a new ticket, with a title that contains non-ASCII text. WHEN user attempts to run distix list THEN attempt succeeded - AND output matches "^[0-9a-f]{32} new-ticket-title-gröt$" + AND output matches "^[0-9a-f]{32} .* new-ticket-title-gröt$" diff --git a/yarns/080-import-mail.yarn b/yarns/080-import-mail.yarn index d458deb..7d7a1b8 100644 --- a/yarns/080-import-mail.yarn +++ b/yarns/080-import-mail.yarn @@ -23,7 +23,7 @@ will read the e-mail from its standard input. WHEN user changes working directory to REPO AND user attempts to run distix list THEN attempt succeeded - AND output matches "^[0-9a-f]{32} bar$" + AND output matches "^[0-9a-f]{32} .* bar$" Import one email twice. It should result in the mail existing only once in the ticket. @@ -61,7 +61,7 @@ Next, import an mbox. WHEN user changes working directory to REPO AND user attempts to run distix list THEN attempt succeeded - AND output matches "^[0-9a-f]{32} bar$" + AND output matches "^[0-9a-f]{32} .* bar$" Next, import a Maildir. @@ -78,7 +78,7 @@ Next, import a Maildir. WHEN user changes working directory to REPO AND user attempts to run distix list THEN attempt succeeded - AND output matches "^[0-9a-f]{32} bar$" + AND output matches "^[0-9a-f]{32} .* bar$" When importing e-mails, distix needs to automatically recognise when they belong existing tickets: if the new mail refers to a mail in an @@ -102,8 +102,8 @@ headers. WHEN user changes working directory to REPO AND user attempts to run distix list THEN attempt succeeded - AND output matches "^[0-9a-f]{32} bar$" - AND output doesn't match "^[0-9a-f]{32} blerf$" + AND output matches "^[0-9a-f]{32} .* bar$" + AND output doesn't match "^[0-9a-f]{32} .* blerf$" Ditto, but for mailboxes. @@ -123,5 +123,5 @@ Ditto, but for mailboxes. WHEN user changes working directory to REPO AND user attempts to run distix list THEN attempt succeeded - AND output matches "^[0-9a-f]{32} bar$" - AND output doesn't match "^[0-9a-f]{32} blerf$" + AND output matches "^[0-9a-f]{32} .* bar$" + AND output doesn't match "^[0-9a-f]{32} .* blerf$" |