@@ -88,7 +88,13 @@ def help(request):
8888
8989
9090@login_required
91+ @transaction .atomic
9192def me (request ):
93+ curs = connection .cursor ()
94+ # Make sure the patchlist() query, the stats query and, Tag.objects.all()
95+ # all work on the same snapshot. Needs to be first in the
96+ # transaction.atomic decorator.
97+ curs .execute ("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ" )
9298 cfs = list (CommitFest .objects .filter (status = CommitFest .STATUS_INPROGRESS ))
9399 if len (cfs ) == 0 :
94100 cfs = list (CommitFest .objects .filter (status = CommitFest .STATUS_OPEN ))
@@ -108,7 +114,6 @@ def me(request):
108114 return patch_list .redirect
109115
110116 # Get stats related to user for current commitfest
111- curs = connection .cursor ()
112117 curs .execute (
113118 """SELECT
114119 ps.status, ps.statusstring, count(*)
@@ -290,8 +295,9 @@ def patchlist(request, cf, personalized=False):
290295 tag_ids = [int (t ) for t in request .GET .getlist ("tag" )]
291296 for tag_id in tag_ids :
292297 # Instead of using parameters, we just inline the tag_id. This
293- # is easier, and since tag_id is always an int it's safe with
294- # respect to SQL injection.
298+ # is easier because we have can have multiple tags, and since
299+ # tag_id is always an int it's safe with respect to SQL
300+ # injection.
295301 whereclauses .append (
296302 f"EXISTS (SELECT 1 FROM commitfest_patch_tags tags WHERE tags.patch_id=p.id AND tags.tag_id={ tag_id } )"
297303 )
@@ -569,8 +575,13 @@ def patchlist(request, cf, personalized=False):
569575 )
570576
571577
572- @transaction .atomic # tie the patchlist() query to Tag.objects.all()
578+ @transaction .atomic
573579def commitfest (request , cfid ):
580+ curs = connection .cursor ()
581+ # Make sure the patchlist() query, the stats query and, Tag.objects.all()
582+ # all work on the same snapshot. Needs to be first in the
583+ # transaction.atomic decorator.
584+ curs .execute ("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ" )
574585 # Find ourselves
575586 cf = get_object_or_404 (CommitFest , pk = cfid )
576587
@@ -579,7 +590,6 @@ def commitfest(request, cfid):
579590 return patch_list .redirect
580591
581592 # Generate patch status summary.
582- curs = connection .cursor ()
583593 curs .execute (
584594 "SELECT ps.status, ps.statusstring, count(*) FROM commitfest_patchoncommitfest poc INNER JOIN commitfest_patchstatus ps ON ps.status=poc.status WHERE commitfest_id=%(id)s GROUP BY ps.status ORDER BY ps.sortkey" ,
585595 {
0 commit comments