-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12464 from rubhanazeem/new-watchlist-api
Implement New Watchlist API
- Loading branch information
Showing
8 changed files
with
207 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class WatchlistFinder | ||
def initialize(relation = WatchedItem.all) | ||
@relation = relation | ||
end | ||
|
||
def watchlist_projects(user) | ||
@relation.includes(:watchable).where(user: user, watchable_type: 'Project').collect(&:watchable) | ||
end | ||
|
||
def watchlist_packages(user) | ||
@relation.includes(:watchable).where(user: user, watchable_type: 'Package').collect(&:watchable) | ||
end | ||
|
||
def watchlist_requests(user) | ||
@relation.includes(:watchable).where(user: user, watchable_type: 'BsRequest').collect(&:watchable) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
builder.watchlist do | ||
WatchlistFinder.new.watchlist_projects(my_model).each do |project| | ||
builder.project(name: project.name) | ||
end | ||
WatchlistFinder.new.watchlist_packages(my_model).each do |package| | ||
builder.package(name: package.name, project: package.project.name) | ||
end | ||
WatchlistFinder.new.watchlist_requests(my_model).each do |request| | ||
builder.request(number: request.number) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters