Make the upcoming-photos queue length user-configurable
Build and push server image / build-and-push (push) Successful in 42s
Build and push server image / build-and-push (push) Successful in 42s
Adds "Upcoming photos to show" to the config UI (queue_target_len, 5-50, default 20, replacing the hardcoded QUEUE_TARGET_LEN constant). Lowering it trims the queue immediately on next page load rather than waiting for enough advances to consume the excess naturally; raising it tops back up the same way, via a new photo_queue.sync_queue_length() called from GET /api/queue.
This commit is contained in:
+8
-1
@@ -24,6 +24,8 @@ templates = Jinja2Templates(directory="app/templates")
|
||||
|
||||
MIN_REFRESH_INTERVAL_S = 60
|
||||
MAX_REFRESH_INTERVAL_S = 86400
|
||||
MIN_QUEUE_TARGET_LEN = 5
|
||||
MAX_QUEUE_TARGET_LEN = 50
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
@@ -65,6 +67,7 @@ def api_config_save(
|
||||
order: str = Form("sequential"),
|
||||
refresh_interval_s: int = Form(3600),
|
||||
smart_crop_faces: bool = Form(True),
|
||||
queue_target_len: int = Form(20),
|
||||
):
|
||||
# Immich URL/API key are env-var only (IMMICH_URL/IMMICH_API_KEY, see
|
||||
# docker-compose.yml.example) -- config.load() already applies them,
|
||||
@@ -82,6 +85,7 @@ def api_config_save(
|
||||
cfg.order = order if order in ("sequential", "shuffle") else "sequential"
|
||||
cfg.refresh_interval_s = max(MIN_REFRESH_INTERVAL_S, min(MAX_REFRESH_INTERVAL_S, refresh_interval_s))
|
||||
cfg.smart_crop_faces = smart_crop_faces
|
||||
cfg.queue_target_len = max(MIN_QUEUE_TARGET_LEN, min(MAX_QUEUE_TARGET_LEN, queue_target_len))
|
||||
config.save(cfg)
|
||||
return {"status": "saved"}
|
||||
|
||||
@@ -166,7 +170,10 @@ def api_queue():
|
||||
client = ImmichClient(cfg.immich_url, cfg.immich_api_key)
|
||||
assets = _list_assets(client, cfg)
|
||||
|
||||
if photo_queue.get_current(cfg, assets):
|
||||
current_changed = photo_queue.get_current(cfg, assets)
|
||||
queue_before = list(cfg.queue)
|
||||
photo_queue.sync_queue_length(cfg, assets)
|
||||
if current_changed or cfg.queue != queue_before:
|
||||
config.save(cfg)
|
||||
|
||||
def entry(asset_id: str) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user