3 require_once('../include/test-results.php');
5 ignore_user_abort(true);
8 function process_latest_five_builds($db) {
9 $build_rows = $db->query_and_fetch_all('SELECT id, builder FROM builds
10 WHERE start_time IS NOT NULL AND is_processed = FALSE ORDER BY end_time DESC LIMIT 5');
14 foreach ($build_rows as $row) {
15 echo "Build {$row['id']} for builder {$row['builder']}:\n";
16 echo " Updating flakiness...";
19 $start_time = microtime(true);
20 update_flakiness_after_inserting_build($db, $row['id']);
21 $time = microtime(true) - $start_time;
24 echo " Generating JSONs...";
27 $start_time = microtime(true);
28 $generator = new ResultsJSONGenerator($db, $row['builder']);
29 $generator->generate('wrongexpectations');
30 $generator->generate('flaky');
31 $time = microtime(true) - $start_time;
36 $db->query_and_get_affected_rows('UPDATE builds SET is_processed = TRUE where id = $1', array($row['id']));
46 if (!$db->connect()) {
47 echo "Failed to connect to the database";
51 $wait = config('defaultBuildWaitInterval');
53 if (process_latest_five_builds($db))
54 $wait = max(1, $wait * 0.8);
57 echo "Sleeping $wait s...\n";