aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fietsboek/scripts/fietsctl.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/fietsboek/scripts/fietsctl.py b/fietsboek/scripts/fietsctl.py
index 8be226a..7f7170c 100644
--- a/fietsboek/scripts/fietsctl.py
+++ b/fietsboek/scripts/fietsctl.py
@@ -9,6 +9,7 @@ from pyramid.scripting import AppEnvironment
from sqlalchemy import select
from .. import __VERSION__, hittekaart, models
+from ..data import DataManager
from . import config_option
EXIT_OKAY = 0
@@ -229,6 +230,7 @@ def cmd_maintenance_mode(ctx: click.Context, config: str, disable: bool, reason:
multiple=True,
default=["heatmap"],
)
+@click.option("--delete", help="Delete the specified heatmap", is_flag=True)
@optgroup.group("User selection", cls=RequiredMutuallyExclusiveOptionGroup)
@optgroup.option("--id", "-i", "id_", help="database ID of the user", type=int)
@optgroup.option("--email", "-e", help="email of the user")
@@ -237,6 +239,7 @@ def cmd_hittekaart(
ctx: click.Context,
config: str,
modes: list[str],
+ delete: bool,
id_: Optional[int],
email: Optional[str],
):
@@ -252,12 +255,23 @@ def cmd_hittekaart(
exe_path = env["request"].config.hittekaart_bin
with env["request"].tm:
dbsession = env["request"].dbsession
- data_manager = env["request"].data_manager
+ data_manager: DataManager = env["request"].data_manager
user = dbsession.execute(query).scalar_one_or_none()
if user is None:
click.echo("Error: No such user found.", err=True)
ctx.exit(EXIT_FAILURE)
+ if delete:
+ try:
+ user_manager = data_manager.open_user(user.id)
+ except FileNotFoundError:
+ return
+ if hittekaart.Mode.HEATMAP in modes:
+ user_manager.heatmap_path().unlink(missing_ok=True)
+ if hittekaart.Mode.TILEHUNTER in modes:
+ user_manager.tilehunt_path().unlink(missing_ok=True)
+ return
+
click.echo(f"Generating overlay maps for {user.name}...")
for mode in modes: