Skip to content

Commit c5c1061

Browse files
committed
Make /patch/{id} the URL for a patch
Previously we'd include the ID of the commitfest in the URL of the patch. In 9f12a5e we introduced a stable URL for patches that would redirect to the one for the latest commitfest. This starts to use that URL as the valid only URL for a patch (with the previous URL redirecting to this one). The reasoning behind this is that the old approach resulted in N different URLs for each patch, which all showed the exact same patch information. The only difference between all these URLs would be the breadcrumb at the top of the page. The only benefit of that approach is that if you're on an old commitfest, and click a link there, then the breadcrumb will bring you back to where you came from. Since people rarely have a reason to browse closed commitfests, the that benefit seems pretty small. Especially because people can just as well press their browser back button, in that case. The problems that these N links cause seem much more impactful to most users: 1. If you click an old link to a cf entry (e.g. one in the email archives), then the breadcrumb will contain some arbitrarily old commitfest. It seems much more useful to have the breadcrumb show the commitfest that the patch is currently active in (or got committed/rejected in). 2. Places that use the stable URLs require an extra round-trip to actually get to the patch page. 3. It's a bit confusing that old pages of a patch still get updated with all the new information, i.e. why have all these pages if they contain the exact same content. 4. Problem 3 is generally also bad for Search Engine Optimization (SEO), for now we don't care much about that though. Finally this also changes the links on the patch page itself for each of the commitfests that a patch has been part of. Those links were already rather useless, since all they effectively did was change the breadcrumb. But with this new commit, they wouldn't even do that anymore, and simply redirect to the current page. So now they start pointing to the commitfest itself, which seems more useful behaviour anyway.
1 parent b697c34 commit c5c1061

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

pgcommitfest/commitfest/templates/commitfest.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
8484
{%endifchanged%}
8585
{%endif%}
8686
<tr>
87-
<td><a href="{{p.id}}/">{{p.name}}</a></td>
87+
<td><a href="/patch/{{p.id}}/">{{p.name}}</a></td>
8888
<td><span class="label label-{{p.status|patchstatuslabel}}">{{p.status|patchstatusstring}}</span></td>
8989
<td>{%if p.targetversion%}<span class="label label-default">{{p.targetversion}}</span>{%endif%}</td>
9090
<td class="cfbot-summary">

pgcommitfest/commitfest/templates/patch.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<tr>
6969
<th>Status</th>
7070
<td>{%for c in patch_commitfests %}
71-
<div style="margin-bottom: 3px;"><a href="/{{c.commitfest.id}}/{{patch.id}}/">{{c.commitfest}}</a>: <span class="label label-{{c.status|patchstatuslabel}}">{{c.statusstring}}</span></div>
71+
<div style="margin-bottom: 3px;"><a href="/{{c.commitfest.id}}/">{{c.commitfest}}</a>: <span class="label label-{{c.status|patchstatuslabel}}">{{c.statusstring}}</span></div>
7272
{%endfor%}
7373
</td>
7474
</tr>

pgcommitfest/commitfest/views.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,18 @@ def global_search(request):
316316
})
317317

318318

319-
def patch_redirect(request, patchid):
320-
last_commitfest = PatchOnCommitFest.objects.select_related('commitfest').filter(patch_id=patchid).order_by('-commitfest__startdate').first()
321-
if not last_commitfest:
322-
raise Http404("Patch not found")
323-
return HttpResponseRedirect(f'/{last_commitfest.commitfest_id}/{patchid}/')
319+
def patch_legacy_redirect(request, cfid, patchid):
320+
# Previously we would include the commitfest id in the URL. This is no
321+
# longer the case.
322+
return HttpResponseRedirect(f'/patch/{patchid}/')
324323

325324

326-
def patch(request, cfid, patchid):
327-
cf = get_object_or_404(CommitFest, pk=cfid)
328-
patch = get_object_or_404(Patch.objects.select_related(), pk=patchid, commitfests=cf)
329-
patch_commitfests = PatchOnCommitFest.objects.select_related('commitfest').filter(patch=patch).order_by('-commitfest__startdate')
325+
def patch(request, patchid):
326+
patch = get_object_or_404(Patch.objects.select_related(), pk=patchid)
327+
328+
patch_commitfests = PatchOnCommitFest.objects.select_related('commitfest').filter(patch=patch).order_by('-commitfest__startdate').all()
329+
cf = patch_commitfests[0].commitfest
330+
330331
committers = Committer.objects.filter(active=True).order_by('user__last_name', 'user__first_name')
331332

332333
cfbot_branch = getattr(patch, 'cfbot_branch', None)

pgcommitfest/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
re_path(r'^(\d+)/$', views.commitfest),
2020
re_path(r'^(open|inprogress|current)/(.*)$', views.redir),
2121
re_path(r'^(?P<cfid>\d+)/activity(?P<rss>\.rss)?/$', views.activity),
22-
re_path(r'^patch/(\d+)/$', views.patch_redirect),
23-
re_path(r'^(\d+)/(\d+)/$', views.patch),
22+
re_path(r'^patch/(\d+)/$', views.patch),
23+
re_path(r'^(\d+)/(\d+)/$', views.patch_legacy_redirect),
2424
re_path(r'^(\d+)/(\d+)/edit/$', views.patchform),
2525
re_path(r'^(\d+)/new/$', views.newpatch),
2626
re_path(r'^(\d+)/(\d+)/status/(review|author|committer)/$', views.status),

0 commit comments

Comments
 (0)