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
d6b7b0d0
Commit
d6b7b0d0
authored
Jun 21, 2021
by
David Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused pagination data
parent
ba854e13
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
13 additions
and
56 deletions
+13
-56
app/serializers/paginated_diff_entity.rb
app/serializers/paginated_diff_entity.rb
+2
-25
lib/gitlab/diff/file_collection/base.rb
lib/gitlab/diff/file_collection/base.rb
+1
-5
lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
+0
-2
spec/controllers/projects/merge_requests/diffs_controller_spec.rb
...trollers/projects/merge_requests/diffs_controller_spec.rb
+4
-6
spec/frontend_integration/test_helpers/mock_server/routes/diffs.js
...tend_integration/test_helpers/mock_server/routes/diffs.js
+0
-3
spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb
...lab/diff/file_collection/merge_request_diff_batch_spec.rb
+1
-1
spec/models/merge_request_diff_spec.rb
spec/models/merge_request_diff_spec.rb
+4
-8
spec/serializers/paginated_diff_entity_spec.rb
spec/serializers/paginated_diff_entity_spec.rb
+1
-6
No files found.
app/serializers/paginated_diff_entity.rb
View file @
d6b7b0d0
...
...
@@ -23,36 +23,13 @@ class PaginatedDiffEntity < Grape::Entity
end
expose
:pagination
do
expose
:current_page
expose
:next_page
expose
:total_pages
expose
:next_page_href
do
|
diffs
|
next
unless
next_page
project
=
merge_request
.
target_project
diffs_batch_namespace_project_json_merge_request_path
(
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
merge_request
.
iid
,
page:
next_page
,
format: :json
)
expose
:total_pages
do
|
diffs
,
options
|
options
.
dig
(
:pagination_data
,
:total_pages
)
end
end
private
%i[current_page next_page total_pages]
.
each
do
|
method
|
define_method
method
do
pagination_data
[
method
]
end
end
def
pagination_data
options
.
fetch
(
:pagination_data
,
{})
end
def
merge_request
options
[
:merge_request
]
end
...
...
lib/gitlab/diff/file_collection/base.rb
View file @
d6b7b0d0
...
...
@@ -88,11 +88,7 @@ module Gitlab
private
def
empty_pagination_data
{
current_page:
nil
,
next_page:
nil
,
total_pages:
nil
}
{
total_pages:
nil
}
end
def
diff_stats_collection
...
...
lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
View file @
d6b7b0d0
...
...
@@ -21,8 +21,6 @@ module Gitlab
@paginated_collection
=
load_paginated_collection
(
batch_page
,
batch_size
,
diff_options
)
@pagination_data
=
{
current_page:
nil
,
next_page:
nil
,
total_pages:
@paginated_collection
.
blank?
?
nil
:
relation
.
size
}
end
...
...
spec/controllers/projects/merge_requests/diffs_controller_spec.rb
View file @
d6b7b0d0
...
...
@@ -472,8 +472,6 @@ RSpec.describe Projects::MergeRequests::DiffsController do
diff_view: :inline
,
merge_ref_head_diff:
nil
,
pagination_data:
{
current_page:
nil
,
next_page:
nil
,
total_pages:
nil
}.
merge
(
pagination_data
)
}
...
...
@@ -515,7 +513,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'serializes diffs with expected arguments'
do
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
}
let
(
:expected_options
)
{
collection_arguments
(
current_page:
nil
,
total_pages:
20
).
merge
(
merge_ref_head_diff:
false
)
}
let
(
:expected_options
)
{
collection_arguments
(
total_pages:
20
).
merge
(
merge_ref_head_diff:
false
)
}
end
it_behaves_like
'successful request'
...
...
@@ -555,7 +553,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'serializes diffs with expected arguments'
do
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
}
let
(
:expected_options
)
do
collection_arguments
(
current_page:
nil
,
total_pages:
20
)
collection_arguments
(
total_pages:
20
)
end
end
...
...
@@ -574,7 +572,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'serializes diffs with expected arguments'
do
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
}
let
(
:expected_options
)
{
collection_arguments
(
current_page:
nil
,
total_pages:
20
)
}
let
(
:expected_options
)
{
collection_arguments
(
total_pages:
20
)
}
end
it_behaves_like
'successful request'
...
...
@@ -585,7 +583,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'serializes diffs with expected arguments'
do
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
}
let
(
:expected_options
)
{
collection_arguments
(
current_page:
nil
,
next_page:
nil
,
total_pages:
20
)
}
let
(
:expected_options
)
{
collection_arguments
(
total_pages:
20
)
}
end
it_behaves_like
'successful request'
...
...
spec/frontend_integration/test_helpers/mock_server/routes/diffs.js
View file @
d6b7b0d0
...
...
@@ -12,10 +12,7 @@ export default (server) => {
return
{
...
result
,
pagination
:
withValues
(
pagination
,
{
current_page
:
null
,
next_page
:
null
,
total_pages
:
1
,
next_page_href
:
null
,
}),
};
});
...
...
spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb
View file @
d6b7b0d0
...
...
@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Diff::FileCollection::MergeRequestDiffBatch do
describe
'initialize'
do
it
'memoizes pagination_data'
do
expect
(
subject
.
pagination_data
).
to
eq
(
current_page:
nil
,
next_page:
nil
,
total_pages:
20
)
expect
(
subject
.
pagination_data
).
to
eq
(
total_pages:
20
)
end
end
...
...
spec/models/merge_request_diff_spec.rb
View file @
d6b7b0d0
...
...
@@ -432,9 +432,7 @@ RSpec.describe MergeRequestDiff do
it
'returns empty pagination data'
do
diffs
=
diff_with_commits
.
diffs_in_batch
(
1
,
10
,
diff_options:
diff_options
)
expect
(
diffs
.
pagination_data
).
to
eq
(
current_page:
nil
,
next_page:
nil
,
total_pages:
nil
)
expect
(
diffs
.
pagination_data
).
to
eq
(
total_pages:
nil
)
end
end
...
...
@@ -460,9 +458,7 @@ RSpec.describe MergeRequestDiff do
expect
(
diffs
).
to
be_a
(
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
)
expect
(
diffs
.
diff_files
.
size
).
to
eq
(
10
)
expect
(
diffs
.
pagination_data
).
to
eq
(
current_page:
nil
,
next_page:
nil
,
total_pages:
20
)
expect
(
diffs
.
pagination_data
).
to
eq
(
total_pages:
20
)
end
it
'sorts diff files directory first'
do
...
...
@@ -493,7 +489,7 @@ RSpec.describe MergeRequestDiff do
expect
(
diffs
).
to
be_a
(
Gitlab
::
Diff
::
FileCollection
::
Compare
)
expect
(
diffs
.
diff_files
.
size
).
to
eq
10
expect
(
diffs
.
pagination_data
).
to
eq
(
current_page:
nil
,
next_page:
nil
,
total_pages:
file_count
)
expect
(
diffs
.
pagination_data
).
to
eq
(
total_pages:
file_count
)
end
it
'returns an empty MergeRequestBatch with empty pagination data when the batch is empty'
do
...
...
@@ -501,7 +497,7 @@ RSpec.describe MergeRequestDiff do
expect
(
diffs
).
to
be_a
(
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
)
expect
(
diffs
.
diff_files
.
size
).
to
eq
0
expect
(
diffs
.
pagination_data
).
to
eq
(
current_page:
nil
,
next_page:
nil
,
total_pages:
nil
)
expect
(
diffs
.
pagination_data
).
to
eq
(
total_pages:
nil
)
end
end
end
...
...
spec/serializers/paginated_diff_entity_spec.rb
View file @
d6b7b0d0
...
...
@@ -24,12 +24,7 @@ RSpec.describe PaginatedDiffEntity do
end
it
'exposes pagination data'
do
expect
(
subject
[
:pagination
]).
to
eq
(
current_page:
nil
,
next_page:
nil
,
next_page_href:
nil
,
total_pages:
20
)
expect
(
subject
[
:pagination
]).
to
eq
(
total_pages:
20
)
end
context
'when there are conflicts'
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