-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Functional tests for sorting on the /people page #9589
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9589 +/- ##
=======================================
Coverage ? 49.41%
=======================================
Files ? 98
Lines ? 6122
Branches ? 0
=======================================
Hits ? 3025
Misses ? 3097
Partials ? 0 |
@jywarren @cesswairimu some observations that I made from this PR. |
get :list, params: { sort: 'last_activity' } | ||
|
||
assert_response :success | ||
assert assigns(:users).each_cons(2).all?{|i,j| "i.updated_at" >= "j.updated_at" } |
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.
Thanks for working on this @Manasa2850. With the test at line 316 and 323, should the signs >=
be the inverse of each other? If alphabetical and ascending, then the i should be lower than the j? j.node_revisions.username" <= "i.node_revisions.username"
And for the last activity in descending order, it does make sense for the to be greater than j as you have written..
I haven't worked with that kind of comparison before, please let me know if what I am saying does not make sense.
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.
@RuthNjeri since we want the username to be sorted in ascending order, I've written j.node_revisions.username" >= "i.node_revisions.username
where j
refers to the second entry and i
to the first one.
In line 323 it is i.updated_at" >= "j.updated_at
which is the same as j.updated_at" <= "i.updated_at
and is the reverse of what is there in line 316.
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.
Oh, I see, I think I missed the I and j difference, thanks for the clarification.
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.
@Manasa2850 Maybe here we can try with i.node_revisions.maximum("timestamp")
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.
Sure I'll try that out!
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.
@Tlazypanda it shows the same result Expected false to be truthy
and the test passes on interchanging the values of i
and j
.
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.
hey @Manasa2850, I think removing the quotes around the comparison assert assigns(:users).each_cons(2).all?{|i,j| i.updated_at >= j.updated_at }
might solve this, since its a time comparison. Thanks
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.
Thanks @cesswairimu! That worked 🎉
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.
great 🎉 🎉
@@ -106,7 +106,7 @@ def list | |||
if sort_param == 'username' | |||
order_string = 'username ASC' | |||
elsif sort_param == 'last_activity' | |||
order_string = 'last_updated DESC' | |||
order_string = 'updated_at DESC' |
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.
@Manasa2850 I am not too sure switching this to updated_at
fixes the problem. The updated_at
is related to the user details I think, and the last_updated
is related to the user's activities.
I could be wrong but that's something you want to confirm, when is the last_updated
changed and what changes affect the updated_at
in Rails, the updated_at
is a default column that updates the timestamp when the user details changes in the other columns which might be unrelated to the changes detected by the last_updated
which might be looking at when a user was last active on the site.
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.
@RuthNjeri I think you're right with respect to the updated_at
column reflecting the timestamp when changes are made in other columns.
I don't find a column called last_updated
in the User table so I'm not really sure how that's working.
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.
@Manasa2850 they are fetching it in line 137 as an alias for the most recently updated node for that 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.
Ohh I missed that. Thanks @Tlazypanda! 😃
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 you need some input or more problem solving please reach out in chat! Thanks everyone for working together on this one!
Code Climate has analyzed commit 3cabaf8 and detected 0 issues on this pull request. View more on Code Climate. |
get :list, params: { sort: 'last_activity' } | ||
|
||
assert_response :success | ||
assert assigns(:users).each_cons(2).all?{|i,j| i.updated_at >= j.updated_at } |
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 test looks amiss though, because we want to order by node_revisions last updated right?
but this looks like its looking at users table last updated_at ..I will pull locally and try to find a work around and revert
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.
Hey @cesswairimu @Manasa2850 any more activity here? please let me know how I can help 😅 I see the tests are now passing
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.
oh, the test was a bit off, might need to rewrite... this skipped my mind...will check it out soon...thanks @Tlazypanda ❤️
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 believe @Manasa2850 is overloaded a bit but will be back online very soon, so this can hold for a bit! Thanks!
Hi 😄, this issue has been automatically marked as stale because it has not had recent activity. Don't worry you can continue to work on this and ask @publiclab/reviewers to add |
Partially Fixes #9411 (<=== Add issue number here)
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Thanks!