diff options
author | 2009-12-29 21:48:55 +0000 | |
---|---|---|
committer | 2009-12-29 21:48:55 +0000 | |
commit | 2f3e3adb72b43cd0bbf74422592a8256e103cd63 (patch) | |
tree | 7a13a71e3d013de4bf83783399f5771a26b98812 /import.bugzilla.php | |
parent | import bugs (diff) | |
download | znurt-org-backend-2f3e3adb72b43cd0bbf74422592a8256e103cd63.tar.gz znurt-org-backend-2f3e3adb72b43cd0bbf74422592a8256e103cd63.tar.bz2 znurt-org-backend-2f3e3adb72b43cd0bbf74422592a8256e103cd63.zip |
Import all bugs
git-svn-id: file:///var/svn/portage@20 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
Diffstat (limited to 'import.bugzilla.php')
-rw-r--r-- | import.bugzilla.php | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/import.bugzilla.php b/import.bugzilla.php index 0a03c46..6c6300c 100644 --- a/import.bugzilla.php +++ b/import.bugzilla.php @@ -1,33 +1,65 @@ <? - $verbose = true; - $qa = true; - require_once 'header.php'; + require_once 'class.portage.tree.php'; - $url = "http://bugs.gentoo.org/buglist.cgi?bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&component=Ebuilds&email1=&email2=&emailtype1=exact&emailtype2=substring&field-1-0-0=bug_status&field-1-1-0=component&field-1-2-0=product&field-1-3-0=short_desc&field0-0-0=assigned_to&field0-1-0=assigned_to&field0-2-0=short_desc&keywords=&keywords_type=allwords&long_desc=&long_desc_type=allwordssubstr&product=Gentoo%20Linux&query_format=advanced&remaction=&short_desc=%2F&short_desc_type=allwordssubstr&status_whiteboard=&status_whiteboard_type=allwordssubstr&type-1-0-0=anyexact&type-1-1-0=anyexact&type-1-2-0=anyexact&type-1-3-0=allwordssubstr&type0-0-0=notequals&type0-1-0=notequals&type0-2-0=notsubstring&value-1-0-0=UNCONFIRMED%2CNEW%2CASSIGNED%2CREOPENED&value-1-1-0=Ebuilds&value-1-2-0=Gentoo%20Linux&value-1-3-0=%2F&value0-0-0=maintainer-wanted%40gentoo.org&value0-1-0=maintainer-needed%40gentoo.org&value0-2-0=new%20package&votes=&ctype=csv"; + $tree = new PortageTree(); + $table = 'category'; - $ch = curl_init($url); - $fp = fopen("/tmp/bugs.csv", "w"); + // Only run this one once a day + $sql = "SELECT MAX(idate) FROM package_bugs;"; + $max = $db->getOne($sql); - curl_setopt($ch, CURLOPT_FILE, $fp); - curl_setopt($ch, CURLOPT_HEADER, 0); + $import_bugzilla = false; - curl_exec($ch); - curl_close($ch); - fclose($fp); - + if(!is_null($max)) { + $max = strtotime($max); + if(time() - $max >= 86400) + $import_bugzilla = true; + } else { + $import_bugzilla = true; + } + + if($import_bugzilla) { - die; + if($verbose) { + shell::msg("importing bugs"); + } - $url = urlencode($url); + $arr_categories = $tree->getCategories(); + + foreach($arr_categories as $category_name) { + + if($verbose) + shell::msg($category_name); + + $url = "http://bugs.gentoo.org/buglist.cgi?bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&email1=&email2=&emailtype1=exact&emailtype2=substring&field-1-0-0=product&field-1-1-0=bug_status&field-1-2-0=short_desc&field0-0-0=assigned_to&field0-1-0=assigned_to&field0-2-0=short_desc&keywords=&keywords_type=allwords&long_desc=&long_desc_type=allwordssubstr&product=Gentoo%20Linux&query_format=advanced&remaction=&short_desc=$category_name%2F&short_desc_type=allwordssubstr&status_whiteboard=&status_whiteboard_type=allwordssubstr&type-1-0-0=anyexact&type-1-1-0=anyexact&type-1-2-0=allwordssubstr&type0-0-0=notequals&type0-1-0=notequals&type0-2-0=notsubstring&value-1-0-0=Gentoo%20Linux&value-1-1-0=UNCONFIRMED%2CNEW%2CASSIGNED%2CREOPENED&value-1-2-0=media-video%2F&value0-0-0=maintainer-wanted%40gentoo.org&value0-1-0=maintainer-needed%40gentoo.org&value0-2-0=new%20package&votes=&ctype=csv"; + + $ch = curl_init($url); + $fp = fopen("/tmp/bugs.csv", "w"); + + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_setopt($ch, CURLOPT_HEADER, 0); + + curl_exec($ch); + curl_close($ch); + fclose($fp); + + $sql = "COPY bugzilla FROM '/tmp/bugs.csv' DELIMITER ',' CSV HEADER;"; + $db->query($sql); + + } - $arr = file_get_contents($url); + // FIXME this query takes a while to run + $sql = "INSERT INTO package_bugs (bug, package, description, status) SELECT b.bug_id AS bug, p.id AS package, b.short_short_desc, 1 FROM package p INNER JOIN category c ON p.category = c.id INNER JOIN bugzilla b ON b.short_short_desc LIKE ('%' || c.name || '/' || p.name || '%');"; + $db->query($sql); - print_r($arr); + } else { - $sql = "INSERT INTO package_bugs (bug, package, description, status) select b.bug_id AS bug, p.id AS package, b.short_short_desc, 1 FROM package p INNER JOIN category c ON p.category = c.id INNER JOIN bugzilla b ON b.short_short_desc LIKE ('%' || c.name || '/' || p.name || '%');"; + if($verbose) + shell::msg("Not importing bugs"); + } ?>
\ No newline at end of file |