Add collaborative repositories to the dashboard#2205
Conversation
|
LGTM |
|
LGTM |
|
One more thing - integration test for this would be great |
There was a problem hiding this comment.
This will match all collaborative repos, even ones that do not match the other options (e.g. opts.Private, opts.Keyword, ...)
There was a problem hiding this comment.
It might be time to add an options type for this function. If I see something like retrieveFeeds(ctx, ctxUser, true, false, true, false), I'll have no idea what it means without further investigating.
We could also reuse the GetFeedsOptions type instead of introducing a new options type, since most of the current argument map directly to GetFeedsOptions fields.
|
Make LG-TM work |
There was a problem hiding this comment.
This will drop other conditions like opts.IncludeDeleted. I think this method should refactor via builder otherwise it's still not correct.
6de7ed7 to
47e8494
Compare
|
Fixed |
There was a problem hiding this comment.
I mean maybe we should move these 3 lines to line 737 ?
if opts.Collaborate {
cond = builder.Eq{"user_id": opts.RequestedUser.ID}.Or(
builder.Expr(`repo_id IN (SELECT repo_id FROM "access" WHERE access.user_id = ?)`, opts.RequestedUser.ID)
)
} else {
cond = builder.Eq{"user_id": opts.RequestedUser.ID}
}|
@Bwko do you have time to fix this PR? |
|
@lunny Done |
There was a problem hiding this comment.
Put this line to the end of the function is perfect.
There was a problem hiding this comment.
This is still not correct. This will match repos that do not match the opts.Starred or opts.OwnerID options.
Apologies if I wasn't clear in my previous comment. Instead of relisting all the other conditions (which is fragile if we add more options), I think we should do something like
// compute ownerIds, existing code up to line 154 is fine
searcherReposCond := builder.In("owner_id", ownerIds)
if opts.Collaborate {
searcherReposCond.Or(builder.Expr(`id IN (SELECT repo_id FROM "access" WHERE access.user_id = ? AND owner_id != ?)`, opts.Searcher.ID, opts.Searcher.ID)
}
cond.And(searcherReposCond)
There was a problem hiding this comment.
But some bug
searcherReposCond := builder.In("owner_id", ownerIds)
if opts.Collaborate {
searcherReposCond = searcherReposCond.Or(builder.Expr(`id IN (SELECT repo_id FROM "access" WHERE access.user_id = ? AND owner_id != ?)`, opts.Searcher.ID, opts.Searcher.ID)
}
cond = cond.And(searcherReposCond)|
@Bwko do you have time to fix this? |
Remove some unused code from the Dashboard func
|
Trusted LGTM |
| cond = builder.Eq{"user_id": opts.RequestedUser.ID}.Or( | ||
| builder.Expr(`repo_id IN (SELECT repo_id FROM "access" WHERE access.user_id = ?)`, opts.RequestedUser.ID)) | ||
| } else { | ||
| cond = builder.Eq{"user_id": opts.RequestedUser.ID} |
There was a problem hiding this comment.
I don't think this is right. The assignments on lines 737 and 740 will overwrite the assignment on line 733.
|
@lunny @lafriks @andreynering @Bwko Hi, don't know if I am doing something wrong, but it looks like this PR actually removed all collaborative repositories instead of adding any (nice paradox :D) and doubled some feeds. Did anyone test it? |
Remove some unused code from the Dashboard func
Fixes #2114