Browse Source

- 修改保持跟进、搁置状态下截止日期的显示效果

- 修改综合优先级的规则(权重调整、“保持跟进”和“搁置”不受截止日期影响)
master
lxb 2 months ago
parent
commit
4c33cc1afb
  1. 31
      app.py

31
app.py

@ -13,7 +13,7 @@ from tkcalendar import Calendar
# ----------------------- CONFIG -----------------------
# region 配置
VERSION = "v1.0.1"
VERSION = "v1.0.2"
DB_PATH = "tasks.db" # 数据库文件路径
TEMPLATES_PATH = "templates.json" # 检索模板文件路径
@ -80,7 +80,7 @@ SORT_ORDER = {
COMPOSITE_WEIGHTS = {
"priority": {"SSS": 4.0, "SS": 3.0, "S": 2.0, "A": 1.0, "B": 0.8, "C": 0.6, "D": 0.4, "E": 0.2},
"type": {"Bug": 1.5, "需求": 1.0, "其他": 1.0},
"status": {"待处理": 0.9, "进行中": 1.0, "保持跟进": 0.1, "搁置": 0.1, "取消": 0.0, "已完成": 0.0},
"status": {"待处理": 0.9, "进行中": 1.0, "保持跟进": 0.15, "搁置": 0.1, "取消": 0.0, "已完成": 0.0},
# age factor multiplier (per day)
"age_factor": 0.1
}
@ -128,8 +128,11 @@ DEADLINE_COLOR = [
(4, "#73bc75"),
(10, "#83d6ff"),
(15, "#bdd8e9"),
(30, "#ffffff"),
]
# 保持跟进、搁置超出日期时的颜色
PAUSE_DEADLINE_COLOR = "#fbffa9"
# 默认颜色
DEFAULT_DEADLINE_COLOR = "#ffffff"
# endregion
@ -407,11 +410,17 @@ def compute_composite_score(task_row: dict) -> float:
except Exception:
have_deadline = False
# 各种因素分数
ddl_score = 1 + math.exp(-(0.3 + days_to_deadline / 3.0)) if have_deadline else 0.8
ddl_score = 1 + math.exp(-(0.3 + days_to_deadline / 3.0)) if have_deadline else 0.9
d_score = COMPOSITE_WEIGHTS.get("age_factor", 0.1) * days_from_start + 1
p_score = COMPOSITE_WEIGHTS["priority"].get(task_row.get("priority"), 1.0)
t_score = COMPOSITE_WEIGHTS["type"].get(task_row.get("type"), 1.0)
s_score = COMPOSITE_WEIGHTS["status"].get(task_row.get("status"), 1.0)
# 跟进和搁置状态不考虑截止日期
state = task_row.get("status")
if state in ["保持跟进", "搁置"]:
ddl_score = 1.0
# 计算综合优先级分数
score = p_score * t_score * s_score * d_score * ddl_score
return round(float(score), 6)
@ -940,19 +949,19 @@ class TaskManagerApp(ctk.CTk):
try:
dt_deadline = datetime.fromisoformat(ddl)
days_to_deadline = (dt_deadline.date() - datetime.now(dt_deadline.tzinfo or timezone.utc).date()).days
bg = DEFAULT_DEADLINE_COLOR
for (d, c) in DEADLINE_COLOR:
if days_to_deadline <= d:
bg = c
try: self.sheet.highlight_cells(row=r_idx, column=COL_DEADLINE, bg=bg)
except Exception:
try: self.sheet.set_cell_bg(r_idx,COL_DEADLINE,bg)
except Exception: pass
bg = c if st not in ["保持跟进", "搁置"] else PAUSE_DEADLINE_COLOR
break
try: self.sheet.highlight_cells(row=r_idx, column=COL_DEADLINE, bg=bg)
except Exception:
try: self.sheet.set_cell_bg(r_idx,COL_DEADLINE,bg)
except Exception: pass
except Exception:
pass
else:
# 取最后一个颜色
bg = DEADLINE_COLOR[-1][1]
bg = DEFAULT_DEADLINE_COLOR
try: self.sheet.highlight_cells(row=r_idx, column=COL_DEADLINE, bg=bg)
except Exception:
try: self.sheet.set_cell_bg(r_idx,COL_DEADLINE,bg)

Loading…
Cancel
Save