From 61cda5eaf5e301f1cee68183b878690041cf34d1 Mon Sep 17 00:00:00 2001 From: yibo <386083722@qq.com> Date: Tue, 11 Aug 2026 22:00:10 +0800 Subject: [PATCH] Bug: better display --- export.py | 120 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 20 deletions(-) diff --git a/export.py b/export.py index 492a7ade..e97961a3 100644 --- a/export.py +++ b/export.py @@ -1,16 +1,10 @@ import json -import argparse -import sqlite3 -import pandas as pd +from collections import Counter +from html import escape -conn = sqlite3.connect(':memory:') -c = conn.cursor() with open("data/bugs.json") as f: data = json.load(f) -df = pd.DataFrame(data) -df.to_sql('bugs', conn) - domain_map = { 'dbms' : 'Database Management Systems', 'datalog' : 'Datalog Engines', @@ -18,25 +12,111 @@ 'compiler&interpreter': 'Compilers and Interpreters' } -common_where_clause = "(resolution IN ('confirmed', 'fixed', 'open') OR resolution IS NULL)" -domain_count_query = 'SELECT domain, COUNT(*) FROM bugs WHERE ' + common_where_clause + ' GROUP BY domain ORDER BY COUNT(*) DESC;' +def is_included(entry): + return entry.get('resolution') in ('confirmed', 'fixed', 'open', None) + + +included_bugs = [entry for entry in data if is_included(entry)] +domain_counts = Counter(entry.get('domain') for entry in included_bugs) +ordered_domains = sorted(domain_counts.items(), key=lambda item: item[1], reverse=True) + print('Overview
') print('') +print(''' +
+ + +
+ +''') + print('
') -for domain, count in c.execute(domain_count_query).fetchall(): +for domain, count in ordered_domains: print('

%s (%d bugs)

' % (domain, domain_map[domain], count)) - for system, count in c.execute(("SELECT system, COUNT(*) FROM bugs WHERE domain = '%s' AND " + common_where_clause + " GROUP BY system ORDER BY COUNT(*) DESC") % (domain,)).fetchall(): - print('

%s (%d bugs)

' % (system, count)) - for title, url, found_by, resolution in c.execute(("SELECT title, url, reported_by, resolution FROM bugs WHERE domain='%s' AND system='%s' AND " + common_where_clause + ";") % (domain, system)).fetchall(): - print('
') - print('%s'% (title, )) + domain_bugs = [entry for entry in included_bugs if entry.get('domain') == domain] + system_counts = Counter(entry.get('system') for entry in domain_bugs) + ordered_systems = sorted(system_counts.items(), key=lambda item: item[1], reverse=True) + for system, count in ordered_systems: + print('
') + print('%s (%d bugs)' % (escape(system or 'Unknown database'), count)) + for entry in domain_bugs: + if entry.get('system') != system: + continue + title = entry.get('title') + url = entry.get('url') + found_by = entry.get('reported_by') + resolution = entry.get('resolution') + print('
') + print('%s' % escape(title or 'Untitled bug')) if resolution is None: resolution = 'unconfirmed' - print('Status: %s
' % (resolution, )) - print('Link: %s
' % (url, url)) - print('Found by: %s' % (found_by,)) + safe_url = escape(url or '', quote=True) + print('Status: %s
' % escape(resolution)) + print('Link: %s
' % (safe_url, escape(url or ''))) + print('Found by: %s' % escape(found_by or 'Unknown')) print('
') + print('
') + +print(''' +''')