Commit graph

8 commits

Author SHA1 Message Date
GitLab Bot
71da5de44f Add latest changes from gitlab-org/gitlab@master 2020-08-05 15:09:59 +00:00
GitLab Bot
80f61b4035 Add latest changes from gitlab-org/gitlab@master 2019-09-18 14:02:45 +00:00
gfyoung
c858f70d07 Enable frozen string for lib/gitlab/*.rb 2018-10-22 07:00:50 +00:00
Yorick Peterse
2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
blackst0ne
0e9297b37a [Rails5] Fix per_page in lib/gitlab/multi_collection_paginator.rb
In Rails 5 the `per_page` argument came from `params` is String but an
Integer is expected.

This commit explicitly converts `per_page` to an Integer.
It fixes the errors like:

```
  1) Groups::ChildrenController GET #index for subgroups filtering children succeeds if multiple pages contain matching subgroups
     Failure/Error:
       hash[page] = second_collection.page(second_collection_page)
                      .per(per_page - paginated_first_collection(page).size)
                      .padding(offset)

     NoMethodError:
       undefined method `-' for "3":String
       Did you mean?  -@
     # ./lib/gitlab/multi_collection_paginator.rb:42:in `block in paginated_second_collection'
     # ./lib/gitlab/multi_collection_paginator.rb:46:in `paginated_second_collection'
     # ./lib/gitlab/multi_collection_paginator.rb:14:in `paginate'
     # ./app/finders/group_descendants_finder.rb:52:in `children'
     # ./app/finders/group_descendants_finder.rb:34:in `execute'
     # ./app/controllers/groups/children_controller.rb:36:in `setup_children'
     # ./app/controllers/groups/children_controller.rb:18:in `index'
     # ./lib/gitlab/i18n.rb:50:in `with_locale'
     # ./lib/gitlab/i18n.rb:56:in `with_user_locale'
     # ./app/controllers/application_controller.rb:351:in `set_locale'
     # ./spec/controllers/groups/children_controller_spec.rb:182:in `block (5 levels) in <top (required)>'
     # ./spec/spec_helper.rb:198:in `block (2 levels) in <top (required)>'
```
2018-05-11 13:36:38 +11:00
🙈 jacopo beschi 🙉
729f05f0e3 Adds Rubocop rule for line break around conditionals 2018-01-11 16:34:01 +00:00
Bob Van Landuyt
5a335c4d95 Remove the selects when counting the last page
The last page of the first collection is only loaded into memory when
it is being viewed. If it isn't loaded into memory, the `#size` call
triggers a count query.

This `#count` would generate an invalid query if our custom preloaded
counts are included by adding a separate `as count_column` alias on
top of the count aliases. Removing the selects in this case will make
sure a valid `COUNT(*)` is generated.
2017-11-17 16:20:47 +01:00
Bob Van Landuyt
dda023d66d Optimize queries and pagination in GroupDescendantsFinder 2017-10-05 11:10:57 +02:00