mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 08:09:37 +00:00
29 lines
697 B
Python
29 lines
697 B
Python
import click
|
|
from flask.cli import AppGroup
|
|
|
|
from project import app, db
|
|
from project.dateutils import berlin_tz
|
|
from project.services.event import (
|
|
get_recurring_events,
|
|
update_event_dates_with_recurrence_rule,
|
|
)
|
|
|
|
event_cli = AppGroup("event")
|
|
|
|
|
|
@event_cli.command("update-recurring-dates")
|
|
def update_recurring_dates():
|
|
# Setting the timezone is neccessary for cli command
|
|
db.session.execute("SET timezone TO :val;", {"val": berlin_tz.zone})
|
|
|
|
events = get_recurring_events()
|
|
|
|
for event in events:
|
|
update_event_dates_with_recurrence_rule(event)
|
|
db.session.commit()
|
|
|
|
click.echo(f"{len(events)} event(s) were updated.")
|
|
|
|
|
|
app.cli.add_command(event_cli)
|