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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b5db5413
Commit
b5db5413
authored
Feb 12, 2013
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All scopes must be in lambdas
parent
9a22ac63
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
22 deletions
+22
-22
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-3
app/models/event.rb
app/models/event.rb
+2
-2
app/models/milestone.rb
app/models/milestone.rb
+2
-2
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/note.rb
app/models/note.rb
+2
-2
app/models/project.rb
app/models/project.rb
+1
-1
app/models/snippet.rb
app/models/snippet.rb
+3
-3
app/models/user.rb
app/models/user.rb
+4
-4
app/models/users_project.rb
app/models/users_project.rb
+4
-4
No files found.
app/models/concerns/issuable.rb
View file @
b5db5413
...
@@ -19,12 +19,12 @@ module Issuable
...
@@ -19,12 +19,12 @@ module Issuable
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:closed
,
inclusion:
{
in:
[
true
,
false
]
}
validates
:closed
,
inclusion:
{
in:
[
true
,
false
]
}
scope
:opened
,
where
(
closed:
false
)
scope
:opened
,
->
{
where
(
closed:
false
)
}
scope
:closed
,
where
(
closed:
true
)
scope
:closed
,
->
{
where
(
closed:
true
)
}
scope
:of_group
,
->
(
group
)
{
where
(
project_id:
group
.
project_ids
)
}
scope
:of_group
,
->
(
group
)
{
where
(
project_id:
group
.
project_ids
)
}
scope
:of_user_team
,
->
(
team
)
{
where
(
project_id:
team
.
project_ids
,
assignee_id:
team
.
member_ids
)
}
scope
:of_user_team
,
->
(
team
)
{
where
(
project_id:
team
.
project_ids
,
assignee_id:
team
.
member_ids
)
}
scope
:assigned
,
->
(
u
)
{
where
(
assignee_id:
u
.
id
)}
scope
:assigned
,
->
(
u
)
{
where
(
assignee_id:
u
.
id
)}
scope
:recent
,
order
(
"created_at DESC"
)
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
delegate
:name
,
delegate
:name
,
:email
,
:email
,
...
...
app/models/event.rb
View file @
b5db5413
...
@@ -42,8 +42,8 @@ class Event < ActiveRecord::Base
...
@@ -42,8 +42,8 @@ class Event < ActiveRecord::Base
serialize
:data
serialize
:data
# Scopes
# Scopes
scope
:recent
,
order
(
"created_at DESC"
)
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
scope
:code_push
,
where
(
action:
Pushed
)
scope
:code_push
,
->
{
where
(
action:
Pushed
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
class
<<
self
class
<<
self
...
...
app/models/milestone.rb
View file @
b5db5413
...
@@ -20,8 +20,8 @@ class Milestone < ActiveRecord::Base
...
@@ -20,8 +20,8 @@ class Milestone < ActiveRecord::Base
has_many
:issues
has_many
:issues
has_many
:merge_requests
has_many
:merge_requests
scope
:active
,
where
(
closed:
false
)
scope
:active
,
->
{
where
(
closed:
false
)
}
scope
:closed
,
where
(
closed:
true
)
scope
:closed
,
->
{
where
(
closed:
true
)
}
validates
:title
,
presence:
true
validates
:title
,
presence:
true
validates
:project
,
presence:
true
validates
:project
,
presence:
true
...
...
app/models/namespace.rb
View file @
b5db5413
...
@@ -29,7 +29,7 @@ class Namespace < ActiveRecord::Base
...
@@ -29,7 +29,7 @@ class Namespace < ActiveRecord::Base
after_update
:move_dir
after_update
:move_dir
after_destroy
:rm_dir
after_destroy
:rm_dir
scope
:root
,
where
(
'type IS NULL'
)
scope
:root
,
->
{
where
(
'type IS NULL'
)
}
def
self
.
search
query
def
self
.
search
query
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
...
...
app/models/note.rb
View file @
b5db5413
...
@@ -43,8 +43,8 @@ class Note < ActiveRecord::Base
...
@@ -43,8 +43,8 @@ class Note < ActiveRecord::Base
# Scopes
# Scopes
scope
:for_commit_id
,
->
(
commit_id
)
{
where
(
noteable_type:
"Commit"
,
commit_id:
commit_id
)
}
scope
:for_commit_id
,
->
(
commit_id
)
{
where
(
noteable_type:
"Commit"
,
commit_id:
commit_id
)
}
scope
:inline
,
where
(
"line_code IS NOT NULL"
)
scope
:inline
,
->
{
where
(
"line_code IS NOT NULL"
)
}
scope
:not_inline
,
where
(
"line_code IS NULL"
)
scope
:not_inline
,
->
{
where
(
"line_code IS NULL"
)
}
scope
:common
,
->
{
where
(
noteable_type:
[
""
,
nil
])
}
scope
:common
,
->
{
where
(
noteable_type:
[
""
,
nil
])
}
scope
:fresh
,
->
{
order
(
"created_at ASC, id ASC"
)
}
scope
:fresh
,
->
{
order
(
"created_at ASC, id ASC"
)
}
...
...
app/models/project.rb
View file @
b5db5413
...
@@ -91,7 +91,7 @@ class Project < ActiveRecord::Base
...
@@ -91,7 +91,7 @@ class Project < ActiveRecord::Base
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:public
,
where
(
public:
true
)
scope
:public
,
->
{
where
(
public:
true
)
}
class
<<
self
class
<<
self
def
abandoned
def
abandoned
...
...
app/models/snippet.rb
View file @
b5db5413
...
@@ -31,9 +31,9 @@ class Snippet < ActiveRecord::Base
...
@@ -31,9 +31,9 @@ class Snippet < ActiveRecord::Base
validates
:content
,
presence:
true
validates
:content
,
presence:
true
# Scopes
# Scopes
scope
:fresh
,
order
(
"created_at DESC"
)
scope
:fresh
,
->
{
order
(
"created_at DESC"
)
}
scope
:non_expired
,
where
([
"expires_at IS NULL OR expires_at > ?"
,
Time
.
current
])
scope
:non_expired
,
->
{
where
([
"expires_at IS NULL OR expires_at > ?"
,
Time
.
current
])
}
scope
:expired
,
where
([
"expires_at IS NOT NULL AND expires_at < ?"
,
Time
.
current
])
scope
:expired
,
->
{
where
([
"expires_at IS NOT NULL AND expires_at < ?"
,
Time
.
current
])
}
def
self
.
content_types
def
self
.
content_types
[
[
...
...
app/models/user.rb
View file @
b5db5413
...
@@ -87,10 +87,10 @@ class User < ActiveRecord::Base
...
@@ -87,10 +87,10 @@ class User < ActiveRecord::Base
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
# Scopes
# Scopes
scope
:admins
,
where
(
admin:
true
)
scope
:admins
,
->
{
where
(
admin:
true
)
}
scope
:blocked
,
where
(
blocked:
true
)
scope
:blocked
,
->
{
where
(
blocked:
true
)
}
scope
:active
,
where
(
blocked:
false
)
scope
:active
,
->
{
where
(
blocked:
false
)
}
scope
:alphabetically
,
order
(
'name ASC'
)
scope
:alphabetically
,
->
{
order
(
'name ASC'
)
}
scope
:in_team
,
->
(
team
){
where
(
id:
team
.
member_ids
)
}
scope
:in_team
,
->
(
team
){
where
(
id:
team
.
member_ids
)
}
scope
:not_in_team
,
->
(
team
){
where
(
'users.id NOT IN (:ids)'
,
ids:
team
.
member_ids
)
}
scope
:not_in_team
,
->
(
team
){
where
(
'users.id NOT IN (:ids)'
,
ids:
team
.
member_ids
)
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
...
...
app/models/users_project.rb
View file @
b5db5413
...
@@ -32,10 +32,10 @@ class UsersProject < ActiveRecord::Base
...
@@ -32,10 +32,10 @@ class UsersProject < ActiveRecord::Base
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
scope
:guests
,
where
(
project_access:
GUEST
)
scope
:guests
,
->
{
where
(
project_access:
GUEST
)
}
scope
:reporters
,
where
(
project_access:
REPORTER
)
scope
:reporters
,
->
{
where
(
project_access:
REPORTER
)
}
scope
:developers
,
where
(
project_access:
DEVELOPER
)
scope
:developers
,
->
{
where
(
project_access:
DEVELOPER
)
}
scope
:masters
,
where
(
project_access:
MASTER
)
scope
:masters
,
->
{
where
(
project_access:
MASTER
)
}
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:in_projects
,
->
(
projects
)
{
where
(
project_id:
project_ids
)
}
scope
:in_projects
,
->
(
projects
)
{
where
(
project_id:
project_ids
)
}
...
...
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