Skip to content

Commit 71e7724

Browse files
committed
Add new report for orphan required packages
This dashboard lists packages which are orphan but required by other packages and should get a maintainer.
1 parent 9bc4816 commit 71e7724

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

devel/reports.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections import defaultdict
12
from datetime import timedelta
23

34
import pytz
@@ -173,6 +174,34 @@ def non_reproducible_packages(packages):
173174
return packages.filter(pkgname__in=statuses)
174175

175176

177+
def orphan_dependencies(packages):
178+
packages_with_orphan_deps = []
179+
required_mapping = defaultdict(list)
180+
181+
cursor = connection.cursor()
182+
query = """
183+
SELECT DISTINCT pp.pkgbase, ppr.user_id, child.pkgname
184+
FROM packages_depend ppd JOIN packages pp ON ppd.pkg_id = pp.id
185+
JOIN packages_packagerelation ppr ON pp.pkgbase = ppr.pkgbase
186+
JOIN (SELECT DISTINCT cp.pkgname FROM packages cp LEFT JOIN packages_packagerelation pr ON cp.pkgbase = pr.pkgbase WHERE pr.id IS NULL) child ON ppd.name = child.pkgname
187+
ORDER BY child.pkgname;
188+
"""
189+
cursor.execute(query)
190+
191+
for row in cursor.fetchall():
192+
pkgname, _, orphan = row
193+
required_mapping[pkgname].append(orphan)
194+
packages_with_orphan_deps.append(pkgname)
195+
196+
pkgs = packages.filter(pkgname__in=packages_with_orphan_deps)
197+
198+
for pkg in pkgs:
199+
# Templates take a string
200+
pkg.orphandeps = ' '.join(required_mapping.get(pkg.pkgname, []))
201+
202+
return pkgs
203+
204+
176205
REPORT_OLD = DeveloperReport(
177206
'old', 'Old', 'Packages last built more than two years ago', old)
178207

@@ -233,6 +262,14 @@ def non_reproducible_packages(packages):
233262
'Packages that are not reproducible on our reproducible.archlinux.org test environment',
234263
non_reproducible_packages)
235264

265+
REPORT_REQUIRED_ORPHAN = DeveloperReport(
266+
'required-orphan',
267+
'Required orphan packages',
268+
'Packages with orphan dependencies',
269+
orphan_dependencies,
270+
['Orphan dependencies'],
271+
['orphandeps'])
272+
236273

237274
def available_reports():
238275
return (REPORT_OLD,
@@ -242,6 +279,7 @@ def available_reports():
242279
REPORT_MAN,
243280
REPORT_INFO,
244281
REPORT_ORPHANS,
282+
REPORT_REQUIRED_ORPHAN,
245283
REPORT_SIGNATURE,
246284
REPORT_SIG_TIME,
247285
NON_EXISTING_DEPENDENCIES,

0 commit comments

Comments
 (0)