All pastes #2083143 Raw Edit

srweb update stats script

public php v1 · immutable
#2083143 ·published 2011-09-26 19:54 UTC
rendered paste body
<?php$hash_srobo = '/home/srobo/hash-srobo';$revs = file('update-revs', FILE_IGNORE_NEW_LINES);// ignore the first few revs that are testing etc.$revs = array_slice($revs, 10);// 30 mins$delay = 30 * 60;$self_updates = $quick_self_updates = $quick_updates = 0;$delays = array();function self_update($committer, $updater) {    $people = array(REDACTED); // map of sr username => git user name    if (!isset($people[$updater]))    {	print "\n\n\nUknonwn updater: $updater; Committer $committer\n\n\n\n";	return false;    }    return $people[$updater] == $committer;}foreach ($revs as $rev){    $commit_line = trim(`git log -1 --format='%ad|%an' $rev`);    list($commit_date, $commit_who) = explode('|', $commit_line);    $commit_date = substr($commit_date, 0, -6);    $update_line = trim(`grep -E "srbot.*Live.*updated.*to.*$rev" $hash_srobo`);    $update_date = substr($update_line, 1, 19);    $update_who = substr(array_pop(explode(' ', $update_line)), 2);    $commit_time = strtotime($commit_date);    $udpate_time = strtotime($update_date);    $self_update = self_update($commit_who, $update_who);    if ($self_update) { $self_updates++; }    if ($commit_time + $delay >= $udpate_time)    {	$actual_delay = ($udpate_time - $commit_time) / 60;	echo "Commit: $rev; Author: $commit_who on $commit_date; Updated: $update_who at $update_date; Delay: ";	echo intval($actual_delay), " minute(s)\n";	if ($delay > 0) { $delays[] = $actual_delay; }	$quick_updates++;	if ($self_update)	{	    $quick_self_updates++;	}    }}echo "Total updates: ", count($revs), PHP_EOL;echo "Average update delay: ", array_sum($delays) / count($delays), PHP_EOL;echo "Quick updates: $quick_updates\n";echo "Self updates: $self_updates\n";echo "Quick Self updates: $quick_self_updates\n";