Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement Replica::pending_tasks #454

Merged

Conversation

Scandiravian
Copy link
Contributor

This is a first attempt at #452.

I've implemented two different approaches in the storage layer and I'm looking for feedback on whether either of these, or a third approach, would be most optimal.

Currently the taskdb layer use the more "naive" approach, which follows the original c++ code more closely.

The alternative approach would use the get_tasks_by_status to query for pending tasks. I am however not sure whether there could potentially be an inconsistency between the working_set and the sqlite database, which would make that solution unfeasible.

@djmitche
Copy link
Collaborator

Nice work! I think it would be unusual to want to get all completed or deleted tasks (and those cases would be covered by all_tasks()).

And, the set of all pending tasks and the working set can be slightly different in ways that might be significant. I think the best approach here would be joining with the working set to get the working-set tasks.

@Scandiravian Scandiravian force-pushed the feat/replica__pending_tasks branch 3 times, most recently from ee6da77 to 38e108e Compare September 12, 2024 09:09
@Scandiravian
Copy link
Contributor Author

Nice work! I think it would be unusual to want to get all completed or deleted tasks (and those cases would be covered by all_tasks()).

And, the set of all pending tasks and the working set can be slightly different in ways that might be significant. I think the best approach here would be joining with the working set to get the working-set tasks.

Thanks for the feedback. I've updated the PR so it hopefully reflect your suggestions. I moved some code from pending_tasks to pending_tasks_data when implementing the latter, but the functionality should be the same.

I have also fixed the CI failures, so I think this is ready for review. Let me know if you'd like any other changes to the code

@Scandiravian Scandiravian marked this pull request as ready for review September 12, 2024 09:17
@djmitche
Copy link
Collaborator

Nice work! I think it would be unusual to want to get all completed or deleted tasks (and those cases would be covered by all_tasks()).
And, the set of all pending tasks and the working set can be slightly different in ways that might be significant. I think the best approach here would be joining with the working set to get the working-set tasks.

Thanks for the feedback. I've updated the PR so it hopefully reflect your suggestions. I moved some code from pending_tasks to pending_tasks_data when implementing the latter, but the functionality should be the same.

I have also fixed the CI failures, so I think this is ready for review. Let me know if you'd like any other changes to the code

This implementation looks solid and well-tested!

However, this still requires two separate queries to get the pending tasks: first to get the list of UUIDs in the pending set, and second to fetch each of those tasks. This involves sending that list of UUIDs from the DB to Rust and back. Could a single get_pending_tasks method do this in one query, with something like SELECT tasks.* from tasks join working_set on..?

@djmitche djmitche removed their request for review September 13, 2024 14:12
@Scandiravian Scandiravian force-pushed the feat/replica__pending_tasks branch 2 times, most recently from 67e658b to 7212d14 Compare September 16, 2024 14:49
@Scandiravian
Copy link
Contributor Author

Scandiravian commented Sep 16, 2024

That's really good feedback. I hadn't realised that the working set already exists in the database, thanks 😄

I'm guessing that there's somewhere else in the code that ensures only tasks with the "pending" status are added to the working_set?

I've added a new commit that changes the implementation to using a join to do it in a single query. Let me know if you would like any other changes. I'm personally not entirely happy with the inmemory implementation of get_pending_tasks as it's a bit too nested/complicated making it difficult to read

If you're happy with how the implementation is looking I'm going to squash the changes into a single commit before merging and give the code another pass to see if I can improve the readability+improve the doc strings

@djmitche
Copy link
Collaborator

I'm guessing that there's somewhere else in the code that ensures only tasks with the "pending" status are added to the working_set?

Yes, modifications to the status property trigger adjustments of the working set.

I've added a new commit that changes the implementation to using a join to do it in a single query. Let me know if you would like any other changes. I'm personally not entirely happy with the inmemory implementation of get_pending_tasks as it's a bit too nested/complicated making it difficult to read

If you're happy with how the implementation is looking I'm going to squash the changes into a single commit before merging and give the code another pass to see if I can improve the readability+improve the doc strings

I'll have a look shortly!

@djmitche djmitche self-requested a review September 18, 2024 01:43
Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really close! Just a few comments below.

taskchampion/src/replica.rs Outdated Show resolved Hide resolved
taskchampion/src/storage/inmemory.rs Show resolved Hide resolved
taskchampion/src/storage/test.rs Show resolved Hide resolved
@Scandiravian
Copy link
Contributor Author

Thank you so much for the review and for taking the time to thoroughly explain the bug that my choice of LEFT JOIN would have caused - it helps me improve as a developer

I've added a commit for each comment you had to make it easier to read through. I hope it's okay to run the changes by you one final time before I squash (actually fixup) everything into a single commit so it's ready to merge 🤞

Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! And no problem at all making another round of review.

I can squash this when merging, so if you want to just make one more commit to fix the comment, that's all that should be necessary.

taskchampion/src/storage/test.rs Outdated Show resolved Hide resolved
@Scandiravian
Copy link
Contributor Author

Hey @djmitche

If everything looks good to you, feel free to squash and merge the PR 😄

Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay!

@djmitche djmitche merged commit 40d8c9e into GothenburgBitFactory:main Sep 25, 2024
13 checks passed
@Scandiravian
Copy link
Contributor Author

Sorry for the delay!

No problem. I wasn't sure if I had communicated clearly that I thought I had solved all remaining issues 😅

Thanks so much for all your constructive feedback on my changes. This was an incredibly pleasant experience and I hope I'll get the chance to contribute to the project again

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.

2 participants