We now keep all builds in the N most recent evaluations of a jobset, rather than the N most recent builds of every job. Note that this means that typically fewer builds will be kept (since jobs may be unchanged across evaluations).
I3X25POIIRIY47QTN2PA3WMDVROM6TLFJAV3Q5W6AU526TFPNHKAC
OX6NYJDVCDX2UCJ4QQMTRJVZ535NOMCJGYCHDLCADJPQI7RMCXPQC
ODNCGFQ5FPKFI624BVMLW7PJ2EFJOR3TY66OCZM42UNNTWBCF2TQC
6KJXJB7NZ5XJ3WGUWKFNT6LMBNYJN3IPHZ7B7H654D5B6LPOL5QAC
PMNWRTGJ4GVSMSSAWSUD57B26PCRAHMZIQ5SIWJIK7A74ENKEQLAC
WZ3AEJ67LOG5L335AAC2BDLIJPIU4VSCGBMATBHDZC26ECRS5A6AC
4X6NS66QDWR4S4ZZFKN2QOJQII5ZYIMTDYRHK25N6NJSROVLHJ6QC
KJQWSRCCQEKF64L4NYYZ7VKAF2YEPYXXTRW6BI464P6Q6KU34TQAC
YISCM3G35J5KHV6CQHX5GWH65W4J4BBWWNLXCGTYU6ZBQITNQ7AAC
IN272KZWHENW2TCR3LWQ6OZAEESJL5S7AEL3GYLJTWHJUDE6HADAC
XBU2ODSPGKXUPOV5CFKOBOJLCIU5BMMZ5YVWFR7CP2G5QQZ5GAJAC
keepBuild $_ foreach $jobset->builds->search(
{ 'me.id' => { 'in' => \
[ "select b2.id from Builds b2 join " .
" (select distinct job, system, coalesce( " .
" (select id from builds where project = b.project and jobset = b.jobset and job = b.job and system = b.system and finished = 1 and buildStatus = 0 order by id desc offset ? limit 1)" .
" , 0) as nth from builds b where project = ? and jobset = ? and isCurrent = 1) x " .
" on b2.project = ? and b2.jobset = ? and b2.job = x.job and b2.system = x.system and (id >= x.nth) where finished = 1 and buildStatus = 0"
, [ '', $keepnr - 1 ], [ '', $project->name ], [ '', $jobset->name ], [ '', $project->name ], [ '', $jobset->name ] ] }
},
{ order_by => ["job", "system", "id"], columns => [ @columns ] });
keepBuild $_ foreach $jobset->builds->search(
{ finished => 1, buildStatus => 0
, id => { -in =>
\ [ "select build from JobsetEvalMembers where eval in (select id from JobsetEvals where project = ? and jobset = ? and hasNewBuilds = 1 order by id desc limit ?)",
[ '', $project->name ], [ '', $jobset->name ], [ '', $keepnr ] ] }
},
{ order_by => ["job", "id"], columns => [ @columns ] });