return self.activity
def item_title(self, item):
- if self.cfid:
- return item['name']
- else:
- return '{cfname}: {name}'.format(**item)
+ return item['name']
def item_description(self, item):
- if self.cfid:
- return "<div>Patch: {name}</div><div>User: {by}</div>\n<div>{what}</div>".format(**item)
- else:
- return "<div>Commitfest: {cfname}</div><div>Patch: {name}</div><div>User: {by}</div><div>{what}</div>".format(**item)
+ return "<div>Patch: {name}</div><div>User: {by}</div>\n<div>{what}</div>".format(**item)
def item_link(self, item):
if self.cfid:
- return 'https://commitfest.postgresql.org/{cfid}/{patchid}/'.format(cfid=self.cfid, **item)
+ return 'https://commitfest.postgresql.org/{0}/{1}/'.format(self.cfid, item['patchid'])
else:
return 'https://commitfest.postgresql.org/{cfid}/{patchid}/'.format(**item)
class PatchHistory(models.Model):
patch = models.ForeignKey(Patch, blank=False, null=False)
- date = models.DateTimeField(blank=False, null=False, auto_now_add=True)
+ date = models.DateTimeField(blank=False, null=False, auto_now_add=True, db_index=True)
by = models.ForeignKey(User, blank=False, null=False)
what = models.CharField(max_length=500, null=False, blank=False)
<tr>
<th>Time</th>
<th>User</th>
-{%if not commitfest%}<th>CommitFest</th>{%endif%}
<th>Patch</th>
<th>Activity</th>
</tr>
<tr>
<td style="white-space: nowrap;">{{a.date}}</td>
<td>{{a.by}}</td>
-{%if not commitfest%}<td>{{a.cfname}}</td>{%endif%}
<td><a href="/{%if commitfest%}{{commitfest.id}}{%else%}{{a.cfid}}{%endif%}/{{a.patchid}}/">{{a.name}}</a></td>
<td>{{a.what}}</td>
</tr>
# we're evil. And also because the number has been verified
# when looking up the cf itself, so nothing can be injected
# there.
- extrafields = ''
- where = 'WHERE poc.commitfest_id={0}'.format(cf.id)
+ where = 'WHERE EXISTS (SELECT 1 FROM commitfest_patchoncommitfest poc2 WHERE poc2.patch_id=p.id AND poc2.commitfest_id={0})'.format(cf.id)
else:
cf = None
- extrafields = ',poc.commitfest_id AS cfid,cf.name AS cfname'
- where = ' INNER JOIN commitfest_commitfest cf ON cf.id=poc.commitfest_id'
+ where = ''
- sql = "SELECT ph.date, auth_user.username AS by, ph.what, p.id AS patchid, p.name{0} FROM commitfest_patchhistory ph INNER JOIN commitfest_patch p ON ph.patch_id=p.id INNER JOIN auth_user on auth_user.id=ph.by_id INNER JOIN commitfest_patchoncommitfest poc ON poc.patch_id=p.id {1} ORDER BY ph.date DESC LIMIT {2}".format(extrafields, where, num)
+ sql = "SELECT ph.date, auth_user.username AS by, ph.what, p.id AS patchid, p.name, (SELECT max(commitfest_id) FROM commitfest_patchoncommitfest poc WHERE poc.patch_id=p.id) AS cfid FROM commitfest_patchhistory ph INNER JOIN commitfest_patch p ON ph.patch_id=p.id INNER JOIN auth_user on auth_user.id=ph.by_id {0} ORDER BY ph.date DESC LIMIT {1}".format(where, num)
curs = connection.cursor()
curs.execute(sql)