From: Joerg Jaspert Date: Sat, 13 Jun 2009 22:00:18 +0000 (+0200) Subject: process-new X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=0f93456a9271c40a332cd382ca6c2ac415022bb7;p=dak.git process-new (Hopefully) ignore trainee comments for the sorting within NEW. Signed-off-by: Joerg Jaspert --- diff --git a/dak/dakdb/update13.py b/dak/dakdb/update13.py new file mode 100755 index 00000000..d5dbedce --- /dev/null +++ b/dak/dakdb/update13.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# coding=utf8 + +""" +Adding a trainee field to the process-new notes + +@contact: Debian FTP Master +@copyright: 2009 Joerg Jaspert +@license: GNU General Public License version 2 or later +""" + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +################################################################################ + + +################################################################################ + +import psycopg2 +import time +from daklib.dak_exceptions import DBUpdateError + +################################################################################ + +def do_update(self): + print "Adding a trainee field to the process-new notes" + + try: + c = self.db.cursor() + c.execute("ALTER TABLE new_comments ADD COLUMN trainee BOOLEAN NOT NULL DEFAULT false") + + c.execute("UPDATE config SET value = '13' WHERE name = 'db_revision'") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, "Unable to apply process-new update 13, rollback issued. Error message : %s" % (str(msg)) diff --git a/dak/process_new.py b/dak/process_new.py index 3037b14a..6cbbccff 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -225,7 +225,7 @@ def sort_changes(changes_files): mtime = os.stat(d["filename"])[stat.ST_MTIME] if mtime < oldest: oldest = mtime - have_note += (database.has_new_comment(d["source"], d["version"])) + have_note += (database.has_new_comment(d["source"], d["version"], True)) per_source[source]["oldest"] = oldest if not have_note: per_source[source]["note_state"] = 0; # none @@ -496,7 +496,8 @@ def edit_note(note): elif answer == 'Q': end() sys.exit(0) - database.add_new_comment(Upload.pkg.changes["source"], Upload.pkg.changes["version"], newnote, utils.whoami()) + + database.add_new_comment(Upload.pkg.changes["source"], Upload.pkg.changes["version"], newnote, utils.whoami(), Options["Trainee"]) ################################################################################ @@ -766,7 +767,7 @@ def init(): try: Logger = Upload.Logger = logging.Logger(Cnf, "process-new") except CantOpenError, e: - Options["Trainee"] = "Oh yes" + Options["Trainee"] = True projectB = Upload.projectB diff --git a/dak/update_db.py b/dak/update_db.py index b559e544..5fe6918a 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -45,7 +45,7 @@ from daklib.dak_exceptions import DBUpdateError Cnf = None projectB = None -required_database_schema = 12 +required_database_schema = 13 ################################################################################ diff --git a/daklib/database.py b/daklib/database.py index fc8dd677..3d69cf19 100755 --- a/daklib/database.py +++ b/daklib/database.py @@ -864,9 +864,10 @@ def get_new_comments(package): return comments -def has_new_comment(package, version): +def has_new_comment(package, version, ignore_trainee=False): """ Returns true if the given combination of C{package}, C{version} has a comment. + If C{ignore_trainee} is true, comments from a trainee are ignored. @type package: string @param package: name of the package @@ -874,22 +875,30 @@ def has_new_comment(package, version): @type version: string @param version: package version + @type version: boolean + @param version: ignore trainee comments + @rtype: boolean @return: true/false """ + trainee="" + if ignore_trainee: + trainee='AND trainee=false' + exists = projectB.query("""SELECT 1 FROM new_comments WHERE package='%s' AND version='%s' + %s LIMIT 1""" - % (package, version) ).getresult() + % (package, version, trainee) ).getresult() if not exists: return False else: return True -def add_new_comment(package, version, comment, author): +def add_new_comment(package, version, comment, author, trainee=False): """ Add a new comment for C{package}, C{version} written by C{author} @@ -904,11 +913,14 @@ def add_new_comment(package, version, comment, author): @type author: string @param author: the authorname + + @type trainee: boolean + @param trainee: trainee comment """ - projectB.query(""" INSERT INTO new_comments (package, version, comment, author) - VALUES ('%s', '%s', '%s', '%s') - """ % (package, version, pg.escape_string(comment), pg.escape_string(author))) + projectB.query(""" INSERT INTO new_comments (package, version, comment, author, trainee) + VALUES ('%s', '%s', '%s', '%s', '%s') + """ % (package, version, pg.escape_string(comment), pg.escape_string(author), trainee)) return