feat: 职称评审核验助手首版 v1.0.1(verify-promotion-metric-default)
All checks were successful
技能自动化发布 / release (push) Successful in 7s
All checks were successful
技能自动化发布 / release (push) Successful in 7s
This commit is contained in:
58
scripts/db/seed_data.py
Normal file
58
scripts/db/seed_data.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""业务种子数据:职称评审刚性门槛(示例,上线前由人事处核准维护)。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
|
||||
from util.timeutil import now_unix
|
||||
|
||||
_BASIS = "《专业技术职务评聘办法》"
|
||||
|
||||
# (rank, metric_key, metric_name, min_value, unit, basis_doc, clause)
|
||||
_SEED_THRESHOLDS: tuple[tuple[str, str, str, float, str, str, str], ...] = (
|
||||
("副教授", "presiding_provincial", "主持省部级项目", 1.0, "项", _BASIS, "第X条"),
|
||||
("副教授", "core_papers", "核心期刊论文", 3.0, "篇", _BASIS, "第X条"),
|
||||
("副教授", "teaching_hours", "年均教学工作量", 160.0, "课时", _BASIS, "第X条"),
|
||||
("副教授", "current_title_years", "任现职年限", 5.0, "年", _BASIS, "第X条"),
|
||||
("教授", "presiding_provincial", "主持省部级项目", 2.0, "项", _BASIS, "第X条"),
|
||||
("教授", "core_papers", "核心期刊论文", 6.0, "篇", _BASIS, "第X条"),
|
||||
("教授", "monographs", "专著/教材", 1.0, "部", _BASIS, "第X条"),
|
||||
("教授", "current_title_years", "任现职年限", 5.0, "年", _BASIS, "第X条"),
|
||||
)
|
||||
|
||||
_KNOWN_METRIC_KEYS = (
|
||||
"presiding_provincial",
|
||||
"core_papers",
|
||||
"teaching_hours",
|
||||
"current_title_years",
|
||||
"monographs",
|
||||
"awards",
|
||||
"degree",
|
||||
)
|
||||
_KNOWN_RANKS = ("副教授", "教授")
|
||||
|
||||
|
||||
def seed_thresholds(cursor: sqlite3.Cursor) -> int:
|
||||
"""幂等写入门槛种子,返回新增条数。"""
|
||||
inserted = 0
|
||||
for rank, metric_key, metric_name, min_value, unit, basis_doc, clause in _SEED_THRESHOLDS:
|
||||
cursor.execute(
|
||||
"SELECT COUNT(*) FROM threshold_rules WHERE rank = ? AND metric_key = ?",
|
||||
(rank, metric_key),
|
||||
)
|
||||
if int(cursor.fetchone()[0]) > 0:
|
||||
continue
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO threshold_rules
|
||||
(rank, metric_key, metric_name, min_value, unit, basis_doc, clause, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(rank, metric_key, metric_name, min_value, unit, basis_doc, clause, now_unix(), now_unix()),
|
||||
)
|
||||
inserted += 1
|
||||
return inserted
|
||||
|
||||
|
||||
def seed_all(cursor: sqlite3.Cursor) -> dict[str, int]:
|
||||
return {"threshold_rules": seed_thresholds(cursor)}
|
||||
Reference in New Issue
Block a user