Author: neronus-guest
Date: 2008-07-22 19:03:59 +0000 (Tue, 22 Jul 2008)
New Revision: 919

Added:
   udd/src/udd/bugs_gatherer.pl
Modified:
   udd/src/db_manager.py
   udd/src/setup-db.sql
   udd/src/test.yaml
Log:
Added tables for bugs.debian.org
Write script to import data from bugs.debian.org. Still incomplete


Modified: udd/src/db_manager.py
===================================================================
--- udd/src/db_manager.py       2008-07-21 17:08:45 UTC (rev 918)
+++ udd/src/db_manager.py       2008-07-22 19:03:59 UTC (rev 919)
@@ -6,7 +6,7 @@
 
 """This scripts sets up and deletes the tables of the database"""
 
-TABLES = ('sources', 'packages', 'popcon', 'migrations')
+TABLES = ('sources', 'packages', 'popcon', 'migrations', 'bugs', 
'bug_merged_with', 'bug_user_tags')
 VIEWS = ('popcon_average', 'popcon_max')
 
 def print_help():

Modified: udd/src/setup-db.sql
===================================================================
--- udd/src/setup-db.sql        2008-07-21 17:08:45 UTC (rev 918)
+++ udd/src/setup-db.sql        2008-07-22 19:03:59 UTC (rev 919)
@@ -24,6 +24,17 @@
 CREATE TABLE popcon
   (Name text, vote int, olde int, recent int, nofiles int, distribution text, 
UNIQUE (Name, distribution));
 
+CREATE TABLE bugs
+  (id int, package text, arrival timestamp, status text,
+     severity text, tags text, submitter text, owner text, title text,
+     last_modified timestamp, UNIQUE (id));
+
+CREATE TABLE bug_merged_with
+  (bug int, merged_with int);
+
+CREATE TABLE bug_user_tags
+  (bug_user text, tag text, bug_nr text);
+
 CREATE VIEW popcon_average AS
   SELECT sources.package, avg(vote) AS vote, avg(olde) AS old, avg(recent) AS 
recent, avg(nofiles) as nofiles
     FROM sources, popcon,

Modified: udd/src/test.yaml
===================================================================
--- udd/src/test.yaml   2008-07-21 17:08:45 UTC (rev 918)
+++ udd/src/test.yaml   2008-07-22 19:03:59 UTC (rev 919)
@@ -1,5 +1,5 @@
 general:
-  dbname: udd
+  dbname: udd-test
   types:
     sources: module udd.sources_gatherer
     packages: module udd.packages_gatherer

Added: udd/src/udd/bugs_gatherer.pl
===================================================================
--- udd/src/udd/bugs_gatherer.pl                                (rev 0)
+++ udd/src/udd/bugs_gatherer.pl        2008-07-22 19:03:59 UTC (rev 919)
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+# Last-Modified: <Tue Jul 22 18:44:19 2008>
+
+use strict;
+use warnings;
+
+use lib qw{/org/udd.debian.net/mirrors/bugs.debian.org/perl};
+
+use DBI;
+use YAML::Syck;
+
+use Debbugs::Bugs qw{get_bugs};
+use Debbugs::Status qw{readbug get_bug_status};
+
+use POSIX qw{strftime};
+
+$YAML::Syck::ImplicitTyping = 1;
+
+sub main {
+       if(@ARGV != 2) {
+               print STDERR "Usage: $0 <config> <source>";
+               exit 1;
+       }
+
+       my $config = LoadFile($ARGV[0]) or die "Could not load configuration: 
$!";
+       my $source = $ARGV[1];
+
+       my $dbname = $config->{general}->{dbname};
+       # Connection to DB
+       my $dbh = DBI->connect("dbi:Pg:dbname=$dbname");
+       # We want to commit the transaction as a hole at the end
+       $dbh->{AutoCommit} = 0;
+
+       $dbh->prepare("DELETE FROM bugs")->execute();
+
+       # Read all bugs
+       foreach my $bug_nr (get_bugs()) {
+               my %bug = %{readbug($bug_nr)};
+               # Construct insertion query
+               my $date = strftime("%Y-%m-%d %T", localtime($bug{date}));
+               my $log_modified = strftime("%Y-%m-%d %T", 
localtime($bug{log_modified}));
+               map { $bug{$_} = $dbh->quote($bug{$_}) } qw(subject originator 
owner);
+               my $query = "INSERT INTO bugs VALUES ($bug_nr, '$bug{package}', 
'$date', \
+                            NULL, '$bug{severity}', '$bug{keywords}', 
$bug{originator}, $bug{owner}, \
+                                        $bug{subject}, '$log_modified')";
+               # Execute insertion
+               my $sth = $dbh->prepare($query);
+               $sth->execute() or die $!;
+       }
+
+       $dbh->commit();
+}
+
+main();


_______________________________________________
Collab-qa-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/collab-qa-commits

Reply via email to