anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

issue joins #228

Closed ashrafalzyoud closed 3 years ago

ashrafalzyoud commented 3 years ago

self.custom_field_values = { 463=> Issue.joins(:custom_values).where(custom_values: {custom_field_id: 472, value: "1"},custom_values: {custom_field_id: 471, value: "259"},tracker_id: 45,project_id: ([84])).distinct.size what wrong for this code ??? my code not working if im put TOW custom_field_id ITS ACCEPTE JUST ONE CFS[472] OR CFS[471]

AirTibu commented 3 years ago

Hi,

You should try to separate the counting:


my_value_471 = CustomValue.where("custom_field_id = 471 AND value ='259'").pluck(:customized_id).uniq.size.to_i

my_value_472 = CustomValue.where("custom_field_id = 472 AND value ='1'").pluck(:customized_id).uniq.size.to_i

self.custom_field_values = { 463=> (my_value_471.to_i + my_value_472.to_i).to_s }

I hope it helps!

ashrafalzyoud commented 3 years ago

i cant separate it i need issue have( custom_field_id = 471 AND value ='259) and (("custom_field_id = 472 AND value ='1'")) example:- issues ( custom_field_id = 471 AND value ='259) = 100 issues (custom_field_id = 472 AND value ='1) = 50 issues have both = 20 this correct answer in your formula the answer is 150

ashrafalzyoud commented 3 years ago

@AirTibu

ashrafalzyoud commented 3 years ago

@AirTibu

AirTibu commented 2 years ago

Hi,

You should try this code:


my_value_471 = CustomValue.where("custom_field_id = 471 AND value ='259'").pluck(:customized_id)

my_value_472 = CustomValue.where("custom_field_id = 472 AND value ='1'").pluck(:customized_id)

self.custom_field_values = { 463=> (my_value_471 & my_value_472).uniq.size.to_i.to_s }

I hope it helps!