import arlo
This commit is contained in:
0
task/health_knowledge/__init__.py
Normal file
0
task/health_knowledge/__init__.py
Normal file
BIN
task/health_knowledge/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
task/health_knowledge/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
21
task/health_knowledge/health_knowledge.py
Normal file
21
task/health_knowledge/health_knowledge.py
Normal file
@ -0,0 +1,21 @@
|
||||
from database.database import get_session
|
||||
from database.thealthknowledge.health_knowledge import get_oldest_unused_data, mark_data_as_used
|
||||
from database.tscheduler.model import TScheduler
|
||||
from log.log_manager import log
|
||||
from mail.mail_manager import send_mail
|
||||
|
||||
|
||||
def send_health_knowledge_mail_task(scheduler: TScheduler):
|
||||
with get_session() as db:
|
||||
# 获取需要发送的内容列表
|
||||
health_knowledge = get_oldest_unused_data(db)
|
||||
# 发送邮件
|
||||
subject = health_knowledge.subject
|
||||
content = health_knowledge.knowledge
|
||||
send_mail(subject, content, receiver_email="lu9531@126.com")
|
||||
log(f"send mail success with title {subject}, content {content[:20]}.")
|
||||
# 更新数据库
|
||||
mark_data_as_used(db, health_knowledge)
|
||||
|
||||
if __name__ == '__main__':
|
||||
send_health_knowledge_mail_task(TScheduler())
|
||||
Reference in New Issue
Block a user