Skip to content

Conversation

@DiegoAscanio
Copy link

Currently, task identifiers are generated using md5sum hashes. Since these hashes are not chronologically sortable, every time a new task is added it can end up in an arbitrary position in the task file.

To address this, I propose replacing the hash-based IDs with a monotonically increasing counter encoded in an obfuscated base62 ([0–9A–Z–a–z]) base. The counter starts at 62², so all generated IDs have at least three base62 digits, and is incremented every time a new task is created.

To preserve the IDs of existing tasks, I implemented a lookup table that maps each task’s hash to its current ID. When a task is processed, its hash is checked in this table:

if it already exists, the existing ID is reused;

if it does not exist, a new obfuscated base62 ID is generated from the counter, assigned to the task, and recorded in the lookup table.

For “summary line” tasks (those that can be added directly in a text editor without metadata), the first occurrence of such a task receives the next available ID (greater than all previous IDs). All subsequent tasks that follow this summary line receive IDs that are incremented from that point, ensuring that the chronological order of tasks in the file is consistent with their IDs.

… na linha de comando e sempre cria novas tarefas após as já criadas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant