summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/reproducible_common.py20
-rwxr-xr-xbin/reproducible_html_notes.py29
2 files changed, 32 insertions, 17 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index 661a81cd..3b42cabe 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -459,29 +459,33 @@ def package_has_notes(package):
return False
-def link_package(package, suite, arch, bugs={}):
+def link_package(package, suite, arch, bugs={}, popcon=None, is_popular=None):
url = RB_PKG_URI + '/' + suite + '/' + arch + '/' + package + '.html'
query = 'SELECT n.issues, n.bugs, n.comments ' + \
'FROM notes AS n JOIN sources AS s ON s.id=n.package_id ' + \
'WHERE s.name="{pkg}" AND s.suite="{suite}" ' + \
'AND s.architecture="{arch}"'
+ css_classes = []
+ if is_popular:
+ css_classes += ["package-popular"]
+ title = ''
+ if popcon is not None:
+ title += 'popcon score: ' + str(popcon) + '\n'
try:
notes = query_db(query.format(pkg=package, suite=suite, arch=arch))[0]
except IndexError: # no notes for this package
- html = '<a href="' + url + '" class="package">' + package + '</a>'
+ css_classes += ["package"]
else:
- title = ''
+ css_classes += ["noted"]
for issue in json.loads(notes[0]):
title += issue + '\n'
for bug in json.loads(notes[1]):
title += '#' + str(bug) + '\n'
if notes[2]:
title += notes[2]
- title = HTML.escape(title.strip())
- html = '<a href="' + url + '" class="noted" title="' + title + \
- '">' + package + '</a>'
- finally:
- html += get_trailing_icon(package, bugs) + '\n'
+ html = '<a href="' + url + '" class="' + ' '.join(css_classes) \
+ + '" title="' + HTML.escape(title.strip()) + '">' + package + '</a>' \
+ + get_trailing_icon(package, bugs) + '\n'
return html
diff --git a/bin/reproducible_html_notes.py b/bin/reproducible_html_notes.py
index 3b048678..11bcc0ff 100755
--- a/bin/reproducible_html_notes.py
+++ b/bin/reproducible_html_notes.py
@@ -276,7 +276,8 @@ def gen_html_issue(issue, suite):
try:
arch = 'amd64'
for status in ['unreproducible', 'FTBFS', 'not for us', 'blacklisted', 'reproducible', 'depwait']:
- pkgs = [x[0] for x in all_pkgs if x[1] == status and x[2] == suite and x[3] == arch and x[0] in issues_count[issue]]
+ pkgs = [x[0] for x in all_pkgs
+ if x[1] == status and x[2] == suite and x[3] == arch and x[0] in issues_count[issue]]
if not pkgs:
continue
affected += tab*4 + '<p>\n'
@@ -284,8 +285,9 @@ def gen_html_issue(issue, suite):
affected += ' alt="' + status + ' icon" />\n'
affected += tab*5 + str(len(pkgs)) + ' ' + status + ' packages in ' + suite + '/' + arch +':\n'
affected += tab*5 + '<code>\n'
- for pkg in sorted(pkgs, key=lambda x: x in bugs):
- affected += tab*6 + link_package(pkg, suite, arch, bugs)
+ pkgs_popcon = issues_popcon_annotate(pkgs)
+ for pkg, popcon, is_popular in sorted(pkgs_popcon, key=lambda x: x[0] in bugs):
+ affected += tab*6 + link_package(pkg, suite, arch, bugs, popcon, is_popular)
affected += tab*5 + '</code>\n'
affected += tab*4 + '</p>\n'
except KeyError: # The note is not listed in any package, that is
@@ -387,12 +389,25 @@ def iterate_over_issues(issues):
log.info('Created ' + str(i) + ' issue pages for ' + suite)
+def issues_popcon_annotate(issues_list):
+ # outputs [(package, popcon, is_popular)] where is_popular True if it's
+ # in the upper 1/4 of issues_list, i.e. a relative measure
+ n = len(issues_list)
+ popcon_dict = dict((p, 0) for p in issues_list)
+ popcon_dict.update(popcon.package(*issues_list))
+ issues = sorted(popcon_dict.items(), key=lambda p: p[0])
+ issues_by_popcon = sorted(issues, key=lambda p: p[1], reverse=True)
+ issues_with_popcon = [(p[0], p[1], i<n/4) for i, p in enumerate(issues_by_popcon)]
+ return sorted(issues_with_popcon, key=lambda p: p[0])
+
+
def sort_issues(scorefunc, issue):
try:
return (-scorefunc(issues_count[issue]), issue)
except KeyError: # there are no packages affected by this issue
return (0, issue)
+
def index_issues(issues, scorefuncs):
firstscorefunc = next(iter(scorefuncs.values()))
templ = "\n<table class=\"body\">\n" + tab + "<tr>\n" + tab*2 + "<th>\n" \
@@ -410,14 +425,10 @@ def index_issues(issues, scorefuncs):
for scorefunc in scorefuncs.values():
html += tab*4 + '<td><b>' + str(scorefunc(issues_list)) + '</b></td>\n'
html += tab*4 + '<td>\n'
- popcon_dict = dict((p, 0) for p in issues_list)
- popcon_dict.update(popcon.package(*issues_list))
- issues_with_popcon = sorted(popcon_dict.items(), key=lambda p: p[0])
- issues_by_popcon = sorted(issues_with_popcon, key=lambda p: p[1], reverse=True)
- popular_packages = set([p[0] for p in issues_by_popcon[:int(len(issues_by_popcon)/4)]])
+ issues_with_popcon = issues_popcon_annotate(issues_list)
issue_strings = [
'<span %stitle="popcon score: %s">%s</span>' % (
- 'class="package-popular" ' if p[0] in popular_packages else '', p[1], p[0]
+ 'class="package-popular" ' if p[2] else '', p[1], p[0]
) for p in issues_with_popcon]
html += tab*5 + ', '.join(issue_strings) + '\n'
html += tab*4 + '</td>\n'