From b46cbe320d6f769c74cbc3a959e376692c5c4465 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 8 Dec 2023 15:22:58 +0200 Subject: [PATCH 1/3] Fix AD queue graphs and AD doc list sorting. Fixes #6700 Fixes #6720 --- ietf/doc/views_search.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py index 6ba8abe1e00..71b55c164f3 100644 --- a/ietf/doc/views_search.py +++ b/ietf/doc/views_search.py @@ -368,9 +368,7 @@ def state_name(doc_type, state, shorten=True): def date_to_bucket(date, now, num_buckets): - return num_buckets - min( - num_buckets, int((now.date() - date.date()).total_seconds() / 60 / 60 / 24) - ) + return num_buckets - int((now.date() - date.date()).total_seconds() / 60 / 60 / 24) def ad_workload(request): @@ -460,13 +458,13 @@ def ad_workload(request): buckets_start = date_to_bucket(e.time, now, days) buckets_end = date_to_bucket(last, now, days) - if buckets_end >= days: + if buckets_start <= 0: # this event is older than we record in the history if last == now: # but since we didn't record any state yet, # this is the state the doc was in for the # entire history - for b in range(buckets_start, days): + for b in range(0, days): ad.buckets[dt][sn][b].append(doc.name) sums[dt][sn][b].append(doc.name) last = e.time @@ -510,8 +508,11 @@ def ad_workload(request): def docs_for_ad(request, name): def sort_key(doc): - key = list(AD_WORKLOAD.keys()).index(doc_type(doc)) - return key + dt = doc_type(doc) + dt_key = list(AD_WORKLOAD.keys()).index(dt) + ds = doc_state(doc) + ds_key = AD_WORKLOAD[dt].index(ds) if ds in AD_WORKLOAD[dt] else 99 + return dt_key * 100 + ds_key ad = None responsible = Document.objects.values_list("ad", flat=True).distinct() From 03b98bdc833f2f8fc941205b03001027487b713e Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 8 Dec 2023 16:46:56 +0200 Subject: [PATCH 2/3] Fix the issue @rdanyliw found. Hopefully. --- ietf/doc/views_search.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py index 71b55c164f3..9b374254558 100644 --- a/ietf/doc/views_search.py +++ b/ietf/doc/views_search.py @@ -364,6 +364,14 @@ def state_name(doc_type, state, shorten=True): for dt in AD_WORKLOAD } + +def state_to_doc_type(state): + for dt in STATE_SLUGS: + if state in STATE_SLUGS[dt]: + return dt + return None + + IESG_STATES = State.objects.filter(type="draft-iesg").values_list("name", flat=True) @@ -445,13 +453,16 @@ def ad_workload(request): elif to_state == "RFC Published": to_state = "RFC" + new_dt = state_to_doc_type(to_state) + if new_dt is not None: + dt = new_dt + if to_state not in STATE_SLUGS[dt].keys() or to_state == "Replaced": # change into a state the AD dashboard doesn't display if to_state in IESG_STATES or to_state == "Replaced": - # if it's an IESG state we don't display, we're done with this doc + # if it's an IESG state we don't display, record it's time last = e.time - break - # if it's not an IESG state, keep going with next event + # keep going with next event continue sn = STATE_SLUGS[dt][to_state] @@ -464,7 +475,7 @@ def ad_workload(request): # but since we didn't record any state yet, # this is the state the doc was in for the # entire history - for b in range(0, days): + for b in range(days): ad.buckets[dt][sn][b].append(doc.name) sums[dt][sn][b].append(doc.name) last = e.time From a772c8a4bd9db9d87f4de4501ed6eb23671c5cf6 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Mon, 11 Dec 2023 15:47:32 +0200 Subject: [PATCH 3/3] More fixes --- ietf/doc/views_search.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py index 9b374254558..10c063f6457 100644 --- a/ietf/doc/views_search.py +++ b/ietf/doc/views_search.py @@ -429,6 +429,7 @@ def ad_workload(request): to_state = state_name(dt, state, shorten=False) elif e.desc.endswith("has been replaced"): # stop tracking + last = e.time break if not to_state: @@ -453,9 +454,10 @@ def ad_workload(request): elif to_state == "RFC Published": to_state = "RFC" - new_dt = state_to_doc_type(to_state) - if new_dt is not None: - dt = new_dt + if dt == "rfc": + new_dt = state_to_doc_type(to_state) + if new_dt is not None and new_dt != dt: + dt = new_dt if to_state not in STATE_SLUGS[dt].keys() or to_state == "Replaced": # change into a state the AD dashboard doesn't display @@ -469,13 +471,13 @@ def ad_workload(request): buckets_start = date_to_bucket(e.time, now, days) buckets_end = date_to_bucket(last, now, days) + if dt == "charter" and to_state == "Approved" and buckets_start < 0: + # don't count old charter approvals + break + if buckets_start <= 0: - # this event is older than we record in the history - if last == now: - # but since we didn't record any state yet, - # this is the state the doc was in for the - # entire history - for b in range(days): + if buckets_end >= 0: + for b in range(0, buckets_end): ad.buckets[dt][sn][b].append(doc.name) sums[dt][sn][b].append(doc.name) last = e.time @@ -487,15 +489,6 @@ def ad_workload(request): sums[dt][sn][b].append(doc.name) last = e.time - if last == now: - s = state_name(dt, state, shorten=False) - if s in STATE_SLUGS[dt].keys(): - # we didn't have a single event for this doc, assume - # the current state applied throughput the history - for b in range(days): - ad.buckets[dt][state][b].append(doc.name) - sums[dt][state][b].append(doc.name) - metadata = [ { "type": (dt, doc_type_name(dt)),