Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This gives us some visibility into tickets that bounce back and forth between closed and wontfix.
- Loading branch information
Showing
6 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
{% extends "base_community.html" %} | |||
|
|||
{% block content-related %}{% endblock %} | |||
|
|||
{% block title %}Bouncing Tickets{% endblock %} | |||
|
|||
{% block content %} | |||
|
|||
<h1>Bouncing Tickets</h1> | |||
|
|||
<h2 class="deck">Tickets that have been repeatedly reopened.</h2> | |||
|
|||
<table width="90%" class="docutils"> | |||
<thead> | |||
<tr> | |||
<th>Ticket</th> | |||
<th>Times reopened</th> | |||
<th>Last reopened</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
{% for t in tickets %} | |||
<tr> | |||
<td><a href="http://code.djangoproject.com/ticket/{{ t.id }}">#{{ t.id }}: {{ t.summary|truncatewords:10 }}</a></td> | |||
<td>{{ t.times_reopened }}</td> | |||
<td>{{ t.last_reopen_time|date:"F j, Y" }}</td> | |||
</tr> | |||
{% endfor %} | |||
</tbody> | |||
</table> | |||
|
|||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
from south.db import dbs | |||
from south.v2 import SchemaMigration | |||
|
|||
# | |||
# Create a database view for "bouncing" tickets - tickets that change their | |||
# state from closed back to open, possibly a number of times. | |||
# | |||
|
|||
class Migration(SchemaMigration): | |||
viewname = "bouncing_tickets" | |||
viewquery = """ | |||
SELECT | |||
ticket.id, | |||
ticket.summary, | |||
COUNT(*) AS times_reopened, | |||
MAX(change.time) AS last_reopen_time | |||
FROM ticket_change AS change | |||
JOIN ticket ON change.ticket = ticket.id | |||
WHERE | |||
change.field = 'status' | |||
AND change.oldvalue = 'closed' | |||
AND change.newvalue != 'closed' | |||
AND ticket.resolution = 'wontfix' | |||
GROUP BY ticket.id; | |||
""" | |||
|
|||
def forwards(self, orm): | |||
db = dbs['trac'] | |||
db.execute("CREATE VIEW %s AS %s" % (self.viewname, self.viewquery)) | |||
db.execute('COMMIT') | |||
|
|||
def backwards(self, orm): | |||
db = dbs['trac'] | |||
db.execute("DROP VIEW %s" % self.viewname) | |||
db.execute('COMMIT') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
from django.conf.urls import patterns, url | |||
from . import views | |||
|
|||
urlpatterns = patterns('', | |||
url( | |||
r'^bouncing/$', | |||
views.bouncing_tickets, | |||
name='bouncing_tickets', | |||
), | |||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
import datetime | |||
from django.shortcuts import render | |||
from django import db | |||
from django.utils.tzinfo import FixedOffset | |||
|
|||
def bouncing_tickets(request): | |||
c = db.connections['trac'].cursor() | |||
c.execute("""SELECT * FROM bouncing_tickets | |||
WHERE times_reopened >= 3 | |||
ORDER BY last_reopen_time DESC""") | |||
tickets = dictfetchall(c) | |||
|
|||
# Fix timestamps. LOLTrac. | |||
for t in tickets: | |||
t['last_reopen_time'] = ts2dt(t['last_reopen_time']) | |||
|
|||
return render(request, | |||
'tracdb/bouncing_tickets.html', | |||
{'tickets': tickets} | |||
) | |||
|
|||
def ts2dt(ts): | |||
epoc = datetime.datetime(1970, 1, 1, tzinfo=FixedOffset(0)) | |||
return epoc + datetime.timedelta(microseconds=ts) | |||
|
|||
def dictfetchall(cursor): | |||
desc = cursor.description | |||
return [ | |||
dict(zip([col[0] for col in desc], row)) | |||
for row in cursor.fetchall() | |||
] |