-
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.
Support new watchlist format in persons endpoint and add new endpoints
Persons get info and put info has been updated to support new watchlist format. New endpoints to get and update watchlist are also added Signed-off-by: Rubhan Azeem <rubhanazeem@gmail.com>
- Loading branch information
1 parent
778823d
commit ebcd12f
Showing
7 changed files
with
129 additions
and
30 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