- filters
- Use KST receipts in [2025-04-01 00:00, 2025-07-01 00:00). Convert offset-aware timestamps to the same timezone before cohorting and timing.
- Remove duplicate_of records for response compliance. Count recorded responses and overdue unanswered as eligible. Keep still-within-target unanswered tickets outside the denominator.
- For resolution, include tickets with a first resolved event. Subtract each interval starting with waiting_customer and ending at the next event, up to first resolution.
- exclusions
- scope
- First-response SLA and response charts
- source_refs
- tickets.jsonl lines 161, 278, 328, 342, 533, 538, 547, 572, 607, 624, 762, 765, 866, 916, 920
- reason
- 15 tickets linked to originals through duplicate_of. The original tickets are evaluated under the same first-response rules.
- scope
- First-response SLA and response charts
- source_refs
- tickets.jsonl lines 1434, 1457, 1459, 1470, 1475, 1478, 1482–1484, 1491, 1493–1500
- reason
- 18 unanswered original tickets whose first-response deadlines remained open at quarter-end.
- scope
- Recorded first-response chart
- source_refs
- tickets.jsonl lines 18, 52, 68, 84, 113, 120, 157, 198, 229, 266, 269, 323, 388, 392, 401, 457, 528, 536–537, 564–565, 578, 606, 650, 674, 706, 718, 750–751, 784, 827, 849, 857, 945, 995, 1025, 1048, 1067, 1108, 1140, 1152, 1192, 1202, 1228, 1233, 1235, 1263, 1282, 1299, 1338, 1382, 1490
- reason
- 52 eligible overdue tickets have no observed first-response duration. They contribute to the compliance denominator as misses.
- scope
- Resolution metrics and charts
- source_refs
- tickets.jsonl lines 9, 14, 18, 51–52, 68, 75, 84, 86, 96, 113, 120–121, 149, 154, 157, 173, 198, 203, 225, 229, 241, 266, 269, 272, 282, 319, 323–324, 331, 342, 388, 390, 392, 394, 401, 417, 455, 457, 471, 494, 496, 528, 532, 536–537, 555, 564–565, 578–579, 606, 609, 650, 661, 674, 684, 694–695, 706, 718, 728, 750–751, 765, 771, 777, 781, 784, 798, 804, 827, 849, 857, 861, 874, 903, 927, 945, 995, 1003, 1008, 1025, 1030, 1047–1048, 1067, 1092, 1094, 1099, 1108, 1116, 1140, 1151–1152, 1192, 1202, 1228, 1233, 1235, 1255, 1263, 1282, 1299, 1322, 1338, 1382, 1386, 1418, 1433–1434, 1444, 1454, 1457, 1459, 1462–1468, 1470–1472, 1475–1476, 1478–1480, 1482–1485, 1488–1500
- reason
- 147 tickets have no first resolved event by quarter-end.
- transforms
- input
- tickets.jsonl
- transform
- Decode one JSON object per line and retain original line numbers
- output
- Q2 receipts
- before
- 1500
- after
- 1500
- input
- Q2 receipts
- transform
- Exclude duplicate_of links from the first-response population
- output
- Original tickets
- before
- 1500
- after
- 1485
- input
- Original tickets
- transform
- Determine eligibility at quarter-end
- output
- First-response SLA cohort
- before
- 1485
- after
- 1467
- input
- First-response SLA cohort
- transform
- Select recorded first responses for raw chart
- output
- Observed first responses
- before
- 1467
- after
- 1415
- input
- First-response SLA cohort
- transform
- Pool counts by KST receipt month
- output
- Monthly values
- before
- 1467
- after
- 3
- input
- Q2 receipts
- transform
- Select and time first resolution
- output
- First resolutions
- before
- 1500
- after
- 1353
- input
- First resolutions
- transform
- Emit New, Assigned and Waiting for customer hours per ticket
- output
- Status-duration values
- before
- 1353
- after
- 4059
- sample_sizes
- Q2 receipts
- 1500
- first-response SLA
- 1467
- recorded first responses
- 1415
- first resolutions
- 1353
- status durations
- 4059
- source_locators
- tickets.jsonl lines 1–1500
- tickets.jsonl line 18 (overdue unanswered)
- tickets.jsonl line 1500 (pending)
- tickets.jsonl line 15 (reopened after first resolution)
- tickets.jsonl line 2, $.events[2:4] (one customer-wait interval)
- tickets.jsonl line 897 (longest adjusted time)
Code
# Run from eda-work with python3 -I analyze.py
import json
from collections import Counter
from pathlib import Path
import pandas as pd
SOURCE = Path("../tickets.jsonl")
ZONE = "Asia/Seoul"
START = pd.Timestamp("2025-04-01", tz=ZONE)
CUTOFF = pd.Timestamp("2025-07-01", tz=ZONE)
HOLIDAYS = {"2025-05-05", "2025-06-06"}
TARGET = {"P1": 60, "P2": 240, "P3": 480, "P4": 1440}
lines = SOURCE.read_text(encoding="utf-8").splitlines()
records = [json.loads(line) for line in lines]
d = pd.DataFrame(records, index=pd.Index(range(1, len(records) + 1), name="source_line"))
parse_failures = {}
for col in ["created_at", "first_response_at", "resolved_at"]:
parsed = pd.to_datetime(d[col], utc=True, errors="coerce").dt.tz_convert(ZONE)
parse_failures[col] = int((parsed.isna() & d[col].notna()).sum())
d[col] = parsed
assert not any(parse_failures.values())
duplicate = d.duplicate_of.notna()
assert d.ticket_id.is_unique and d.ticket_id.notna().all()
assert d.loc[duplicate, "duplicate_of"].isin(d.loc[~duplicate, "ticket_id"]).all()
assert (d.created_at.ge(START) & d.created_at.lt(CUTOFF)).all()
# Build business intervals in KST and intersect them with each response clock.
days = pd.date_range(START, CUTOFF, freq="B", inclusive="left")
windows = [
(day + pd.Timedelta(hours=9), day + pd.Timedelta(hours=18))
for day in days if day.strftime("%Y-%m-%d") not in HOLIDAYS
]
def business_minutes(start, stop):
return sum(max(0, (min(stop, end) - max(start, begin)).total_seconds()) / 60
for begin, end in windows if start < end and stop > begin)
responded = d.first_response_at.notna()
assert d.loc[responded, "first_response_at"].ge(d.loc[responded, "created_at"]).all()
assert d.loc[responded, "first_response_at"].lt(CUTOFF).all()
d["target_min"] = d.priority.map(TARGET)
assert d.target_min.notna().all()
d["business_min"] = [
business_minutes(a, b) for a, b in zip(d.created_at, d.first_response_at.fillna(CUTOFF))
]
d["late_unanswered"] = ~responded & d.business_min.ge(d.target_min)
d["eligible"] = ~duplicate & (responded | d.late_unanswered)
d["met"] = d.eligible & responded & d.business_min.le(d.target_min)
d["missed"] = d.eligible & ~d.met
d["month"] = d.created_at.dt.strftime("%Y-%m")
d["receipt"] = [
"Business hours" if any(a <= t < b for a, b in windows) else "Outside business hours"
for t in d.created_at
]
d["recorded"] = responded
# Use source event order. Each interval inherits the status at its start.
all_status = Counter()
kinds = ("new", "assigned", "waiting_customer")
stages = []
reopened = []
for line, row in d.iterrows():
events = [(pd.Timestamp(event["at"]).tz_convert(ZONE), event["status"]) for event in row.events]
all_status.update(status for _, status in events)
assert events[0] == (row.created_at, "new")
assert all(left[0] <= right[0] for left, right in zip(events, events[1:]))
first = next((j for j, (_, status) in enumerate(events) if status == "resolved"), None)
if any(status == "reopened" for _, status in events):
reopened.append(line)
if first is None:
assert pd.isna(row.resolved_at)
continue
assert events[first][0] == row.resolved_at and row.resolved_at < CUTOFF
hours = dict.fromkeys(kinds, 0.0)
for (begin, status), (end, _) in zip(events[:first], events[1:first + 1]):
hours[status] += (end - begin).total_seconds() / 3600
gross = (row.resolved_at - row.created_at).total_seconds() / 3600
assert abs(gross - sum(hours.values())) < 1e-8
stages.append({
"source_line": line, "gross_h": gross, **hours,
"adjusted_h": gross - hours["waiting_customer"]
})
resolved = pd.DataFrame(stages).set_index("source_line")
d = d.join(resolved, validate="one_to_one")
sla = d[d.eligible].copy()
raw = sla[sla.recorded].copy()
raw["target_multiple"] = raw.business_min / raw.target_min
def breakdown(columns):
table = sla.groupby(columns, dropna=False).agg(
eligible=("met", "size"), met=("met", "sum"), missed=("missed", "sum"),
unanswered_misses=("late_unanswered", "sum"), recorded=("recorded", "sum")
)
table["percent"] = 100 * table.met / table.eligible
return table
monthly = breakdown("month")
monthly.reset_index().assign(month_start=lambda g: g.month + "-01").to_csv("monthly.csv", index=False)
raw[["target_multiple"]].to_csv("response_observations.csv")
resolved[["adjusted_h"]].to_csv("resolution_observations.csv")
resolved[list(kinds)].rename(columns={
"new": "New", "assigned": "Assigned", "waiting_customer": "Waiting for customer"
}).reset_index().melt(id_vars="source_line", var_name="status", value_name="elapsed_h").to_csv(
"stage_observations.csv", index=False
)
if __name__ == "__main__":
print("Missing fields:", pd.DataFrame(records).isna().sum().to_dict())
print("Exact repeated records:", len(records) - len({json.dumps(r, sort_keys=True) for r in records}))
print("Events:", all_status, "reopened tickets:", len(reopened))
print("Scopes:", len(d), int(duplicate.sum()), len(sla), len(raw), len(resolved))
print("Overall:", int(sla.met.sum()), int(sla.missed.sum()), int(sla.late_unanswered.sum()))
for grouping in ["priority", "assignee_team", "channel", "receipt", "month",
["receipt", "priority"], ["month", "priority"]]:
print(breakdown(grouping).to_string())
print("Resolution", resolved.describe(percentiles=[.25, .5, .75, .9]).to_string())
print("Resolution sums", resolved.sum().to_dict())
print("Positive waiting count", int(resolved.waiting_customer.gt(0).sum()))
print("Resolution by team", d.groupby("assignee_team").adjusted_h.agg(["count", "median"]).to_string())
print("Response multiples", raw.target_multiple.describe(percentiles=[.5,.9]).to_dict())
print("Late answered response business hours", (raw.loc[raw.missed, "business_min"]/60).describe().to_dict())
print("Highest miss slice", sla[sla.missed].groupby(["priority","assignee_team"]).size().nlargest(5).to_dict())
print("Source examples", sla[sla.late_unanswered].index[0], int(resolved.assigned.idxmax()))
# Render each figure with python3 -I ../eda-skill/scripts/plots.py --spec plot-<id>.json --outdir delivery/figures
# Plot specifications (one per input table)
# plot-monthly_attainment.json
# {"source": {"path": "monthly.csv", "header": true}, "charts": [{"id": "monthly_attainment", "type": "line_time", "time": "month_start", "value": "percent", "title": "First-response SLA attainment by receipt month", "x_label": "Receipt month (KST)", "y_label": "Eligible tickets that met target", "y_unit": "%"}]}
# plot-resolution_spread.json
# {"source": {"path": "resolution_observations.csv", "header": true}, "charts": [{"id": "resolution_spread", "type": "histogram", "column": "adjusted_h", "bins": 26, "title": "Time to first resolution after customer waits", "x_label": "Receipt to first resolution, excluding customer waits", "x_unit": "hours", "y_label": "Tickets"}]}
# plot-resolution_stages.json
# {"source": {"path": "stage_observations.csv", "header": true}, "charts": [{"id": "resolution_stages", "type": "grouped_boxplot", "group": "status", "value": "elapsed_h", "title": "Time spent in each status before first resolution", "x_label": "Recorded event status", "y_label": "Elapsed time per ticket", "y_unit": "hours"}]}
# plot-response_observations.json
# {"source": {"path": "response_observations.csv", "header": true}, "charts": [{"id": "response_observations", "type": "scatter", "x": "source_line", "y": "target_multiple", "title": "Recorded first-response times relative to target", "x_label": "Original JSONL line", "y_label": "Business time divided by target", "y_unit": "times target"}]}