1. 05 Nov, 2018 1 commit
    • Yorick Peterse's avatar
      Rewrite SnippetsFinder to improve performance · b81102d2d9a4
      Yorick Peterse authored
      This completely rewrites the SnippetsFinder class from the ground up in
      order to improve its performance. The old code was beyond salvaging. It
      was complex, included various Rails 5 workarounds, comments that
      shouldn't be necessary, and most important of all: it produced a really
      poorly performing database query.
      As a result, I opted for rewriting the finder from scratch, instead of
      trying to patch the existing code. Instead of trying to reuse as many
      existing methods as possible, I opted for defining new methods
      specifically meant for the SnippetsFinder. This requires some extra code
      here and there, but allows us to have much more control over the
      resulting SQL queries. It is these changes that then allow us to produce
      a _much_ more efficient query.
      To illustrate how bad the old query was, we will use my own snippets as
      an example. Currently I have 52 snippets, most of which are global ones.
      To retrieve these, you would run the following Ruby code:
          user = User.find_by(username: 'yorickpeterse')
          SnippetsFinder.new(user, author: user).execute
      On GitLab.com the resulting query will take between 10 and 15 seconds to
      run, producing the query plan found at
      https://explain.depesz.com/s/Y5IX. Apart from the long execution time,
      the total number of buffers (the sum of all shared hits) is around 185
      GB, though the real number is probably (hopefully) much lower as I doubt
      simply summing these numbers produces the true total number of buffers
      The new query's plan can be found at https://explain.depesz.com/s/wHdN,
      and this query takes between 10 and 100-ish milliseconds to run. The
      total number of buffers used is only about 30 MB.
      Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/52639
  2. 01 Nov, 2018 1 commit
  3. 31 Oct, 2018 1 commit
  4. 30 Oct, 2018 1 commit
  5. 22 Oct, 2018 3 commits
    • Cindy Pallares's avatar
      Alias the lfs_enabled method · 976a87eb74be
      Cindy Pallares authored
      We currently check for `project.lfs_enabled` to display
      the state of lfs being enabled/disabled, but this is set to nil by
      default, even when lfs is enabled.
      Aliasing the method to #lfs_enabled? will return the correct state.
    • Yorick Peterse's avatar
      Backport rescue in Project#import_url from EE · 44195c4e3513
      Yorick Peterse authored
      EE added a `rescue` to the method Project#import_url, which could cause
      merge conflicts when changing this method. This commit backports those
      changes to CE, reducing the chances of running into a merge conflict.
    • Yorick Peterse's avatar
      Move Project#rename_repo to a service class · a8f8af2f9d3f
      Yorick Peterse authored
      This moves the logic of Project#rename_repo and all methods _only_ used
      by this method into a new service class: Projects::AfterRenameService.
      By moving this code into a separate service class we can more easily
      refactor it, and we also get rid of some RuboCop "disable" statements
      During the refactoring of this code, I removed most of the explicit
      logging using Gitlab::AppLogger. The data that was logged would not be
      useful when debugging renaming issues, as it does not add any value on
      top of data provided by users.
      I also removed a variety of comments that either mentioned something the
      code does in literal form, or contained various grammatical errors.
      Instead we now resort to more clearly named methods, removing the need
      for code comments.
      This method was chosen based on analysis in
      https://gitlab.com/gitlab-org/release/framework/issues/28. In this issue
      we determined this method has seen a total of 293 lines being changed in
      it. We also noticed that RuboCop determined the ABC size
      (https://www.softwarerenovation.com/ABCMetric.pdf) was too great.
  6. 19 Oct, 2018 1 commit
    • Bob Van Landuyt's avatar
      Remove the `ForkedProjectLink` model · b055a9ce0a40
      Bob Van Landuyt authored
      This removes the `ForkedProjectLink` model that has been replaced by
      the `ForkNetworkMember` and `ForkNetwork` combination. All existing
      relations have been adjusted to use these new models.
      The `forked_project_link` table has been dropped.
      The "Forks" count on the admin dashboard has been updated to count all
      `ForkNetworkMember` rows and deduct the number of `ForkNetwork`
      rows. This is because now the "root-project" of a fork network also
      has a `ForkNetworkMember` row. This count could become inaccurate when
      the root of a fork network is deleted.
  7. 15 Oct, 2018 1 commit
  8. 10 Oct, 2018 1 commit
    • Stan Hu's avatar
      Fix project deletion when there is a export available · d893ead145a7
      Stan Hu authored
      Project deletions were failing with "Can't modify frozen hash" because:
      1. Project#remove_exports was called in the after_destroy hook
      2. This would remove the file and update ImportExportUpload
      3. ImportExportUpload#save would attempt to write to a destroyed model
      To avoid this, we just check if ImportExportUpload has been destroyed
      before attempting to save it.
      This would have a side effect of not running after_commit hooks to delete the
      repository on disk, making it impossible to delete the project entirely.
      Closes #52362
  9. 08 Oct, 2018 1 commit
    • Yorick Peterse's avatar
      Clean up ActiveRecord code in TodosFinder · c454a2f4a6ca
      Yorick Peterse authored
      This refactors the TodosFinder finder according to the new code reuse
      rules, as enforced by the CodeReuse cops. I also changed some of the
      methods to use regular if statements, instead of assignments and/or
      early returns. This results in a more natural flow when reading the
      code, and it makes it harder to accidentally return the wrong result.
  10. 06 Oct, 2018 1 commit
  11. 05 Oct, 2018 1 commit
  12. 04 Oct, 2018 1 commit
  13. 01 Oct, 2018 1 commit
  14. 26 Sep, 2018 1 commit
  15. 25 Sep, 2018 1 commit
    • Valery Sizov's avatar
      Geo: sync disabled wikis. Stage 2 · 8ce3572c59aa
      Valery Sizov authored
      We started syncing all the wiki regardless of the fact it's disabled or
      not. We couldn't do that in one stage because of needing of smoth update
      and deprecating things. This is the second stage that finally removes
      unused columns in the geo_node_status table.
  16. 24 Sep, 2018 1 commit
  17. 21 Sep, 2018 2 commits
  18. 17 Sep, 2018 1 commit
    • Yorick Peterse's avatar
      Added FromUnion to easily select from a UNION · 84f6b869d148
      Yorick Peterse authored
      This commit adds the module `FromUnion`, which provides the class method
      `from_union`. This simplifies the process of selecting data from the
      result of a UNION, and reduces the likelihood of making mistakes. As a
      result, instead of this:
          union = Gitlab::SQL::Union.new([foo, bar])
          Foo.from("(#{union.to_sql}) #{Foo.table_name}")
      We can now write this instead:
          Foo.from_union([foo, bar])
      This commit also includes some changes to make this new setup work
      properly. For example, a bug in Rails 4
      (https://github.com/rails/rails/issues/24193) would break the use of
      `from("sub-query-here").includes(:relation)` in certain cases. There was
      also a CI query which appeared to repeat a lot of conditions from an
      outer query on an inner query, which isn't necessary.
      Finally, we include a RuboCop cop to ensure developers use this new
      module, instead of using Gitlab::SQL::Union directly.
      Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/51307
  19. 12 Sep, 2018 1 commit
  20. 11 Sep, 2018 1 commit
  21. 10 Sep, 2018 1 commit
  22. 07 Sep, 2018 2 commits
  23. 06 Sep, 2018 1 commit
  24. 05 Sep, 2018 1 commit
  25. 04 Sep, 2018 1 commit
  26. 26 Aug, 2018 1 commit
  27. 23 Aug, 2018 1 commit
  28. 22 Aug, 2018 2 commits
  29. 20 Aug, 2018 2 commits
    • Gilbert Roulot's avatar
      Remove Gemnasium service · 43b04f62433f
      Gilbert Roulot authored
    • Yorick Peterse's avatar
      Refactor AutocompleteController · c8cc17675ba4
      Yorick Peterse authored
      This refactors the AutocompleteController according to the guidelines
      and boundaries discussed in
      https://gitlab.com/gitlab-org/gitlab-ce/issues/49653. Specifically,
      ActiveRecord logic is moved to different finders, which are then used in
      the controller. View logic in turn is moved to presenters, instead of
      directly using ActiveRecord's "to_json" method.
      The finder MoveToProjectFinder is also adjusted according to the
      abstraction guidelines and boundaries, resulting in a much more simple
      By using finders (and other abstractions) more actively, we can push a
      lot of logic out of the controller. We also remove the need for various
      "before_action" hooks, though this could be achieved without using
      finders as well.
      The various finders related to AutcompleteController have also been
      moved into a namespace. This removes the need for calling everything
      "AutocompleteSmurfFinder", instead you can use
  30. 16 Aug, 2018 1 commit
  31. 13 Aug, 2018 1 commit
    • Duana Saskia's avatar
      Filter project hooks by branch · 11a03100ca1c
      Duana Saskia authored
      Allow specificying a branch filter for a project hook and only trigger
      a project hook if either the branch filter is blank or the branch matches.
      Only supported for push_events for now.
  32. 06 Aug, 2018 1 commit
  33. 03 Aug, 2018 2 commits