Add another table to store linked_revs
We need to create fake revisions when packages were touched that are linked themselves
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import functools
|
||||
import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from lib.binary import is_binary_or_large
|
||||
from lib.db import DB
|
||||
@@ -145,6 +146,36 @@ class Importer:
|
||||
dbrev.links_to(db, tprj, tpkg)
|
||||
db.conn.commit()
|
||||
|
||||
def find_linked_revs(self, db):
|
||||
cur = db.cursor()
|
||||
cur.execute(
|
||||
"""SELECT * from revisions WHERE id in (SELECT l.revision_id FROM links l
|
||||
LEFT JOIN linked_revs lrevs ON lrevs.revision_id=l.revision_id
|
||||
WHERE lrevs.id IS NULL) and broken is FALSE;"""
|
||||
)
|
||||
for row in cur.fetchall():
|
||||
rev = DBRevision(row)
|
||||
linked_rev = rev.linked_rev(db)
|
||||
if not linked_rev:
|
||||
logging.debug("No link", rev)
|
||||
continue
|
||||
cur.execute(
|
||||
"""INSERT INTO linked_revs (revision_id, linked_id)
|
||||
VALUES (%s,%s)""",
|
||||
(rev.dbid, linked_rev.dbid),
|
||||
)
|
||||
|
||||
def fetch_all_linked_packages(self, db, project, package):
|
||||
cur = db.cursor()
|
||||
cur.execute(
|
||||
"""SELECT DISTINCT l.project, l.package from links l JOIN revisions r
|
||||
on r.id=l.revision_id WHERE r.project=%s AND r.package=%s""",
|
||||
(project, package),
|
||||
)
|
||||
for row in cur.fetchall():
|
||||
(lproject, lpackage) = row
|
||||
self.update_db_package(db, lproject, lpackage)
|
||||
|
||||
def import_into_db(self):
|
||||
db = DB()
|
||||
for project, _, api_url in self.projects:
|
||||
@@ -169,9 +200,15 @@ class Importer:
|
||||
# TODO move into SELECT
|
||||
if rev.broken or rev.expanded_srcmd5:
|
||||
continue
|
||||
linked_rev = rev.linked_rev(db)
|
||||
with db.cursor() as cur:
|
||||
cur.execute(
|
||||
"""SELECT unexpanded_srcmd5 from revisions WHERE
|
||||
id=(SELECT linked_id FROM linked_revs WHERE revision_id=%s""",
|
||||
(rev.dbid,),
|
||||
)
|
||||
linked_rev = cur.fetchone()
|
||||
if linked_rev:
|
||||
linked_rev = linked_rev.unexpanded_srcmd5
|
||||
linked_rev = linked_rev[0]
|
||||
list = self.obs.list(
|
||||
project, self.package, rev.unexpanded_srcmd5, linked_rev
|
||||
)
|
||||
|
Reference in New Issue
Block a user