This was clearly an error in the original part-2 of the diff, and specifically breaks when two projects have a jobset of the same name.
VGUFW62F2DVRDMISV7TFO4BWLXKJKINFDVMC52BPZGIF6MSSGJRAC
makeQueries('ForJobset', "and jobset_id = (select id from jobsets j where j.name = ?)");
makeQueries('ForJob', "and jobset_id = (select id from jobsets j where j.name = ?) and job = ?");
makeQueries('ForJobset', "and jobset_id = ?");
makeQueries('ForJob', "and jobset_id = ? and job = ?");