mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 15:35:12 +02:00
Anpassung scheduler
This commit is contained in:
parent
8679e44386
commit
936040fcb1
@ -108,6 +108,14 @@ doc_events = {
|
|||||||
# Scheduled Tasks
|
# Scheduled Tasks
|
||||||
# ---------------
|
# ---------------
|
||||||
|
|
||||||
|
scheduler_events = {
|
||||||
|
"cron": {
|
||||||
|
"*/5 * * * *": [
|
||||||
|
"msp.tools.update_tickets_and_articles"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# scheduler_events = {
|
# scheduler_events = {
|
||||||
# "all": [
|
# "all": [
|
||||||
# "msp.tasks.all"
|
# "msp.tasks.all"
|
||||||
|
@ -436,9 +436,14 @@ def update_tickets_and_articles():
|
|||||||
# Ensure settings.last_ticket_sync has a default value
|
# Ensure settings.last_ticket_sync has a default value
|
||||||
last_ticket_sync = settings.last_ticket_sync or '2024-07-01T00:00:00'
|
last_ticket_sync = settings.last_ticket_sync or '2024-07-01T00:00:00'
|
||||||
|
|
||||||
|
# Add a buffer of 15 minutes to the last_ticket_sync time
|
||||||
|
last_ticket_sync_time = datetime.strptime(last_ticket_sync, "%Y-%m-%d %H:%M:%S")
|
||||||
|
last_ticket_sync_with_buffer = (last_ticket_sync_time - timedelta(minutes=15)).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
new_tickets = get_tickets_from_otrsdb(otrsdb, f"ticket.id > {int(settings.last_ticket_id)}")
|
new_tickets = get_tickets_from_otrsdb(otrsdb, f"ticket.id > {int(settings.last_ticket_id)}")
|
||||||
print(len(new_tickets))
|
print(len(new_tickets))
|
||||||
updated_tickets = get_tickets_from_otrsdb(otrsdb, f"ticket.change_time > '{last_ticket_sync}'")
|
updated_tickets = get_tickets_from_otrsdb(otrsdb, f"ticket.change_time > '{last_ticket_sync_with_buffer}'")
|
||||||
print(len(updated_tickets))
|
print(len(updated_tickets))
|
||||||
articles = get_articles_from_otrsdb(otrsdb, int(settings.last_article_id))
|
articles = get_articles_from_otrsdb(otrsdb, int(settings.last_article_id))
|
||||||
print(len(articles))
|
print(len(articles))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user