forked from adamm/git-importer
Split Revision into OBS and DB
This commit is contained in:
22
lib/db_revision.py
Normal file
22
lib/db_revision.py
Normal file
@@ -0,0 +1,22 @@
|
||||
class DBRevision:
|
||||
|
||||
def __init__(self, row):
|
||||
(self.dbid, self.project, self.package, self.rev, self.unexpanded_srcmd5, self.commit_time, self.userid, self.comment, self.requestid) = row
|
||||
|
||||
@classmethod
|
||||
def fetch_revision(cls, db, project, package, rev):
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT * FROM revisions where project=%s and package=%s and rev=%s", (project, package, rev))
|
||||
row = cur.fetchone()
|
||||
cur.close()
|
||||
return DBRevision(row)
|
||||
|
||||
@classmethod
|
||||
def latest_revision(cls, db, project, package):
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT MAX(rev) FROM revisions where project=%s and package=%s", (project, package))
|
||||
max = cur.fetchone()[0]
|
||||
cur.close()
|
||||
if max:
|
||||
return DBRevision.fetch_revision(db, project, package, int(max))
|
||||
return None
|
Reference in New Issue
Block a user