@@ -265,6 +265,10 @@ def commitfest(request, cfid):
265265 )
266266 elif sortkey == - 6 :
267267 orderby_str = "branch.all_additions + branch.all_deletions DESC NULLS LAST, created DESC"
268+ elif sortkey == 7 :
269+ orderby_str = "branch.failing_since NULLS FIRST, branch.created"
270+ elif sortkey == - 7 :
271+ orderby_str = "branch.failing_since DESC NULLS LAST, branch.created DESC"
268272 else :
269273 orderby_str = "p.id"
270274 sortkey = 0
@@ -1250,13 +1254,14 @@ def cfbot_ingest(message):
12501254 # CONFLICT does not allow us to return that). We need to know the previous
12511255 # state so we can skip sending notifications if the needs_rebase status did
12521256 # not change.
1257+ needs_save = False
12531258 needs_rebase = branch_status ["commit_id" ] is None
12541259 if bool (branch_in_db .needs_rebase_since ) is not needs_rebase :
12551260 if needs_rebase :
12561261 branch_in_db .needs_rebase_since = datetime .now ()
12571262 else :
12581263 branch_in_db .needs_rebase_since = None
1259- branch_in_db . save ()
1264+ needs_save = True
12601265
12611266 if needs_rebase :
12621267 PatchHistory (
@@ -1270,6 +1275,28 @@ def cfbot_ingest(message):
12701275 what = "Patch does not need rebase anymore" ,
12711276 ).save_and_notify (authors_only = True )
12721277
1278+ # Similarly, we change the failing_since field using a separate UPDATE
1279+ failing = branch_status ["status" ] in ("failed" , "timeout" ) or needs_rebase
1280+ finished = branch_status ["status" ] == "finished"
1281+
1282+ if "task_status" in message and message ["task_status" ]["status" ] in (
1283+ "ABORTED" ,
1284+ "ERRORED" ,
1285+ "FAILED" ,
1286+ ):
1287+ failing = True
1288+
1289+ if (failing or finished ) and bool (branch_in_db .failing_since ) is not failing :
1290+ print (branch_in_db .failing_since , failing )
1291+ if failing :
1292+ branch_in_db .failing_since = datetime .now ()
1293+ else :
1294+ branch_in_db .failing_since = None
1295+ needs_save = True
1296+
1297+ if needs_save :
1298+ branch_in_db .save ()
1299+
12731300
12741301@csrf_exempt
12751302def cfbot_notify (request ):
0 commit comments