svn: /web/php-bugs/trunk/scripts/cron/ email-assigned

From: Date: Tue, 01 Jun 2010 17:05:18 +0000
Subject: svn: /web/php-bugs/trunk/scripts/cron/ email-assigned
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-8290@lists.php.net to get a copy of this message
philip Tue, 01 Jun 2010 17:05:18 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=300058 Log: Added script that emails people with assigned bugs. In 'test' mode currently. Will be added to weekly cron. Changed paths: A web/php-bugs/trunk/scripts/cron/email-assigned Added: web/php-bugs/trunk/scripts/cron/email-assigned =================================================================== --- web/php-bugs/trunk/scripts/cron/email-assigned (rev 0) +++ web/php-bugs/trunk/scripts/cron/email-assigned 2010-06-01 17:05:18 UTC (rev 300058) @@ -0,0 +1,81 @@ +#!/local/bin/php -q +<?php /* vim: set ft=phpbugdb noet ts=4 sw=4 : */ + +require __DIR__ . '/../../include/prepend.php'; + +// NOTE: We could adjust to email other combinations. Ex: assign is user 'foo', and status is 'Feedback' ... +$sql = "SELECT id, package_name, bug_type, sdesc, assign, UNIX_TIMESTAMP(ts1) AS ts_opened, UNIX_TIMESTAMP(ts2) AS ts_changed + FROM bugdb + WHERE length(assign) > 1 + AND status = 'Assigned' + ORDER BY id"; + +$res = $dbh->query($sql); + +if (PEAR::isError($res)) { + throw new Exception("SQL Error in email-assigned"); +} + +// Gather up the data +while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { + $data[$row['assign']][] = $row; +} + +$num_rows = $res->numRows(); +$num_users = count($data); + +foreach ($data as $assigned => $binfos) { + + $mbody = format_email_body($binfos); + $email_user = $assigned . '@php.net'; + + // TESTING + if ($assigned === 'philip') { + $mbody .= "Num Rows: $num_rows\nNum Users: $num_users\n"; + mail($email_user, 'Assigned PHP bugs reminder', $mbody, 'From: noreply@lists.php.net'); + exit; + } +} + +function format_email_body($binfos) { + + $links = ''; + $count = count($binfos); + $earliest_changed = time(); + $earliest_opened = time(); + + foreach ($binfos as $binfo) { + + if ($earliest_changed > $binfo['ts_changed']) { + $earliest_changed = $binfo['ts_changed']; + } + if ($earliest_opened > $binfo['ts_opened']) { + $earliest_opened = $binfo['ts_opened']; + } + + $link_title = strlen($binfo['sdesc']) < 42 ? $binfo['sdesc'] : substr($binfo['sdesc'], 0, 42) . '...'; + + $links .= " Title: $link_title\r\n"; + $links .= " Link: http://bugs.php.net/{$binfo['id']}\r\n\r\n"; + } + + $assigned = $binfo['assign']; + $salute = ($count === 1) ? 'one bug report' : "$count bug reports"; + $date_c = date('M d, Y', $earliest_changed); + $date_o = date('M d, Y', $earliest_opened); + + $body = <<<MAIL_BODY +Hello $assigned, + +This is a gentle reminder about the $salute assigned to you. + +Dates: + Earliest opened date: $date_o + Earliest last change date: $date_c + +Your assigned bug information: +$links +MAIL_BODY; + + return $body; +} Property changes on: web/php-bugs/trunk/scripts/cron/email-assigned ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native

« previous php.webmaster (#8290) next »