ogn-python/app/commands/logbook.py

42 wiersze
1.1 KiB
Python
Czysty Zwykły widok Historia

2019-08-31 08:14:41 +00:00
from flask.cli import AppGroup
import click
from datetime import datetime
2020-10-27 19:46:14 +00:00
from app.collect.logbook import update_takeoff_landings, update_logbook
2019-08-31 08:14:41 +00:00
from tqdm import tqdm
from app.commands.database import get_database_days
from app.utils import date_to_timestamps
user_cli = AppGroup("logbook")
2020-10-27 19:46:14 +00:00
user_cli.help = "Handling of takeoff/landings and logbook data."
2019-08-31 08:14:41 +00:00
@user_cli.command("compute_takeoff_landing")
@click.argument("start")
@click.argument("end")
def compute_takeoff_landing(start, end):
"""Compute takeoffs and landings."""
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
pbar.set_description(datetime.strftime(single_date, "%Y-%m-%d"))
(start, end) = date_to_timestamps(single_date)
2020-10-27 19:46:14 +00:00
result = update_takeoff_landings(start=start, end=end)
2019-08-31 08:14:41 +00:00
@user_cli.command("compute_logbook")
@click.argument("start")
@click.argument("end")
def compute_logbook(start, end):
"""Compute logbook."""
days = get_database_days(start, end)
pbar = tqdm(days)
for single_date in pbar:
pbar.set_description(single_date.strftime("%Y-%m-%d"))
2020-10-27 19:46:14 +00:00
result = update_logbook(date=single_date)