Closed sebastiancarlos closed 2 months ago
probably the tags should be thought of as a set, not a list, and their order not relied upon, but rather their presence.
@sebastiancarlos Just like @smemsh said, tags are implemented as a set, so the order is not guaranteed. I would be interested in your use case why you need the Taskwarrior UUID always at the first position... 🤔
@lauft Got it, thanks.
My use case is that I want to:
timew summary
to take a quick glance at the intervals and their metadata. And this is easier if the metadata for all tasks appears in the same order.Given that the tags are sets, I ended up prefixing the fields.
# on-modify.timewarrior
...
def extract_tags_from(json_obj):
# Note: The tags are sorted alphabetically by timewarrior, so here they are
# prefixed by the type of tag so they always appear in the same order in
# the summary.
# get first 8 characters of the UUID
tags = [f'uuid:{json_obj["uuid"][:8]}']
if 'project' in json_obj:
# add projects a tag
tags.append(f'project:{json_obj["project"]}')
if 'ticket' in json_obj:
# add ticket as a tag
tags.append(f'ticket:{json_obj["ticket"]}')
# append description as a tag
tags.append(f'desc:{json_obj["description"]}')
return tags
...
It seems that the order is alphabetical. Feel free to close this ticket if you see no advantage in keeping the cli order, as I think the priority is maintaining backwards compatibility.
The reason I want this is because I want the first tag to always be the taskwarrior uuid, but it moves around depending on the first character.