-
Notifications
You must be signed in to change notification settings - Fork 927
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
Moves the note's description, author ID, and author IP from the first comment to the note itself #5485
base: master
Are you sure you want to change the base?
Conversation
Added migration scripts for adding description, user_id and user_ip columns to notes table, adding foreign key connecting note and users, updated notes scheme description in model file and added migration script for initializing Note.{description, user_id, user_ip} from first special note comment.
Improved NoteController#create to store note's description to Note.description instead of first (opening) comment. First comment will still be created.
Replaced using first comment's body with Note's description. Also, replaced using first comment's author and author_ip (through Note) with Note's variants.
Updated notes' j(builder) files to use Note.description instead of first note comment (opening) body. Also, improved indentation in _comment partial.
Updated tests to specify note's description and author when creating note (to follow the latest scheme).
How does this relate to the notes restructuring plan from #3831? Is this a step on the way to that or is it going in a different direction? |
This does align with the goals of #3831 in a way, and can be considered alternative to #4481. In fact, the initial motivation for this change came from a comment in #5294, which suggested that note versioning could be a right approach for adding tags. To implement note versioning properly, this PR serves as a first step towards that. It might be worth opening a new issue specifically about note versioning, linking back to that comment for context. |
What I was going to say in comments for #5294 is that the plan from #3831 tries to solve (a) by ignoring (b). You can read the original post of #3831 and see that it doesn't mention note actions/events at all. And those actions, they are stored in the comments table. You'll still have another leaky abstraction as that post says. Note comments won't be really comments. You'll close a note without a comment, that will still generate a "comment" entry in
The direction is hopefully the same for things stated explicitly in #3831. It's different for things omitted. |
This PR should be first step toward adding editable note-tags and solving #3831. In next PRs we planned to:
We thought to do above as a sequence of as small as possible PRs (like this one), but if you would prefer one big, we can do it? Every comment / suggestion is very welcome :-) |
I hadn't previously noticed that #5294 had proposed adding versioning - that's a whole other level of additional complication. I can understand why it might be needed for tags, and I guess it also allows for editing the initial description if we want once that it part of the note itself rather than being a special comment. I do wonder how it interacts with comments though - do we duplicate those for every version like we do with members of other objects or do we always show all comments whatever the version or maybe track add the current version to the comment when it's created and then show comments up to the note's version when showing an old version of the note? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to need to be broken down in to multiple PRs as we can't take all three migrations in one go, and we can't take code changes that rely on new fields until after those fields have been created.
The first two PRs should be one to create new methods on Note
that correspond to the new fields but just look (for now) at the first comment, and one to add the new fields to Note
.
After that a PR to validate the new key and one to adjust the new methods in Note
to take the description from the note if the first comment has been migrated.
Only after that can we have a PR to actually do the migration.
else | ||
json.text comment.body.to_text | ||
json.html comment.body.to_html | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan in #3831 was to add methods like description
to the Note
model first so that we can hide this kind of logic in one place and avoid duplicating it even temporarily - those methods can then be removed once the migration is complete.
Our current plan is to |
I wouldn't say "duplicate (comments) for every version like we do with members of other objects" - do we even have comments for versioned objects elsewhere? The idea is to take the current comments, let's call them api 0.6 comments, and split them into actual comments and versions. Versions will contain states (open/closed/hidden) that were previously in api 0.6 comments. After that it should be possible to reassemble actual comments and versions into api 0.6 comments for use in api calls. This reassembling wouldn't require associating comments with versions if I'm correct. |
Description
PR improves using of note's description / author_id / author_ip by:
A few comments:
How has this been tested?
By running automated tests and by semi-manual testing (semi-manual generating notes, doing migration and applying changes, manually checking rendered notes and new memory variables content).