fix: 打卡内容完整显示,不再截断第2条
This commit is contained in:
+16
-6
@@ -41,17 +41,27 @@ def _memo_oneline(rec: dict) -> str:
|
||||
return " / ".join(x.strip() for x in (rec.get("memo") or "").replace("\r", "\n").split("\n") if x.strip())
|
||||
|
||||
|
||||
def _day_memo(records: list) -> tuple[str, str]:
|
||||
"""Use the longest memo of the day; morning and evening punches usually repeat it."""
|
||||
best_site, best_memo = "", ""
|
||||
for rec in records:
|
||||
memo = _memo_oneline(rec)
|
||||
if len(memo) >= len(best_memo):
|
||||
best_memo = memo
|
||||
best_site = (rec.get("siteName") or "").strip()
|
||||
return best_site, best_memo
|
||||
|
||||
|
||||
def print_table(summaries) -> None:
|
||||
print(f"{'日期':<12}{'次数':>4} {'补卡':<4} {'最早':<9}{'最晚':<9}{'时长h':>6} {'状态':<18}站点 / 打卡内容")
|
||||
print(f"{'日期':<12}{'次数':>4} {'补卡':<4} {'最早':<9}{'最晚':<9}{'时长h':>6} {'状态':<18}站点")
|
||||
print("-" * 114)
|
||||
for s in summaries:
|
||||
rec = s.records[-1] if s.records else {}
|
||||
site = (rec.get("siteName") or "").strip()
|
||||
memo = _memo_oneline(rec)
|
||||
extra = (site[:16] + "… " if site else "") + memo
|
||||
site, memo = _day_memo(s.records)
|
||||
supp = "含补" if s.has_supplement else " "
|
||||
print(f"{s.day.isoformat():<12}{s.count:>4} {supp:<4} {_fmt_t(s.first):<9}{_fmt_t(s.last):<9}"
|
||||
f"{s.hours:>6.1f} {s.status:<18}{extra[:60]}")
|
||||
f"{s.hours:>6.1f} {s.status:<18}{site}")
|
||||
if memo:
|
||||
print(f" {memo}")
|
||||
|
||||
|
||||
def export_csv(rows: list[dict], path: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user