Skip to content

Commit

Permalink
fixes severe slowdown (#6) for Redmine 2.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwais committed Apr 7, 2015
1 parent 4b58ebe commit 80b2e48
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The plugin was developed and tested with Redmine version 2.5.2.

- Put the plugin folder into your Redmine's /plugin directory.

- Restart your Redmine.
- Restart Redmine.


###License
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
name 'Redmine Workflow Hidden Fields plugin'
author 'Alexander Wais, et al.'
description "Provides a 'hidden' issue field permission for workflows"
version '0.1.2'
version '0.1.2.1'
url 'https://github.com/alexwais/redmine_workflow_hidden_fields'
author_url 'http://www.redmine.org/issues/12005'
end
9 changes: 6 additions & 3 deletions lib/redmine_workflow_hidden_fields/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ def self.included(base)
base.class_eval do
unloadable
alias_method_chain :safe_attribute_names, :hidden
alias_method_chain :visible_custom_field_values, :hidden
alias_method_chain :read_only_attribute_names, :hidden
alias_method_chain :each_notification, :hidden
end
end

module InstanceMethods

def visible_custom_field_values(user=nil)
def visible_custom_field_values_with_hidden(user=nil)
user_real = user || User.current
fields = custom_field_values.select do |value|
value.custom_field.visible_by?(project, user_real)
Expand All @@ -29,7 +32,7 @@ def viewable_custom_field_values(user=nil)
end


def read_only_attribute_names(user=nil)
def read_only_attribute_names_with_hidden(user=nil)
workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly' and rule != 'hidden'}.keys
end

Expand All @@ -46,7 +49,7 @@ def hidden_attribute?(name, user=nil)
end


def each_notification(users, &block)
def each_notification_with_hidden(users, &block)
if users.any?
variations = users.collect {
|user| (hidden_attribute_names(user) + (custom_field_values - visible_custom_field_values(user))).uniq
Expand Down
37 changes: 19 additions & 18 deletions lib/redmine_workflow_hidden_fields/issue_query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@ def self.included(base)
module InstanceMethods

def available_columns_with_hidden

@available_columns = available_columns_without_hidden

if project == nil
hidden_fields = []
all_projects.each { |prj|
if prj.visible? and User.current.roles_for_project(prj).count > 0
hidden_fields = hidden_fields == [] ? prj.completely_hidden_attribute_names : hidden_fields & prj.completely_hidden_attribute_names
end
}
else
hidden_fields = project.completely_hidden_attribute_names
unless @available_columns
@available_columns = available_columns_without_hidden

if project == nil
hidden_fields = []
all_projects.each { |prj|
if prj.visible? and User.current.roles_for_project(prj).count > 0
hidden_fields = hidden_fields == [] ? prj.completely_hidden_attribute_names : hidden_fields & prj.completely_hidden_attribute_names
end
}
else
hidden_fields = project.completely_hidden_attribute_names
end
hidden_fields.map! {|field| field.sub(/_id$/, '')}

@available_columns.reject! {|column|
hidden_fields.include?(column.name.to_s)
}
end
hidden_fields.map! {|field| field.sub(/_id$/, '')}

@available_columns.reject! {|column|
hidden_fields.include?(column.name.to_s)
}

@available_columns
@available_columns
end

def available_filters_with_hidden
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_workflow_hidden_fields/query_column_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.included(base)

module InstanceMethods

def value_with_hidden(object)
def value_with_hidden(object)
object.send name
if object.respond_to?(:hidden_attribute_names)
hidden_fields = object.hidden_attribute_names.map {|field| field.sub(/_id$/, '')}
Expand Down

0 comments on commit 80b2e48

Please sign in to comment.