Skip to content

Commit 98016b2

Browse files
committed
Allow sorting commitfest entries by "failing since"
1 parent b914d0c commit 98016b2

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.2.19 on 2025-03-01 13:53
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("commitfest", "0009_extra_branch_fields"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="cfbotbranch",
14+
name="failing_since",
15+
field=models.DateTimeField(blank=True, null=True),
16+
),
17+
]

pgcommitfest/commitfest/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ class CfbotBranch(models.Model):
469469
# Actually a postgres enum column
470470
status = models.TextField(choices=STATUS_CHOICES, null=False)
471471
needs_rebase_since = models.DateTimeField(null=True, blank=True)
472+
failing_since = models.DateTimeField(null=True, blank=True)
472473
created = models.DateTimeField(auto_now_add=True)
473474
modified = models.DateTimeField(auto_now=True)
474475
version = models.TextField(null=True, blank=True)

pgcommitfest/commitfest/templates/commitfest.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
6464
<th><a href="#" style="color:#333333;" onclick="return sortpatches(4);">ID</a>{%if sortkey == 4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -4%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
6565
<th>Status</th>
6666
<th>Ver</th>
67-
<th>CI status</th>
67+
<th><a href="#" style="color:#333333;" onclick="return sortpatches(7);">CI status</a>{%if sortkey == 7%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -7%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
6868
<th><a href="#" style="color:#333333;" onclick="return sortpatches(6);">Stats</a>{%if sortkey == 6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%elif sortkey == -6%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-up"></i></div>{%endif%}</th>
6969
<th>Author</th>
7070
<th>Reviewers</th>

pgcommitfest/commitfest/views.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 DESC NULLS FIRST, branch.created DESC"
270+
elif sortkey == -7:
271+
orderby_str = "branch.failing_since NULLS LAST, branch.created"
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
12751302
def cfbot_notify(request):

0 commit comments

Comments
 (0)