backlogs / redmine_backlogs

A Redmine plugin for agile teams
https://backlogs.github.io/www/
GNU General Public License v2.0
773 stars 460 forks source link

the plugin can support higher redmine version. #1153

Open hxqqqqqq opened 6 years ago

hxqqqqqq commented 6 years ago

redmine‘s version is 3.4.5 now. and the rails version usual is v4.2. and the ruby version is usual is v2.3 up. but the "redmine_backlogs" is only support ruby 1.9 & 2.0? can up it for higher version? like version 3.4.3 3.4.5? tkx.

Prophetofcthulhu commented 6 years ago

Hello, I have the same question if this plugin is ever going to become compatible with Redmine version 3.4.4.stable Ruby version 2.5.0-p0 (2017-12-25) [x86_64-linux] Rails version 4.2.8

hxqqqqqq commented 6 years ago

who can help me? can you have aother useful version?tkx.

FooBarTrixibell commented 4 years ago

I almost got this working on redmine 4.

Check out wyplay's fork -

https://github.com/wyplay/redmine_backlogs.git

it almost works, you need to change the ActiveRecord::Migration parts to have a version -

grep -rl "ActiveRecord::Migration$" db | xargs sed -i "$@" "s/ActiveRecord::Migration/ActiveRecord::Migration[5.1]/g"

and you need to remove the unnecessary 3 database commits in 012_migrate_legacy.rb -

ActiveRecord::Base.connection.commit_db_transaction

run the migrate -

bundle exec rake redmine:db:migrate NAME=redmine_backlogs RAILS_ENV=production

then if it fails with a dependent index_issues_on_position error, just drop that index and re run the migrate.

Then it at least installs, unfortunately it then complains in the config page in the browser -

Internal error An error occurred on the page you were trying to access. If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

and the log says -

Processing by SettingsController#plugin as HTML
  Parameters: {"id"=>"redmine_backlogs"}
  Current user: admin (id=1)
  Rendering settings/plugin.html.erb within layouts/admin
  Rendered plugins/redmine_backlogs/app/views/backlogs/_settings.html.erb (30.6ms)
  Rendered settings/plugin.html.erb within layouts/admin (33.2ms)
Completed 500 Internal Server Error in 45ms (ActiveRecord: 10.7ms)

ActionView::Template::Error (undefined method `each' for 26:Integer):
    52: <% if !Backlogs.configured? %>
    53:   <fieldset>
    54:     <legend>Backlogs was not properly set up</legend>
    55:     <%- if !Backlogs.migrated? %>
    56:       <p>Plugin migrations have not been executed</p>
    57:     <%- end %>
    58:     <table>

plugins/redmine_backlogs/lib/backlogs_setup.rb:154:in `migrated?'
FooBarTrixibell commented 4 years ago

If you edit "plugins/redmine_backlogs/lib/backlogs_setup.rb"

and comment out the def migrated? stanza like this -

def migrated?
    #available = Dir[File.join(File.dirname(__FILE__), '../db/migrate/*.rb')].collect{|m| Integer(File.basename(m).split('_')[0].gsub(/^0+/, ''))}.sort
    #return true if available.size == 0
    #available = available[-1]

    #ran = []
    #Setting.connection.execute("select version from schema_migrations where version like '%-redmine_backlogs'").each{|m|
    #  ran << Integer((m.is_a?(Hash) ? m.values : m)[0].split('-')[0])
    #}
    #return false if ran.size == 0
    #ran = ran.sort[-1]

    #return ran >= available
    return 1
  end
  module_function :migrated?

then at least you can get into the settings page. errors following that appear to be partly due to not having any data in the tables in the database though.

Shum1905 commented 4 years ago

Hi FooBarTrixbell,

The "errors following that" means like this?

ActiveRecord::StatementInvalid (TinyTds::Error: A constant expression was encountered in the ORDER BY list, position 1.: EXEC sp_executesql N'SELECT [versions].* FROM [versions] WHERE [versions].[status] IN (N''open'', N''locked'') AND [versions].[project_id] = 4 ORDER BY CASE versions.sprint_start_date WHEN NULL THEN 1 ELSE 0 END ASC, versions.sprint_start_date ASC, CASE versions.effective_date WHEN NULL THEN 1 ELSE 0 END ASC, versions.effective_date ASC'): plugins/redmine_backlogs/app/models/rb_story.rb:152:inbacklogs_by_sprint' plugins/redmine_backlogs/app/controllers/rb_master_backlogs_controller.rb:12:in show' lib/redmine/sudo_mode.rb:63:insudo_mode'`

I got this error when i click "Backlogs" tab. If so, how can I add data in database?

FooBarTrixibell commented 4 years ago

I'm afraid to say, I was only looking at this as a proof of concept for the boss. He wanted an option for migrating away from Jira.

In the end he wasn't overly fond of redmine so we didn't put any serious effort into making it work.

I would start by running that query on your database and seeing what SQL error you get -

SELECT [versions].* 
FROM [versions] 
WHERE [versions].[status] IN ('open', 'locked') 
AND [versions].[project_id] = 4 
ORDER BY 
CASE versions.sprint_start_date WHEN NULL THEN 1 ELSE 0 END ASC, 
versions.sprint_start_date ASC, 
CASE versions.effective_date WHEN NULL THEN 1 ELSE 0 END ASC, 
versions.effective_date ASC

It looks to me like it is generating incorrect sql as CASE versions.sprint_start_date WHEN NULL THEN 1 ELSE 0 END ASC, will probably generate "Order by 0" or "Order by 1" which is just rubbish. probably doesn't happen when your DB is full though.

Perhaps grep for that line in the code and just comment it out, I don't see a reason for it anyway as the order by should not fail if there is nothing to order by.

FooBarTrixibell commented 4 years ago

Looks like it is in plugins/redmine_backlogs/app/models/rb_sprint.rb

  def self.by_date_clause
    dir = Backlogs.setting[:sprint_sort_order] == 'desc' ? 'DESC' : 'ASC'
    "CASE #{table_name}.sprint_start_date WHEN NULL THEN 1 ELSE 0 END #{dir},
     #{table_name}.sprint_start_date #{dir},
     CASE #{table_name}.effective_date WHEN NULL THEN 1 ELSE 0 END #{dir},
     #{table_name}.effective_date #{dir}"
  end

Perhaps change this to

  def self.by_date_clause
    dir = Backlogs.setting[:sprint_sort_order] == 'desc' ? 'DESC' : 'ASC'
    "#{table_name}.sprint_start_date #{dir},
     #{table_name}.effective_date #{dir}"
  end

And try again?

FooBarTrixibell commented 4 years ago

hmm, perhaps not, that ends up in

ORDER BY releases.release_start_date DESC, releases.name DESC, releases.release_end_date ASC, releases.release_start_date ASC'

and it doesn't like having the release start date in there twice!

FooBarTrixibell commented 4 years ago

I could only get this to progress by disabling the sort function entirely -

scope :by_date, #-> { order(by_date_clause) }

at which point it is happy with the query (I think) but complains about labels.yaml being missing

A quick copy of the default file -

cp plugins/redmine_backlogs/lib/labels/labels.yaml.default plugins/redmine_backlogs/lib/labels/labels.yaml

and now it just gives a very generic error and I'm stumped, sorry.

Let me know if you progress it any!

Shum1905 commented 4 years ago

Thank you very much for you a lot of research.

Unfortunately, I couldn't solve this problem with and another error has emerged. I didn't get the error about labels.yaml.

i will keep trying another way.