-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Hide unactive on explore users and some refactors #2741
Hide unactive on explore users and some refactors #2741
Conversation
7ad18cd
to
884fdcd
Compare
Codecov Report
@@ Coverage Diff @@
## master #2741 +/- ##
==========================================
+ Coverage 26.9% 27.08% +0.17%
==========================================
Files 88 88
Lines 17289 17264 -25
==========================================
+ Hits 4652 4676 +24
+ Misses 11958 11909 -49
Partials 679 679
Continue to review full report at Codecov.
|
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.
A few minor things
models/org_test.go
Outdated
@@ -240,7 +240,8 @@ func TestCountOrganizations(t *testing.T) { | |||
func TestOrganizations(t *testing.T) { |
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 test should be moved from org_test
to user_test
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 test will only set type = UserTypeOrganization
, it's for organizations but not users. Since Users
and Organizations
share the user
table. SearchUsers
will be shared also.
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.
But it tests a function that is defined in user.go
, whereas it previously tested a function that was defined in org.go
. It is my understanding that if something is defined in XYZ.go
, its test should be in XYZ_test.go
; is my understanding incorrect?
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.
But should I rename it from TestOrganizations
to TestUsers
or just put TestOrganizations
to user_test.go
? This function logically test organizations
but SearchUsers
is shared by Users
and Organizations
although it's in user.go
. So I don't think we can obey the rule you mentioned above.
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 would suggest renaming it to TestSearchUsers
, and expanding it to test for both individual users and organizations, but you can do what you think is best.
One way or another, however, we should make sure that the SearchUsers
function is fully tested (both individual users and organizations).
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 will send another commit to do that.
models/user.go
Outdated
IsActive util.OptionalBool | ||
} | ||
|
||
func (opts *SearchUserOptions) toConds() builder.Cond { |
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.
nit: since this returns a Cond
, please call it toCond()
.
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.
@ethantkoenig For SearchUserOptions
contains not only 1 condition it should be toConds
. And builder.Cond
maybe one condition or composite conditions, so toConds
will be more suitable.
f27202c
to
c849eab
Compare
@ethantkoenig done. |
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.
Some nits, but looks good otherwise. +1 for adding the methods to OptionalBool
models/notification_test.go
Outdated
// 9 are inactive, thus notifications for user 1 and 4 is created | ||
notf := AssertExistsAndLoadBean(t, &Notification{UserID: 1, IssueID: issue.ID}).(*Notification) | ||
assert.Equal(t, NotificationStatusUnread, notf.Status) | ||
CheckConsistencyFor(t, &Issue{ID: issue.ID}) |
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.
nit: don't need to call CheckConsistencyFor(t, &Issue{ID: issue.ID})
twice, since nothing changes in between the calls. Preferably, only call at the end of the test, for consistency with other tests
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.
done.
modules/util/util.go
Outdated
return o == OptionalBoolFalse | ||
} | ||
|
||
// IsNone return true if equal to OptionalBoolFalse |
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.
OptionalBoolFalse -> OptionalBoolNone
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.
done.
models/notification_test.go
Outdated
@@ -16,8 +16,12 @@ func TestCreateOrUpdateIssueNotifications(t *testing.T) { | |||
|
|||
assert.NoError(t, CreateOrUpdateIssueNotifications(issue, 2)) | |||
|
|||
// Two watchers are inactive, thus only notification for user 10 is created | |||
notf := AssertExistsAndLoadBean(t, &Notification{UserID: 10, IssueID: issue.ID}).(*Notification) | |||
// 9 are inactive, thus notifications for user 1 and 4 is created |
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.
nit: change to // User 9 is inactive, ...
. The current version could mistakenly be interpreted as "9 users are inactive".
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.
done.
LGTM |
LGTM |
* hide unactive on explore users and some refactors * fix test for removed Organizations * fix test for removed Organizations * fix imports * fix logic bug * refactor the toConds * Rename TestOrganizations to TestSearchUsers and add tests for users * fix other tests * fix other tests * fix watchers tests * fix comments and remove unused code
Unactive user should not displayed on explore UI. This PR also reafctors
SearchUserName
toSearchUsers
.