diff options
author | Sean Finney <seanius@debian.org> | 2008-06-26 01:55:58 +0200 |
---|---|---|
committer | Sean Finney <seanius@debian.org> | 2008-06-26 01:55:58 +0200 |
commit | bb37cf116269d5948d7f4d592557642696b5d9c7 (patch) | |
tree | 279809d4fd86e92043e5f8b70dbf2d502d902678 /patchtracker/DB.py | |
parent | d08d138655cce56e9e10c4afbc01ccf4eb55a69e (diff) | |
download | patch-tracker-bb37cf116269d5948d7f4d592557642696b5d9c7.tar.gz |
package search / versionless implementation
going to /packages/pkg now gives a table of contents with
the available versions for the package, or the results of
a widers search in the case of no exact matches
also removed a bunch of dead code from DB mostly
Diffstat (limited to 'patchtracker/DB.py')
-rw-r--r-- | patchtracker/DB.py | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/patchtracker/DB.py b/patchtracker/DB.py index 370d691..9324e97 100644 --- a/patchtracker/DB.py +++ b/patchtracker/DB.py @@ -66,13 +66,6 @@ class PatchTrackerDB: def setFactory(self, factory): self.db.row_factory = factory - def findSourcePackage(self, srcpkg): - q = "SELECT * FROM packages WHERE name=? AND version=?" - cursor = self.db.cursor() - cursor.execute(q, (srcpkg.name, srcpkg.version)) - s = cursor.fetchone() - return s - def saveSourcePackage(self, srcpkg): cursor = self.db.cursor() #print "creating new record for",srcpkg @@ -83,42 +76,31 @@ class PatchTrackerDB: srcpkg.version,srcpkg.diffgz_name,srcpkg.diffgz_size, srcpkg.diffgz_md5sum)) - def findSuite(self, suite): - q = "SELECT * FROM suites WHERE name = ?" + def saveSuite(self, suite): + q = "INSERT OR REPLACE INTO suites (id,name) \ + VALUES ((SELECT MAX(id)+1 FROM suites),?)" cursor = self.db.cursor() cursor.execute(q, (suite,)) - return cursor.fetchone() - def saveSuite(self, suite): - s = self.findSuite(suite) - if not s: - q = "INSERT INTO suites (id,name) \ - VALUES ((SELECT MAX(id)+1 FROM suites),?)" - cursor = self.db.cursor() - cursor.execute(q, (suite,)) - - def findComponent(self, component): - q = "SELECT * FROM components WHERE name = ?" + def saveComponent(self, component): + q = "INSERT OR REPLACE INTO components (id,name) \ + VALUES ((SELECT MAX(id)+1 FROM components),?)" cursor = self.db.cursor() cursor.execute(q, (component,)) - return cursor.fetchone() - def saveComponent(self, component): - c = self.findComponent(component) - if not c: - q = "INSERT INTO components (id,name) \ - VALUES ((SELECT MAX(id)+1 FROM components),?)" - cursor = self.db.cursor() - cursor.execute(q, (component,)) - - def findCollection(self, package="%"): + def findCollection(self, package="%", version=None): oldfactory = self.db.row_factory self.db.row_factory = srcpkg_collection_factory cursor = self.db.cursor() toc = SourceArchive.SourcePackageIndex() q = "SELECT * FROM packages AS p,package_rel_map AS m,suites AS s \ WHERE p.name LIKE ? AND p.id = m.package_id AND m.suite_id = s.id" - cursor.execute(q, (package,)) + qargs = (package,) + if version: + q += " AND p.version = ?" + qargs += (version,) + + cursor.execute(q, qargs) # use srcpkg_factory to fetch sourcepackages, once per suite for srcpkg,rest in cursor.fetchall(): toc.ins(srcpkg, rest["name"]) @@ -131,14 +113,6 @@ class PatchTrackerDB: def findMasterIndex(self): return self.findCollection(package="%") - def findSourcePackageRelation(self, srcpkg, suite): - q = "SELECT * FROM packages AS p,suites AS s,package_rel_map AS m \ - WHERE p.name=? AND s.name=? AND m.package_id=p.id \ - AND m.suite_id=s.id" - cursor = self.db.cursor() - cursor.execute(q, (srcpkg.name, suite)) - return cursor.fetchone() - def relateSourcePackage(self, name, version, suite, component): q = "INSERT OR REPLACE INTO package_rel_map \ (package_id,suite_id,component_id) \ |