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
74626106
Commit
74626106
authored
Sep 14, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: perf
parent
2110989f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
17 deletions
+20
-17
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-0
app/models/cycle_analytics/queries.rb
app/models/cycle_analytics/queries.rb
+2
-2
db/fixtures/development/17_cycle_analytics.rb
db/fixtures/development/17_cycle_analytics.rb
+15
-15
No files found.
app/models/concerns/issuable.rb
View file @
74626106
...
@@ -28,6 +28,9 @@ module Issuable
...
@@ -28,6 +28,9 @@ module Issuable
loaded?
&&
to_a
.
all?
{
|
note
|
note
.
association
(
:award_emoji
).
loaded?
}
loaded?
&&
to_a
.
all?
{
|
note
|
note
.
association
(
:award_emoji
).
loaded?
}
end
end
end
end
has_many
:system_notes
,
->
{
merge
(
Note
.
system
)
},
class_name:
Note
,
as: :noteable
,
inverse_of: :noteable
has_many
:label_links
,
as: :target
,
dependent: :destroy
has_many
:label_links
,
as: :target
,
dependent: :destroy
has_many
:labels
,
through: :label_links
has_many
:labels
,
through: :label_links
has_many
:todos
,
as: :target
,
dependent: :destroy
has_many
:todos
,
as: :target
,
dependent: :destroy
...
...
app/models/cycle_analytics/queries.rb
View file @
74626106
...
@@ -2,7 +2,7 @@ class CycleAnalytics
...
@@ -2,7 +2,7 @@ class CycleAnalytics
module
Queries
module
Queries
class
<<
self
class
<<
self
def
issues
(
project
,
created_after
:)
def
issues
(
project
,
created_after
:)
project
.
issues
.
where
(
"created_at >= ?"
,
created_after
).
map
{
|
issue
|
{
issue:
issue
}
}
project
.
issues
.
where
(
"created_at >= ?"
,
created_after
).
preload
(
:metrics
,
:system_notes
).
map
{
|
issue
|
{
issue:
issue
}
}
end
end
def
merge_requests_closing_issues
(
project
,
options
=
{})
def
merge_requests_closing_issues
(
project
,
options
=
{})
...
@@ -29,7 +29,7 @@ class CycleAnalytics
...
@@ -29,7 +29,7 @@ class CycleAnalytics
def
issue_first_mentioned_in_commit_at
def
issue_first_mentioned_in_commit_at
lambda
do
|
data_point
|
lambda
do
|
data_point
|
issue
=
data_point
[
:issue
]
issue
=
data_point
[
:issue
]
commits_mentioning_issue
=
issue
.
notes
.
system
.
map
{
|
note
|
note
.
all_references
.
commits
}.
flatten
commits_mentioning_issue
=
issue
.
system_notes
.
map
{
|
note
|
note
.
all_references
.
commits
}.
flatten
commits_mentioning_issue
.
map
(
&
:committed_date
).
min
if
commits_mentioning_issue
.
present?
commits_mentioning_issue
.
map
(
&
:committed_date
).
min
if
commits_mentioning_issue
.
present?
end
end
end
end
...
...
db/fixtures/development/17_cycle_analytics.rb
View file @
74626106
require
'sidekiq/testing'
require
'sidekiq/testing'
class
Gitlab::Seeder::CycleAnalytics
class
Gitlab::Seeder::CycleAnalytics
def
initialize
(
project
)
def
initialize
(
project
,
perf:
false
)
@project
=
project
@project
=
project
@user
=
User
.
find
(
1
)
@user
=
User
.
find
(
1
)
@issue_count
=
perf
?
1000
:
5
stub_git_pre_receive!
stub_git_pre_receive!
end
end
...
@@ -27,32 +28,26 @@ class Gitlab::Seeder::CycleAnalytics
...
@@ -27,32 +28,26 @@ class Gitlab::Seeder::CycleAnalytics
# Stage 1
# Stage 1
Timecop
.
travel
5
.
days
.
from_now
Timecop
.
travel
5
.
days
.
from_now
add_milestones_and_list_labels
(
issues
)
add_milestones_and_list_labels
(
issues
)
Timecop
.
return
# Stage 2
# Stage 2
Timecop
.
travel
10
.
days
.
from_now
Timecop
.
travel
5
.
days
.
from_now
branches
=
mention_in_commits
(
issues
)
branches
=
mention_in_commits
(
issues
)
Timecop
.
return
# Stage 3
# Stage 3
Timecop
.
travel
1
5
.
days
.
from_now
Timecop
.
travel
5
.
days
.
from_now
merge_requests
=
create_merge_requests_closing_issues
(
issues
,
branches
)
merge_requests
=
create_merge_requests_closing_issues
(
issues
,
branches
)
Timecop
.
return
# Stage 4
# Stage 4
Timecop
.
travel
20
.
days
.
from_now
Timecop
.
travel
5
.
days
.
from_now
run_builds
(
merge_requests
)
run_builds
(
merge_requests
)
Timecop
.
return
# Stage 5
# Stage 5
Timecop
.
travel
2
5
.
days
.
from_now
Timecop
.
travel
5
.
days
.
from_now
merge_merge_requests
(
merge_requests
)
merge_merge_requests
(
merge_requests
)
Timecop
.
return
# Stage 6 / 7
# Stage 6 / 7
Timecop
.
travel
30
.
days
.
from_now
Timecop
.
travel
5
.
days
.
from_now
deploy_to_production
(
merge_requests
)
deploy_to_production
(
merge_requests
)
Timecop
.
return
end
end
print
'.'
print
'.'
...
@@ -61,7 +56,7 @@ class Gitlab::Seeder::CycleAnalytics
...
@@ -61,7 +56,7 @@ class Gitlab::Seeder::CycleAnalytics
private
private
def
create_issues
(
project
)
def
create_issues
(
project
)
Array
.
new
(
5
)
do
Array
.
new
(
@issue_count
)
do
issue_params
=
{
issue_params
=
{
title:
"Cycle Analytics:
#{
FFaker
::
Lorem
.
sentence
(
6
)
}
"
,
title:
"Cycle Analytics:
#{
FFaker
::
Lorem
.
sentence
(
6
)
}
"
,
description:
FFaker
::
Lorem
.
sentence
,
description:
FFaker
::
Lorem
.
sentence
,
...
@@ -166,8 +161,13 @@ class Gitlab::Seeder::CycleAnalytics
...
@@ -166,8 +161,13 @@ class Gitlab::Seeder::CycleAnalytics
end
end
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
Project
.
all
.
each
do
|
project
|
if
ENV
[
'SEED_CYCLE_ANALYTICS'
]
seeder
=
Gitlab
::
Seeder
::
CycleAnalytics
.
new
(
project
)
seeder
=
Gitlab
::
Seeder
::
CycleAnalytics
.
new
(
Project
.
find
(
1
))
seeder
.
seed!
elsif
ENV
[
'CYCLE_ANALYTICS_PERF_TEST'
]
seeder
=
Gitlab
::
Seeder
::
CycleAnalytics
.
new
(
Project
.
first
,
perf:
true
)
seeder
.
seed!
seeder
.
seed!
else
puts
"Not running the cycle analytics seed file. Use the `SEED_CYCLE_ANALYTICS` environment variable to enable it."
end
end
end
end
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