Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/dashboard_event_filters' of dev.gitlabhq.com:gi…
…tlabhq
- Loading branch information
Showing
11 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,68 @@ | ||
class EventFilter | ||
attr_accessor :params | ||
|
||
class << self | ||
def default_filter | ||
%w{ push issues merge_requests team} | ||
end | ||
|
||
def push | ||
'push' | ||
end | ||
|
||
def merged | ||
'merged' | ||
end | ||
|
||
def comments | ||
'comments' | ||
end | ||
|
||
def team | ||
'team' | ||
end | ||
end | ||
|
||
def initialize params | ||
@params = if params | ||
params.dup | ||
else | ||
[]#EventFilter.default_filter | ||
end | ||
end | ||
|
||
def apply_filter events | ||
return events unless params.present? | ||
|
||
filter = params.dup | ||
|
||
actions = [] | ||
actions << Event::Pushed if filter.include? 'push' | ||
actions << Event::Merged if filter.include? 'merged' | ||
|
||
if filter.include? 'team' | ||
actions << Event::Joined | ||
actions << Event::Left | ||
end | ||
|
||
actions << Event::Commented if filter.include? 'comments' | ||
|
||
events = events.where(action: actions) | ||
end | ||
|
||
def options key | ||
filter = params.dup | ||
|
||
if filter.include? key | ||
filter.delete key | ||
else | ||
filter << key | ||
end | ||
|
||
filter | ||
end | ||
|
||
def active? key | ||
params.include? key | ||
end | ||
end |
8b489ba
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,
Did you see this issue: https://github.com/gitlabhq/gitlabhq/issues/1888
How hard is this to implement?