BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
859e3dfa
Commit
859e3dfa
authored
Jan 08, 2018
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '10-4-stable-prepare-rc2' into '10-4-stable'
Prepare 10.4 RC2 release See merge request gitlab-org/gitlab-ce!16295
parents
e1b74c0b
cfd29c31
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
32 deletions
+16
-32
20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
...hedule_populate_merge_request_metrics_with_events_data.rb
+1
-31
repository.rb
lib/gitlab/git/repository.rb
+1
-1
merge_request_diff_spec.rb
...ib/gitlab/diff/file_collection/merge_request_diff_spec.rb
+14
-0
No files found.
db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
View file @
859e3dfa
...
...
@@ -15,8 +15,6 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migratio
end
def
up
merge_requests
=
MergeRequest
.
where
(
"id IN (
#{
updatable_merge_requests_union_sql
}
)"
).
reorder
(
:id
)
say
'Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs'
# It will update around 4_000_000 records in batches of 10_000 merge
# requests (running between 10 minutes) and should take around 66 hours to complete.
...
...
@@ -25,7 +23,7 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migratio
#
# More information about the updates in `PopulateMergeRequestMetricsWithEventsData` class.
#
merge_requests
.
each_batch
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
MergeRequest
.
all
.
each_batch
(
of:
BATCH_SIZE
)
do
|
relation
,
index
|
range
=
relation
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
BackgroundMigrationWorker
.
perform_in
(
index
*
10
.
minutes
,
MIGRATION
,
range
)
...
...
@@ -37,32 +35,4 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migratio
execute
"update merge_request_metrics set latest_closed_by_id = null"
execute
"update merge_request_metrics set merged_by_id = null"
end
private
# On staging:
# Planning time: 0.682 ms
# Execution time: 22033.158 ms
#
def
updatable_merge_requests_union_sql
metrics_not_exists_clause
=
'NOT EXISTS (SELECT 1 FROM merge_request_metrics WHERE merge_request_metrics.merge_request_id = merge_requests.id)'
without_metrics_data
=
<<-
SQL
.
strip_heredoc
merge_request_metrics.merged_by_id IS NULL OR
merge_request_metrics.latest_closed_by_id IS NULL OR
merge_request_metrics.latest_closed_at IS NULL
SQL
mrs_without_metrics_record
=
MergeRequest
.
where
(
metrics_not_exists_clause
)
.
select
(
:id
)
mrs_without_events_data
=
MergeRequest
.
joins
(
'INNER JOIN merge_request_metrics ON merge_requests.id = merge_request_metrics.merge_request_id'
)
.
where
(
without_metrics_data
)
.
select
(
:id
)
Gitlab
::
SQL
::
Union
.
new
([
mrs_without_metrics_record
,
mrs_without_events_data
]).
to_sql
end
end
lib/gitlab/git/repository.rb
View file @
859e3dfa
...
...
@@ -1185,7 +1185,7 @@ module Gitlab
end
# Items should be of format [[commit_id, path], [commit_id1, path1]]
def
batch_blobs
(
items
,
blob_size_limit:
nil
)
def
batch_blobs
(
items
,
blob_size_limit:
Gitlab
::
Git
::
Blob
::
MAX_DATA_DISPLAY_SIZE
)
Gitlab
::
Git
::
Blob
.
batch
(
self
,
items
,
blob_size_limit:
blob_size_limit
)
end
...
...
spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
View file @
859e3dfa
...
...
@@ -19,4 +19,18 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
diff_files
end
shared_examples
'initializes a DiffCollection'
do
it
'returns a valid instance of a DiffCollection'
do
expect
(
diff_files
).
to
be_a
(
Gitlab
::
Git
::
DiffCollection
)
end
end
context
'with Gitaly disabled'
,
:disable_gitaly
do
it_behaves_like
'initializes a DiffCollection'
end
context
'with Gitaly enabled'
do
it_behaves_like
'initializes a DiffCollection'
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