Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4280575f
Commit
4280575f
authored
May 30, 2016
by
DJ Mountney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move filtering todos by projects not pending deletion into a scope on the todo model
parent
4ecc10fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
7 deletions
+2
-7
app/finders/todos_finder.rb
app/finders/todos_finder.rb
+1
-7
app/models/todo.rb
app/models/todo.rb
+1
-0
No files found.
app/finders/todos_finder.rb
View file @
4280575f
...
@@ -23,13 +23,7 @@ class TodosFinder
...
@@ -23,13 +23,7 @@ class TodosFinder
end
end
def
execute
def
execute
items
=
current_user
.
todos
items
=
current_user
.
todos
.
not_pending_delete
# Filter out todos linked to project pending deletion
items
=
items
.
joins
(
'INNER JOIN projects ON projects.id = todos.project_id AND projects.pending_delete = false'
)
items
=
by_action_id
(
items
)
items
=
by_action_id
(
items
)
items
=
by_author
(
items
)
items
=
by_author
(
items
)
items
=
by_project
(
items
)
items
=
by_project
(
items
)
...
...
app/models/todo.rb
View file @
4280575f
...
@@ -19,6 +19,7 @@ class Todo < ActiveRecord::Base
...
@@ -19,6 +19,7 @@ class Todo < ActiveRecord::Base
scope
:pending
,
->
{
with_state
(
:pending
)
}
scope
:pending
,
->
{
with_state
(
:pending
)
}
scope
:done
,
->
{
with_state
(
:done
)
}
scope
:done
,
->
{
with_state
(
:done
)
}
scope
:not_pending_delete
,
->
{
joins
(
'INNER JOIN projects ON projects.id = todos.project_id AND projects.pending_delete = false'
)
}
state_machine
:state
,
initial: :pending
do
state_machine
:state
,
initial: :pending
do
event
:done
do
event
:done
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment