thombruce / toodles

✅ A super simple todo app
https://toodles.thombruce.com/
GNU General Public License v3.0
0 stars 0 forks source link

Prices and Multipliers #112

Closed thombruce closed 3 months ago

thombruce commented 3 months ago

closes #111

By submitting this pull request, you agree to follow our Code of Conduct: https://github.com/thombruce/.github/blob/main/CODE_OF_CONDUCT.md


Internal use. Do not delete.

netlify[bot] commented 3 months ago

Deploy Preview for toodles canceled.

Name Link
Latest commit 908dd64c8e67a9191af6902e81266dfd410dea10
Latest deploy log https://app.netlify.com/sites/toodles/deploys/666354bc833fd90008d1f817
github-actions[bot] commented 3 months ago

Coverage Summary for `./packages/web`

Status Category Percentage Covered / Total
🟢 Lines 69.61% / 60% 433 / 622
🟢 Statements 69.61% / 60% 433 / 622
🟢 Functions 65.85% / 60% 27 / 41
🟢 Branches 72.05% / 60% 49 / 68
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
packages/web/src/components/ContextTag.vue 20% 100% 0% 20% 4-15
packages/web/src/components/HashTag.vue 20% 100% 0% 20% 4-15
packages/web/src/components/ProgressBar.vue 70.17% 66.66% 100% 70.17% 16-23, 26-34
packages/web/src/components/ProjectTag.vue 20% 100% 0% 20% 4-15
packages/web/src/components/TagTag.vue 71.42% 100% 0% 71.42% 6-7
packages/web/src/components/TodoItem.vue 80.7% 40% 28.57% 80.7% 21, 26-27, 33-40
packages/web/src/components/TodoList.vue 73.68% 100% 100% 73.68% 11-15
packages/web/src/components/TodoPriority.vue 20% 100% 0% 20% 4-15
packages/web/src/components/TodoText.vue 68.08% 60% 85.71% 68.08% 15-18, 21-25, 34-36, 40-42
packages/web/src/models/Todo.ts 89.65% 76.92% 100% 89.65% 35-41, 55-56
packages/web/src/plugins/dexie.ts 62.82% 80% 66.66% 62.82% 46-54, 59-78
packages/web/src/plugins/lunr.ts 100% 100% 100% 100%
packages/web/src/plugins/timepiece.ts 71.42% 60% 50% 71.42% 14-19
packages/web/src/stores/todos.ts 73.14% 100% 83.33% 73.14% 21, 25, 29-31, 35-37, 41-43, 47-49, 53-55, 59-61, 65-67, 71-73, 77-79, 83-85, 89-91, 95-97, 107-115
thombruce commented 3 months ago

Does not presently add the additional decorations suggested in the issue; for instance, to show a total based on price multiplied by multiplier.

Since each regex is iterated over in sequence, however, it seems redundant to identify price again just to apply the multiplier to it.

This may call for a refactor first of all and a better understanding of the order of operations involved here.

I think we leave hover messages as a future exercise. I need to better understand how VS Code extensions interpret the lines of a document - handling something like sorting first may teach me this - and possibly refactor the approach to matching items such that, well, in particular such that when it comes to prices and multipliers we're handling these at the same time. 🤔

That's a thought, huh? Rather than iterate over regexes for those two, why not produce a custom function that handles them both. This would be no more or less (in)efficient than our current approach, which is to iterate over matching tasks in sequence anyway. In the case of prices and multipliers, we remove them from the iterated items and handle them both in one custom function.

thombruce commented 3 months ago

The above said, I'm still tempted to say let's refactor first. The code could certainly use some tidying up, and the idea of handling prices separately from other iterated matching patterns suggests we might explore a sort of... plugin pattern. This would mean holding the code to handle that in a different file or files, and the current codebase being mostly a single file does not lend itself to doing that.

I say, merge the code as is now, create a refactor issue, create an issue to handle this in the future, execute in that order.

thombruce commented 3 months ago

Have made the decision to match prices only near the start of the string, after dates. This will make it easier to recognise the correct price and apply the multiplier to it. Toodles list item order is now:

[status] [priority] [completed date] [created date] [due date] [price] Description of todo [multiplier]

Every part of the above, apart from description, is optional. Additionally, if a completed todo has a completed date, it must also have a created date (holdover rule from todo.txt). Due date is always optional but must come after the created date.