-
Notifications
You must be signed in to change notification settings - Fork 5
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
Views methods #41
base: master
Are you sure you want to change the base?
Views methods #41
Conversation
@@ -13,13 +13,11 @@ | |||
//= require jquery | |||
//= require jquery_ujs | |||
//= require turbolinks | |||
|
|||
// | |||
//= require_tree . |
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.
Still not needed
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 remove those lines linking between administration tabs will not work. Also, I do use datatables, that's why it is there.
I think that this is ready to merge, please review @alexvkcr @agarciavera @sebjimenez @sergio-ocon @delaluzparra |
@sergio-ocon Please check my proposal for the view using datatables in the "Horarios" view in the main navbar menu. It is responsive and columns expand depending on contens, so empty days columns are not as wide as days that have class. |
def user_0_offspr_count | ||
count = 0 | ||
User.all.each do |u| | ||
count += 1 if u.no_offspring? |
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.
u.offsprings.empty?
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.
Creating a joint view and then using
User.select(:offspring_id).distinct.count
will be more efficient
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.
User.count - User.joins(:offsprings).uniq.count
gives you the number of Users without offspring in 0.7 ms
@alexvkcr @agarciavera @sebjimenez @sergio-ocon @delaluzparra |
439992e
to
0ff95d7
Compare
fa11f4a
to
cc3b530
Compare
ad2f646
to
4fd7116
Compare
@alexvkcr @agarciavera @sebjimenez @sergio-ocon Please review asap. |
LGTM @sergio-ocon |
Every PR needs to have tests |
@@ -17,4 +17,12 @@ class User < ActiveRecord::Base | |||
validates :phone, format: { with: VALID_TELEPHONE_REGEX} | |||
# The offspring need to have a parent, they will be destroyed if the parent is | |||
has_many :offsprings, dependent: :destroy | |||
|
|||
def no_offspring? | |||
offsprings.empty? || offsprings.count.zero? |
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.
?
Purpose
Finished adding methods for the dashboard views. They allow the admin to see:
@katafira @agarciavera @sebjimenez @sergio-ocon @delaluzparra