diff options
| author | dam <dam@gudinoff> | 2023-07-28 00:33:52 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-07-28 00:33:52 +0100 |
| commit | c42b75136be325ddb7eef2705f299f8c4a6218a7 (patch) | |
| tree | f57e4a35ae8d07eb8c256af5ed71e2e4eee9c0b3 /ttt.jai | |
| parent | 9d14c9ed9f0a1db804d2e7404807d00c66549687 (diff) | |
| download | task-time-tracker-c42b75136be325ddb7eef2705f299f8c4a6218a7.tar.zst task-time-tracker-c42b75136be325ddb7eef2705f299f8c4a6218a7.zip | |
Prototype implementation of coalesce feature.
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -1234,6 +1234,7 @@ main :: () { " r, R Restore selected task from archive.\n", " t, T Select currently active task (if any).\n", " d, D Duplicate selected task.\n", + " c, C Coalesce similar tasks.\n", " n, N Create new task.\n", " m, M Move selected task to position.\n", " g, G Select task by position.\n", @@ -1698,7 +1699,7 @@ main :: () { case #char "w"; #through; case #char "W"; if (db != *database || db.tasks.count <= 0) continue; - if (read_enter_confirmation(selected_task_row, action_style, " Press enter to archive duplicates and reset all. ") == true) { // TODO Improve message. + if (read_enter_confirmation(selected_task_row, action_style, " Press enter to archive duplicates and reset all. ") == true) { for db.tasks { if (append_to_csv(it, ar_file_path) == false) { print_error("Failed to archive entry."); // TODO Improve this. @@ -1707,6 +1708,33 @@ main :: () { } trigger_autosave(); } + + // Coalesce similar entries. + case #char "c"; #through; + case #char "C"; + if (db.tasks.count <= 0) continue; + if (read_enter_confirmation(selected_task_row, action_style, " Press enter to coalesce similar tasks. ") == true) { + // TODO Coalesce stuff. + print_error(" REQUIRES CODE CLEANUP AND TESTING "); + tasks_to_process := db.tasks.count - 1; + idx := 0; + while tasks_to_process > 0 { + task := *db.tasks[idx]; + for < i : db.tasks.count-1..idx+1 { + if compare_strings(xx task.name, xx db.tasks[i].name) == 0 { + for item, index: db.tasks[i].times { + task.times[index] = add(task.times[index], item); + } + delete_task(db, i); + tasks_to_process -= 1; + } + } + + idx += 1; + tasks_to_process -= 1; + } + trigger_autosave(); + } case KEY_HOME; select_task(db, 0); |
