(Hopefully) ignore trainee comments for the sorting within NEW.
Signed-off-by: Joerg Jaspert <joerg@debian.org>
--- /dev/null
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Adding a trainee field to the process-new notes
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2009 Joerg Jaspert <joerg@debian.org>
+@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))
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
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"])
################################################################################
try:
Logger = Upload.Logger = logging.Logger(Cnf, "process-new")
except CantOpenError, e:
- Options["Trainee"] = "Oh yes"
+ Options["Trainee"] = True
projectB = Upload.projectB
Cnf = None
projectB = None
-required_database_schema = 12
+required_database_schema = 13
################################################################################
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
@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}
@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