svn: /pear2/BugManager/trunk/data/ port_pearweb_to_bugmanager.php

From: Date: Sun, 19 Sep 2010 06:30:26 +0000
Subject: svn: /pear2/BugManager/trunk/data/ port_pearweb_to_bugmanager.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9679@lists.php.net to get a copy of this message
cellog Sun, 19 Sep 2010 06:30:26 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=303544 Log: refine database migration script so that patches are linked to their comments, and for old bugs, new comments are created that can be linked to the patch. Also, fix the percentage indicators to work for odd-numbers of things Changed paths: U pear2/BugManager/trunk/data/port_pearweb_to_bugmanager.php Modified: pear2/BugManager/trunk/data/port_pearweb_to_bugmanager.php =================================================================== --- pear2/BugManager/trunk/data/port_pearweb_to_bugmanager.php 2010-09-19 05:55:01 UTC (rev 303543) +++ pear2/BugManager/trunk/data/port_pearweb_to_bugmanager.php 2010-09-19 06:30:26 UTC (rev 303544) @@ -3,6 +3,14 @@ die("mysqli extension required"); } $mysqli = new Mysqli("localhost", "pear", "pear", "pear"); +$mysqli->query(' +DELETE FROM bugmanager_issues; +DELETE FROM bugmanager_comments; +DELETE FROM bugmanager_obsoletes_patches; +DELETE FROM bugmanager_patchtracker; +DELETE FROM bugmanager_roadmap; +DELETE FROM bugmanager_roadmap_link; + '); $a = function ($values) use ($mysqli) { @@ -58,7 +66,8 @@ return $ret; }; -$e = function ($values) use ($mysqli) +$bugcomment = 102000; +$e = function ($values) use ($mysqli, $bugcomment) { $ret = ''; foreach (array('bugdb_id', 'patch', 'revision') as $field) { @@ -68,10 +77,34 @@ } $ret .= '"' . $mysqli->real_escape_string($values[$field]) . '",'; } - $inf = $mysqli->query("SELECT id FROM bugdb_comments WHERE bug=" . $values['bugdb_id'] . ' ORDER BY + // first find a comment that + $inf = $mysqli->query("SELECT id FROM bugdb_comments WHERE bug=" . $values['bugdb_id'] . ' + AND handle="' . $values['developer'] . '" AND comment LIKE "Added #patch bug:' . + $values['bugdb_id'] . ';patch:' . $values['patch'] . ';revision:' . + $values['revision'] . ';.%" ORDER BY ts DESC'); - $info = $inf->fetch_assoc(); - $ret .= $info['id'] . ','; // use an arbitrary comment id + if ($inf->num_rows) { + $info = $inf->fetch_assoc(); + } else { + $inf = $mysqli->query("SELECT id FROM bugdb_comments WHERE bug=" . $values['bugdb_id'] . ' + AND handle="' . $values['developer'] . '" ORDER BY + ts DESC'); + if (!$inf->num_rows) { + $inf->free_result(); + $bug = $mysqli->query("SELECT * FROM users WHERE handle='" . $values['developer'] . "'"); + $bugi = $bug->fetch_assoc(); + $bug->free_result(); + $mysqli->query($sql = 'INSERT INTO bugmanager_comments (id, bug_id, email, handle, reporter_name, ts, comment, + recordversion) VALUES(' . $bugcomment++ . ',' . $values['bugdb_id'] . ',"' . $bugi['email'] . + '","' . $bugi['handle'] . '","' . $bugi['name'] . '","' . $values['revision'] . '","Added #patch bug:' . $values['bugdb_id'] . + ';patch:' . $values['patch'] . ';revision:' . $values['revision'] . ';.","1.0")'); + $info = array('id' => $bugcomment - 1); + } else { + $info = $inf->fetch_assoc(); + } + } + + $ret .= $info['id'] . ','; // use a comment that the patch developer made return $ret; }; @@ -81,16 +114,16 @@ $total = $res->num_rows; $i = 0; $milestones = array( - .1 * $total, - .2 * $total, - .3 * $total, - .4 * $total, - .5 * $total, - .6 * $total, - .7 * $total, - .8 * $total, - .9 * $total, - $total + 1 + round(.1 * $total), + round(.2 * $total), + round(.3 * $total), + round(.4 * $total), + round(.5 * $total), + round(.6 * $total), + round(.7 * $total), + round(.8 * $total), + round(.9 * $total), + $total ); $j = 1; while ($row = $res->fetch_assoc()) { @@ -120,16 +153,16 @@ $total = $res->num_rows; $i = 0; $milestones = array( - .1 * $total, - .2 * $total, - .3 * $total, - .4 * $total, - .5 * $total, - .6 * $total, - .7 * $total, - .8 * $total, - .9 * $total, - $total + 1 + round(.1 * $total), + round(.2 * $total), + round(.3 * $total), + round(.4 * $total), + round(.5 * $total), + round(.6 * $total), + round(.7 * $total), + round(.8 * $total), + round(.9 * $total), + $total ); $j = 1; while ($row = $res->fetch_assoc()) { @@ -141,6 +174,7 @@ echo ($j++ * 10), "%..."; } } +echo "\n"; $query = "SELECT * FROM bugdb_roadmap_link"; $res = $mysqli->query($query);

« previous php.pear.core (#9679) next »