プロジェクト

全般

プロフィール

Vote #77924

完了

Rebuild a single nested set with nested_set plugin

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Core Plugins_35
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
35
version_id:
119
issue_org_id:
24167
author_id:
120852
assigned_to_id:
1
comments:
4
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

After updating to Redmine 3.3 we began to encounter broken issue trees quite often. Root and parent ids are ok, but lft and rgt values get messed up somehow. We have ~250k issues so using @Issue.rebuild_tree!@ is a rather expensive task with enormous overhead as 99.99% of nested sets are ok and it is usually one or two that get broken from time to time.

I suppose having a possibility to rebuild only a single nested set would be very useful in such situations. Below is the code I'm using to do so now - just added it to /lib/redmine/nested_set/issue_nested_set.rb


def rebuild_single_tree!(root_id)
  root = Issue.find(root_id)
  if root.blank? || !root.parent_id.blank?
    p "Wrong root specified"
    return
  end
  transaction do           
    where(root_id: root_id).update_all(:lft => nil, :rgt => nil)
    where(root_id: root_id, parent_id: nil).update_all(["lft = ?, rgt = ?", 1, 2])
    rebuild_nodes(root_id)    
  end
end

journals

Wouldn't it be nice if Redmine moved to Git and you could just log an MR instead of pasting code or uploading a .patch? Le Sigh.

#14961
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Feature added in r16111.
--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリCore Plugins_35 にセット
  • 対象バージョン3.4.0_119 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0