anteo / redmine_custom_workflows

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

Help needed with custom_field date type #329

Closed akkow closed 10 months ago

akkow commented 10 months ago

For example I have this 'd', which does not work at all, but 'e' on the other hand works fantastic. I am trying to check for a specific day's custom_field_value(19)'s value, then raise an error or pass through accordingly. No matter what I change the custom_values: {custom_field_id: 21, value: '2024-01-06'} is just not working.

d = project.issues.includes(:custom_values).where(:tracker_id=>'13',custom_values: {custom_field_id: 21, value: '2024-01-06'}, :status_id=>[16,18,22,27]).all.sum{|c| c.custom_field_value(19).to_f}.to_f e = project.issues.includes(:custom_values).where(:tracker_id=>'13',custom_values: {custom_field_id: 19, value: "8"}, :status_id=>[16,18,22,27]).all.sum{|c| c.custom_field_value(19).to_f}.to_f

picman commented 10 months ago

Maybe you can try to debug it in the database. Firstly print out the generated SQL query. Secondly try the query in the database, whether it returns any results.

Rails.logger.info project.issues.includes(:custom_values).where(:tracker_id=>'13',custom_values: {custom_field_id: 21, value: '2024-01-06'}, :status_id=>[16,18,22,27]).to_sql
mysql# SELECT * FROM...

I guess that in the database is stored something like '2024-01-06 00:00:00' and you compare it with '2024-01-06'.

akkow commented 10 months ago

@picman Thanks for the fast reply. We have checked on how it's stored on the database and it has saved well. As you can see in the screenshot value is saved as 'MMMM-mm-dd'. vaizdas

picman commented 10 months ago

Okay, have you tested the query produced by your code too?

akkow commented 10 months ago

We have resolved this issue, thanks for help.