From b323cdd195f68a607533d2c2e8f7209744edb3dc Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Tue, 14 Jun 2016 21:45:02 +0200 Subject: reproducible debian: also decorate popular packages in per-issue pages Signed-off-by: Holger Levsen --- bin/reproducible_common.py | 20 ++++++++++++-------- bin/reproducible_html_notes.py | 29 ++++++++++++++++++++--------- 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 = '' + package + '' + 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 = '' + package + '' - finally: - html += get_trailing_icon(package, bugs) + '\n' + html = '' + package + '' \ + + 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 + '

\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 + '\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 + '\n' affected += tab*4 + '

\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" + tab + "\n" + tab*2 + "\n" \ @@ -410,14 +425,10 @@ def index_issues(issues, scorefuncs): for scorefunc in scorefuncs.values(): html += tab*4 + '' + str(scorefunc(issues_list)) + '\n' html += tab*4 + '\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 = [ '%s' % ( - '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 + '\n' -- cgit v1.2.3-54-g00ecf