2 helper functions for cruft-report
4 @contact: Debian FTPMaster <ftpmaster@debian.org>
5 @copyright 2011 Torsten Werner <twerner@debian.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ################################################################################
24 from daklib.dbconn import *
26 from sqlalchemy import func
28 def newer_version(lowersuite_name, highersuite_name, session):
30 Finds newer versions in lowersuite_name than in highersuite_name. Returns a
31 list of tuples (source, higherversion, lowerversion) where higherversion is
32 the newest version from highersuite_name and lowerversion is the newest
33 version from lowersuite_name.
36 lowersuite = get_suite(lowersuite_name, session)
37 highersuite = get_suite(highersuite_name, session)
39 query = session.query(DBSource.source, func.max(DBSource.version)). \
40 with_parent(highersuite).group_by(DBSource.source)
43 for (source, higherversion) in query:
44 lowerversion = session.query(func.max(DBSource.version)). \
45 filter_by(source = source).filter(DBSource.version > higherversion). \
46 with_parent(lowersuite).group_by(DBSource.source).scalar()
47 if lowerversion is not None:
48 list.append((source, higherversion, lowerversion))