-
-
Save timurvafin/e5dc2cb7da5dae394229 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
scope :complete, ->(value) { where(summary_status: 'complete', state: 'active').limit(value) } | |
scope :by_user, ->(user) do | |
includes(:assignee_tasks) | |
.where('tasks.user_id = :user_id OR assignee_tasks.user_id = :user_id', user_id: user.id) | |
end | |
scope :by_state, ->(state) do | |
includes(:assignee_tasks) | |
.where('tasks.state = :state OR assignee_tasks.state = :state', state: state) | |
end | |
scope :accessible_by_user_with_state, ->(user, state) do | |
by_user(user) | |
.by_state(state) | |
end | |
scope :accessible_to_update, ->(user) do | |
.by_user(user) | |
.where('assignee_tasks.status != :status', status: 'visible') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment