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
Facilitate comment reuse with a new History tab #3437
Changes from 5 commits
392e626
0e72a56
382c2a0
4ddfde6
13e2b0f
f910947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,15 @@ class Submissions < Core | |
|
||
title("%s by %s in %s" % [submission.problem.name, submission.user.username, submission.problem.language]) | ||
|
||
comment_history = if current_user.guest? || !$flipper[:comment_history].enabled?(current_user) | ||
[] | ||
else | ||
current_user.comments.recent(25) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every time an user checks a submission a query like this will be triggered, let's keep an eye on performance issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new index should theoretically make this perform well, but it wouldn't hurt to check after its release. @kytrinyx Does Heroku provide you database load metrics? |
||
end | ||
|
||
locals = { | ||
submission: submission, | ||
comment_history: comment_history, | ||
own_uuid: submission.exercise_uuid_by(current_user), | ||
} | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class IndexCommentsByUserId < ActiveRecord::Migration | ||
def change | ||
add_index :comments, [:user_id, :updated_at] | ||
end | ||
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.
May I suggest an structure like
lib/flipper/comment_history.rb
?This class would be initialized with the current user and flipper and it would be easy to test. Another benefit is that it would be easy to remove this feature in the future. Future toggle features would also be easily spotted since they would all be located in the same folder.
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.
If I follow you, you mean something like…
I'm not convinced for this particular scenario yet, but I want to make sure I understand what you're suggesting too. There are several non-user-visible changes that aren't turned off by the feature flag (e.g. schema changes, plumbing locals through erb views, coffeescript classes that are defined but unused) that it seems like, at least with how I implemented most of these features, that I don't feel like it would be easier or less complex to remove. Easier to test… I could be convinced that's true.
I'd love to hear about some examples where this approach has helped you. I assume it has, or I bet you wouldn't be suggesting it. 😄
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 main benefit was being able to test that the data returned for a feature was correct/expected, same when the feature was not enabled. If I remember correctly I also made something like
current_user.feature?(:my_feature)
which returned the appropriate permission for an user or a guest. Not really saying this would work in exercism context though, just sharing experiences. 😄The presentation layer is always complicated, I relied on presenters to do the trick when the feature changed the presentation layer too much, but in this case I think it would be overkill. 🤔
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.
@bernardoamc Cool. I actually think that makes a lot of sense, especially when you're replacing one implementation with another. If you can extract the behavior into its own class, then you can duplicate that class and modify it to be the new behavior, and switch between implementations using a feature flag. Is that along the lines of what you're thinking? It wouldn't even necessarily need to go in a separate Flipper module namespace.
If the behavior/output of both implementations is intended to be the same, the scientist gem is also particularly helpful.