Skip to content
Snippets Groups Projects

Store group and project full name and full path in routes table

Merged username-removed-444 requested to merge dz-refactor-full-path into master
1 unresolved thread

What does this MR do?

  • adds name field to routes table
  • moves full_name and full_path implementation from Namespace/Project to Routable concern
  • uses route.name and route.path for full name/path to group or project

Are there points in the code the reviewer needs to double check?

no

Why was this MR needed?

  • less sql queries (no need to collect parents to build full name/path)
  • use routes table as single point of truth for resource location
  • cleaner code

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/2772

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • username-removed-444 resolved all discussions

    resolved all discussions

  • added 479 commits

    Compare with previous version

  • TODO: add name to Route#rename_descendants

  • added 1 commit

    • 2989192d - Store group and project full name and full path in routes table

    Compare with previous version

  • mentioned in commit 8820f3cd

  • 11 after_update :rename_descendants
    12 12
    13 13 def rename_descendants
    14 # We update each row separately because MySQL does not have regexp_replace.
    15 # rubocop:disable Rails/FindEach
    16 Route.where('path LIKE ?', "#{path_was}/%").each do |route|
    17 # Note that update column skips validation and callbacks.
    18 # We need this to avoid recursive call of rename_descendants method
    19 route.update_column(:path, route.path.sub(path_was, path))
    14 if path_changed? || name_changed?
    15 descendants = Route.where('path LIKE ?', "#{path_was}/%")
    16
    17 descendants.each do |route|
    18 attributes = {
    19 path: route.path.sub(path_was, path),
    20 name: route.name.sub(name_was, name)
    • I believe this is causing the following issue

      Processing by DashboardController#activity as JSON
        Parameters: {"limit"=>"20", "offset"=>"0"}
      Completed 500 Internal Server Error in 329ms (ActiveRecord: 23.4ms)
      
      ActionView::Template::Error (undefined method `sub' for nil:NilClass):
          1: %span.event-scope
          2:   = event_preposition(event)
          3:   - if event.project
          4:     = link_to_project event.project
          5:   - else
          6:     = event.project_name
        app/models/route.rb:20:in `block in rename_descendants'
        app/models/route.rb:17:in `rename_descendants'
        app/models/concerns/routable.rb:134:in `update_route'
        app/models/concerns/routable.rb:90:in `full_name'
        app/models/group.rb:92:in `human_name'
        app/helpers/projects_helper.rb:7:in `block in link_to_project'
        app/helpers/projects_helper.rb:3:in `link_to_project'
        app/views/events/_event_scope.html.haml:4:in `_app_views_events__event_scope_html_haml___2929874715229744757_47358257732160'
        app/views/events/event/_push.html.haml:12:in `_app_views_events_event__push_html_haml__1441259515167165541_47358256146220'
        app/views/events/_event.html.haml:11:in `_app_views_events__event_html_haml__8499293176541115_47358253063620'
        app/views/events/_events.html.haml:1:in `_app_views_events__events_html_haml___398254689614415965_47358308510200'
        app/controllers/application_controller.rb:204:in `pager_json'
        app/controllers/dashboard_controller.rb:19:in `block (2 levels) in activity'
        app/controllers/dashboard_controller.rb:14:in `activity'
        lib/gitlab/middleware/multipart.rb:93:in `call'
        lib/gitlab/request_profiler/middleware.rb:14:in `call'
        lib/gitlab/middleware/go.rb:16:in `call'

      But i might be wrong or missing an upgrade step (installation from sources)

      Happy to provide additional information in case that's needed

      Edit : MySQL as DB, name column values appear to be null for all rows

      Edited by username-removed-17207
    • Please register or sign in to reply
  • mentioned in issue #29554 (closed)

  • Please register or sign in to reply
    Loading