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
Adds invitations_counter cache for triggering the number of invitations ... #425
Conversation
Adds invitations_counter cache for triggering the number of invitations ...
@scambra how do you feel about adding a flag for this? |
@kurenn, what rails version are you using? are you using polymorphic invite_by or did you set invited_by_class_name? |
…ss_name is set and invitations_count column is present, related to #425
I used the polymorphic one. On 10 February 2014 04:48, Sergio Cambra notifications@github.com wrote:
Abraham Kuri Vargas |
@@ -7,6 +7,8 @@ def up | |||
t.datetime :invitation_accepted_at | |||
t.integer :invitation_limit | |||
t.references :invited_by, :polymorphic => true | |||
t.integer :invitations_count, default: 0 | |||
t.index :invitations_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.
Why do you need an index on invitations_count
? Do you query users somewhere based only on invitation counts? And even if you do, the index doesn't seem selective enough.
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.
Yeah, I queried users based on that and displaying it on a view. I made it as a preventive matter if I recall correctly
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 doubt if the majority of people use it for that purpose (some kind of leaderboard), and it would lie as an unused index in their table. I personally think that this index does not belong to the gem migration but should be added separately (in their own migration) if someone needs that kind of functionality.
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.
You may be right, and probably is a better idea to have the index on a separate migration file, in case someone needs 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.
Created a PR: #830
This seems useful for optimization purposes, I'm using it on a project of mine! works pretty good.
Great gem by the way!