-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Followable #1727
Followable #1727
Conversation
@@ -95,9 +95,8 @@ | |||
create_table "budget_ballots", force: :cascade do |t| | |||
t.integer "user_id" | |||
t.integer "budget_id" | |||
t.datetime "created_at", null: false | |||
t.datetime "updated_at", null: false | |||
t.integer "ballot_lines_count", default: 0 |
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 👍 , I messed up somehow on a PR and didn't realize it. I added this on a feature branch that is still on PR stage https://github.com/consul/consul/pull/1712/files#diff-ddcb0cf5e4dfc6ac0c06b85bac771760 My apologies >_< 🙇
@@ -25,8 +25,8 @@ def account_params | |||
if @account.organization? | |||
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name]) | |||
else | |||
params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge) | |||
params.require(:account).permit(:username, :public_activity, :public_interest, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge) |
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.
@bertocq maybe public_interest should be public_interests?
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.
+1 Yes it sounds more descriptive, right? Feature is "User can mark his interests as public." so plural makes sense.
app/models/follow.rb
Outdated
@@ -0,0 +1,31 @@ | |||
class Follow < ActiveRecord::Base | |||
belongs_to :user | |||
#TODO Rock&RoR: Check touch usage on cache system |
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.
@taitus We have to do the check, fix if necessary and remove the comment.
@@ -0,0 +1,31 @@ | |||
class Follow < ActiveRecord::Base | |||
belongs_to :user |
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.
I think a cool improvement here (even if there is no actual use on the code right now) would have been to use a counter_cache
Something like belongs_to :user, counter_cache: :following_count
Without forgetting the migration:
add_column :users, :following_count, :integer, default: 0
add_index :users, :following_count
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.
Don't worry about adding this, seems like there is no actual usage not even reason to. On the mockups there is nowhere to use it (only individual Followable counts) so when that time comes we'll add it if @decabeza thinks it makes sense to put a global following count 👍 .
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.
Because of that we do not have implemented it. Yes, maybe is a YAGNI thing for now.
app/models/follow.rb
Outdated
class Follow < ActiveRecord::Base | ||
belongs_to :user | ||
#TODO Rock&RoR: Check touch usage on cache system | ||
belongs_to :followable, polymorphic: true |
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.
I think here the counter_cache
usage I suggested for the belongs_to :user
would actually be used, so its more like a performance improvement for any @investment.follows.count
or @proposal.follows.count
around. What do you think about naming it "followers_count" twitter-style? 😄
app/models/follow.rb
Outdated
!! by_user_and_followable(user, followable).try(:first) | ||
end | ||
|
||
def self.interests_by(user) |
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.
What do you think about using a symbol proc and { |item| .. } syntax to make function body smaller? It would be something like user.follows.map { |follow| follow.followable.tags.map(&:name) }.flatten.compact.uniq
(the entire function body)
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.
As we commented, this method could make more sense in the User model, to be used as user.interests
<div class="callout primary text-center"> | ||
<%= t('follows.no_followers') %> | ||
</div> | ||
<% 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.
Adding here an else
and including inside it the following .each
loop could maybe be safer?
@@ -170,6 +171,10 @@ def notifications | |||
proposal_notifications | |||
end | |||
|
|||
def users_to_notify |
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.
Maybe increasing proposal model spec to check this new method, just reusing existing spec for voters
could be a nice test improvement https://github.com/rockandror/consul/blob/followable/spec/models/proposal_spec.rb#L382-L425
@@ -166,8 +166,8 @@ | |||
end | |||
|
|||
trait :flagged do | |||
after :create do |debate| |
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.
Nice catch! 👍
@@ -0,0 +1,182 @@ | |||
shared_examples "followable" do |followable_class_name, followable_path, followable_path_arguments| |
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.
Really like the usage of shared_examples 👏 😊
@@ -5,6 +5,7 @@ | |||
require 'knapsack' | |||
Dir["./spec/models/concerns/*.rb"].each { |f| require f } | |||
Dir["./spec/support/**/*.rb"].sort.each { |f| require f } | |||
Dir["./spec/shared/**/*.rb"].sort.each { |f| require f } |
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.
Seems like we have 4 shared_examples for concerns, but they are across 3 different subfolder 🙈 . I'll correct this afterwards don't worry :). IMHO /spec/models/concerns/
should be the path for a concern shared_example
…d proposals pages when user is not logged.
…ements renderization. Add whitespace to proposal page.
c21cb0a
to
f5e8789
Compare
…sts. Add specification to check the discard of duplicate interests.
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.
👏 !!
…sign UI design
Where
What
How
Screenshots
1. Follow button - Mobile
2. Follow button - Tablet
3. Follow button - Desktop
4. Public interest check on user account
5. Interest list on user profile
Test
Deployment
Warnings