mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-12 09:41:18 +02:00
Merge pull request #831 from Gliese852/ensure-unique-id
Ensure Model ID is unique
This commit is contained in:
commit
3cc017b7b5
1 changed files with 7 additions and 4 deletions
|
@ -78,13 +78,16 @@ if not builtins.howdy_args.plain:
|
||||||
# Set the default label
|
# Set the default label
|
||||||
label = "Initial model"
|
label = "Initial model"
|
||||||
|
|
||||||
|
# some id's can be skipped, but the last id is always the maximum
|
||||||
|
next_id = encodings[-1]["id"] + 1 if encodings else 0
|
||||||
|
|
||||||
# Get the label from the cli arguments if provided
|
# Get the label from the cli arguments if provided
|
||||||
if builtins.howdy_args.arguments:
|
if builtins.howdy_args.arguments:
|
||||||
label = builtins.howdy_args.arguments[0]
|
label = builtins.howdy_args.arguments[0]
|
||||||
|
|
||||||
# If models already exist, set that default label
|
# Or set the default label
|
||||||
elif encodings:
|
else:
|
||||||
label = _("Model #") + str(len(encodings) + 1)
|
label = _("Model #") + str(next_id)
|
||||||
|
|
||||||
# Keep de default name if we can't ask questions
|
# Keep de default name if we can't ask questions
|
||||||
if builtins.howdy_args.y:
|
if builtins.howdy_args.y:
|
||||||
|
@ -106,7 +109,7 @@ if "," in label:
|
||||||
insert_model = {
|
insert_model = {
|
||||||
"time": int(time.time()),
|
"time": int(time.time()),
|
||||||
"label": label,
|
"label": label,
|
||||||
"id": len(encodings),
|
"id": next_id,
|
||||||
"data": []
|
"data": []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue