Skip to content

Commit

Permalink
feat: debuglimit for Importable config (#40)
Browse files Browse the repository at this point in the history
Stops after `debuglimit` entries are imported.

---------

Co-authored-by: Sven Eberth <[email protected]>
  • Loading branch information
phorward and sveneberth authored Jan 6, 2025
1 parent d4fdfd7 commit 13dfe6b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/viur/toolkit/importer/importable.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Importable:
"translate.ignore": None, # Bones to be ignored in automatically generated translation
"action": "list", # Action to run, default is "list"
"limit": 99, # Amount of items to fetch per request (only for list-ables)
"debuglimit": None, # After this amount of entries we stop the import (use it for debugging only!)
"render": "vi", # Renderer to run on
"params": None, # Further parameters passed to the action
"follow": [], # Following modules to be imported, that depend on this import.
Expand Down Expand Up @@ -293,8 +294,8 @@ def do_import(
params.update(conf_params)

if "limit" not in params:
params["limit"] = import_conf.get("limit", 99)
params["amount"] = import_conf.get("limit", 99)
params["limit"] = import_conf.get("limit", 99) # viur >= 3
params["amount"] = import_conf.get("limit", 99) # viur < 3

if "cursor" not in params:
params["cursor"] = cursor
Expand Down Expand Up @@ -356,9 +357,10 @@ def do_import(
):
updated += 1

# if total >= 5:
# skellist = ()
# break
if debuglimit := import_conf.get("debuglimit"):
if total >= debuglimit:
skellist = []
break

logger.info("%s: %d entries imported, %d entries updated", self.moduleName, total, updated)

Expand Down

0 comments on commit 13dfe6b

Please sign in to comment.