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
b7e5f455
Commit
b7e5f455
authored
Mar 07, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: Removing the duplicated code.
parent
79cd1ca3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
48 deletions
+40
-48
app/models/network/commit.rb
app/models/network/commit.rb
+9
-0
app/models/network/graph.rb
app/models/network/graph.rb
+30
-47
app/views/graph/show.json.erb
app/views/graph/show.json.erb
+1
-1
No files found.
app/models/network/commit.rb
View file @
b7e5f455
...
@@ -26,5 +26,14 @@ module Network
...
@@ -26,5 +26,14 @@ module Network
0
0
end
end
end
end
def
parents
(
map
)
@commit
.
parents
.
map
do
|
p
|
if
map
.
include?
(
p
.
id
)
map
[
p
.
id
]
end
end
.
compact
end
end
end
end
end
app/models/network/graph.rb
View file @
b7e5f455
...
@@ -2,7 +2,7 @@ require "grit"
...
@@ -2,7 +2,7 @@ require "grit"
module
Network
module
Network
class
Graph
class
Graph
attr_reader
:days
,
:commits
attr_reader
:days
,
:commits
,
:map
def
self
.
max_count
def
self
.
max_count
@max_count
||=
650
@max_count
||=
650
...
@@ -61,10 +61,8 @@ module Network
...
@@ -61,10 +61,8 @@ module Network
end
end
commits_sort_by_ref
.
each
do
|
commit
|
commits_sort_by_ref
.
each
do
|
commit
|
if
@map
.
include?
commit
.
id
then
place_chain
(
commit
)
place_chain
(
commit
)
end
end
end
# find parent spaces for not overlap lines
# find parent spaces for not overlap lines
@commits
.
each
do
|
c
|
@commits
.
each
do
|
c
|
...
@@ -115,10 +113,7 @@ module Network
...
@@ -115,10 +113,7 @@ module Network
def
find_free_parent_spaces
(
commit
)
def
find_free_parent_spaces
(
commit
)
spaces
=
[]
spaces
=
[]
commit
.
parents
.
each
do
|
p
|
commit
.
parents
(
@map
).
each
do
|
parent
|
if
@map
.
include?
(
p
.
id
)
then
parent
=
@map
[
p
.
id
]
range
=
if
commit
.
time
<
parent
.
time
then
range
=
if
commit
.
time
<
parent
.
time
then
commit
.
time
..
parent
.
time
commit
.
time
..
parent
.
time
else
else
...
@@ -134,7 +129,6 @@ module Network
...
@@ -134,7 +129,6 @@ module Network
mark_reserved
(
range
,
space
)
mark_reserved
(
range
,
space
)
spaces
<<
space
spaces
<<
space
end
end
end
spaces
spaces
end
end
...
@@ -175,27 +169,20 @@ module Network
...
@@ -175,27 +169,20 @@ module Network
leaves
.
each
do
|
l
|
leaves
.
each
do
|
l
|
l
.
spaces
<<
space
l
.
spaces
<<
space
# Also add space to parent
# Also add space to parent
l
.
parents
.
each
do
|
p
|
l
.
parents
(
@map
).
each
do
|
parent
|
if
@map
.
include?
(
p
.
id
)
parent
=
@map
[
p
.
id
]
if
parent
.
space
>
0
if
parent
.
space
>
0
parent
.
spaces
<<
space
parent
.
spaces
<<
space
end
end
end
end
end
end
end
# and mark it as reserved
# and mark it as reserved
min_time
=
leaves
.
last
.
time
min_time
=
leaves
.
last
.
time
parents
=
leaves
.
last
.
parents
.
collect
leaves
.
last
.
parents
(
@map
).
each
do
|
parent
|
parents
.
each
do
|
p
|
if
@map
.
include?
p
.
id
parent
=
@map
[
p
.
id
]
if
parent
.
time
<
min_time
if
parent
.
time
<
min_time
min_time
=
parent
.
time
min_time
=
parent
.
time
end
end
end
end
end
if
parent_time
.
nil?
if
parent_time
.
nil?
max_time
=
leaves
.
first
.
time
max_time
=
leaves
.
first
.
time
...
@@ -206,7 +193,7 @@ module Network
...
@@ -206,7 +193,7 @@ module Network
# Visit branching chains
# Visit branching chains
leaves
.
each
do
|
l
|
leaves
.
each
do
|
l
|
parents
=
l
.
parents
.
collect
.
select
{
|
p
|
@map
.
include?
p
.
id
and
@map
[
p
.
id
]
.
space
.
zero?
}
parents
=
l
.
parents
(
@map
).
select
{
|
p
|
p
.
space
.
zero?
}
for
p
in
parents
for
p
in
parents
place_chain
(
p
,
l
.
time
)
place_chain
(
p
,
l
.
time
)
end
end
...
@@ -215,13 +202,10 @@ module Network
...
@@ -215,13 +202,10 @@ module Network
def
get_space_base
(
leaves
)
def
get_space_base
(
leaves
)
space_base
=
1
space_base
=
1
if
leaves
.
last
.
parents
.
size
>
0
parents
=
leaves
.
last
.
parents
(
@map
)
first_parent
=
leaves
.
last
.
parents
.
first
if
parents
.
size
>
0
if
@map
.
include?
(
first_parent
.
id
)
if
parents
.
first
.
space
>
0
first_p
=
@map
[
first_parent
.
id
]
space_base
=
parents
.
first
.
space
if
first_p
.
space
>
0
space_base
=
first_p
.
space
end
end
end
end
end
space_base
space_base
...
@@ -266,10 +250,9 @@ module Network
...
@@ -266,10 +250,9 @@ module Network
leaves
.
push
(
commit
)
if
commit
.
space
.
zero?
leaves
.
push
(
commit
)
if
commit
.
space
.
zero?
while
true
while
true
return
leaves
if
commit
.
parents
.
count
.
zero?
return
leaves
if
commit
.
parents
(
@map
).
count
.
zero?
return
leaves
unless
@map
.
include?
commit
.
parents
.
first
.
id
commit
=
@map
[
commit
.
parents
.
first
.
id
]
commit
=
commit
.
parents
(
@map
).
first
return
leaves
unless
commit
.
space
.
zero?
return
leaves
unless
commit
.
space
.
zero?
...
...
app/views/graph/show.json.erb
View file @
b7e5f455
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
days:
@graph
.
days
.
compact
.
map
{
|
d
|
[
d
.
day
,
d
.
strftime
(
"%b"
)]
},
days:
@graph
.
days
.
compact
.
map
{
|
d
|
[
d
.
day
,
d
.
strftime
(
"%b"
)]
},
commits:
@graph
.
commits
.
map
do
|
c
|
commits:
@graph
.
commits
.
map
do
|
c
|
{
{
parents:
parents_zip_spaces
(
c
.
parents
,
c
.
parent_spaces
),
parents:
parents_zip_spaces
(
c
.
parents
(
@graph
.
map
)
,
c
.
parent_spaces
),
author:
{
author:
{
name:
c
.
author
.
name
,
name:
c
.
author
.
name
,
email:
c
.
author
.
email
,
email:
c
.
author
.
email
,
...
...
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