Show actual bug state changes
This commit is contained in:
parent
0aaa90c27a
commit
a7fcae14b1
29
build.py
29
build.py
|
@ -64,19 +64,18 @@ def get_all_bugs() -> list[Bug]:
|
||||||
return all_bugs
|
return all_bugs
|
||||||
|
|
||||||
|
|
||||||
def parse_date(date_str: str | None) -> date | None:
|
def parse_date(date_str: str | None) -> datetime | None:
|
||||||
"""Parse a date string with timezone information."""
|
"""Parse a date string with timezone information."""
|
||||||
if date_str is None:
|
if date_str is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
fmt = "%Y-%m-%dT%H:%M:%SZ" if date_str.endswith("Z") else "%Y-%m-%dT%H:%M:%S%z"
|
fmt = "%Y-%m-%dT%H:%M:%SZ" if date_str.endswith("Z") else "%Y-%m-%dT%H:%M:%S%z"
|
||||||
return datetime.strptime(date_str, fmt).astimezone(pytz.utc).date()
|
return datetime.strptime(date_str, fmt).astimezone(pytz.utc)
|
||||||
|
|
||||||
|
|
||||||
def count_open_bugs(bug_reports: list[Bug]) -> list[tuple[str, int]]:
|
def count_open_bugs(bug_reports: list[Bug]) -> list[tuple[str, int]]:
|
||||||
"""Count the number of open bugs for each date based on a list of bug reports."""
|
"""Count the number of open bugs for each date based on a list of bug reports."""
|
||||||
open_dates: Counter[date] = Counter()
|
dates: list[tuple[datetime, int]] = []
|
||||||
close_dates: Counter[date] = Counter()
|
|
||||||
|
|
||||||
# Process each bug report
|
# Process each bug report
|
||||||
seen: set[int] = set()
|
seen: set[int] = set()
|
||||||
|
@ -86,25 +85,19 @@ def count_open_bugs(bug_reports: list[Bug]) -> list[tuple[str, int]]:
|
||||||
seen.add(report["id"])
|
seen.add(report["id"])
|
||||||
open_date = parse_date(report["created_at"])
|
open_date = parse_date(report["created_at"])
|
||||||
assert open_date
|
assert open_date
|
||||||
open_dates[open_date] += 1
|
dates.append((open_date, 1))
|
||||||
|
|
||||||
close_date = parse_date(report["closed_at"])
|
close_date = parse_date(report["closed_at"])
|
||||||
if close_date:
|
if close_date:
|
||||||
close_dates[close_date] += 1
|
dates.append((close_date, -1))
|
||||||
|
|
||||||
# Create a date range from the earliest open date to the latest close date
|
dates.sort()
|
||||||
start_date = min(open_dates.keys())
|
bug_count = 0
|
||||||
end_date = max(close_dates.keys(), default=start_date)
|
|
||||||
delta = end_date - start_date
|
|
||||||
|
|
||||||
# Count open bugs for each date
|
|
||||||
open_bug_count = 0
|
|
||||||
open_bugs_over_time = []
|
open_bugs_over_time = []
|
||||||
for i in range(delta.days + 1):
|
for dt, delta in dates:
|
||||||
current_date = start_date + timedelta(days=i)
|
bug_count += delta
|
||||||
open_bug_count += open_dates.get(current_date, 0)
|
iso_date = dt.isoformat()
|
||||||
open_bug_count -= close_dates.get(current_date, 0)
|
open_bugs_over_time.append((iso_date, bug_count))
|
||||||
open_bugs_over_time.append((current_date.isoformat(), open_bug_count))
|
|
||||||
|
|
||||||
return open_bugs_over_time
|
return open_bugs_over_time
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
type: 'time',
|
type: 'time',
|
||||||
time: {
|
time: {unit: 'month'}
|
||||||
parser: 'yyyy-MM-dd',
|
|
||||||
unit: 'month',
|
|
||||||
// displayFormats: {'month': 'MMM yyyy'}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
ticks: {
|
ticks: {
|
||||||
|
|
Loading…
Reference in a new issue