1. Nikolaj Sjujskij
  2. tracaggr

Commits

Nikolaj Sjujskij  committed 6a8ccae

Strip tickets that were closed more than one time (reopened ones)

If ticket has no DATEFIELD set, and was closed, then reopened and closed
again (probably more than one time), changes introduced in 9288d66eaa9d make
it appear in calendar more than one time (one for every closing). This
changeset fixes it, only last closing is accounted now.

  • Participants
  • Parent commits a8a4360
  • Branches default

Comments (0)

Files changed (1)

File defaults.py

View file
                     ticket_custom.value ILIKE %s""".format(DATE_FIELD)
 
 # query to fetch tickets closed this month without DATE_FIELD set
-##TODO: strip reopened
-QUERY_UNSET_DATE = """SELECT ticket.id, ticket.owner, ticket.summary,
+QUERY_UNSET_DATE = """SELECT DISTINCT ON (ticket.id)
+                            ticket.id, ticket.owner, ticket.summary,
                             ticket_change.time AS closed_at
                         FROM ticket INNER JOIN ticket_change
                             ON ticket.id = ticket_change.ticket
                             ticket_custom.name='{0}' AND
                             ticket_custom.value='' AND
                             ticket_change.time>=%s AND
-                            ticket_change.time<=%s""".format(DATE_FIELD)
+                            ticket_change.time<=%s
+                        ORDER BY ticket.id, ticket_change.time DESC;
+                    """.format(DATE_FIELD)
 
 # query to fetch open tickets
 QUERY_OPEN = "SELECT id, owner, summary FROM ticket WHERE status!='closed'"