This commit is contained in:
17
task/material_distribution.py
Normal file
17
task/material_distribution.py
Normal file
@ -0,0 +1,17 @@
|
||||
from database.database import get_session
|
||||
from database.tmaterial.crud import receive_news
|
||||
from database.tnews.crud import get_news_unprocessed, set_news_usage
|
||||
from log.log_manager import log
|
||||
from task.manager_task import execute_task
|
||||
|
||||
|
||||
def distribution_task():
|
||||
with get_session() as db:
|
||||
news_list = get_news_unprocessed(db)
|
||||
receive_news(db, news_list)
|
||||
set_news_usage(db, news_list)
|
||||
log(f'distributed {len(news_list)} news')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
execute_task(distribution_task)
|
||||
Reference in New Issue
Block a user