zh / redmine_importer

Redmine importer that works with trunk.
https://github.com/leovitch/redmine_importer/wiki
47 stars 57 forks source link

Internal Error #33

Closed ElskerDane closed 8 years ago

ElskerDane commented 9 years ago

I have installed your plugin and I am getting an Internal Error when I attempt to upload your sample file "All Standard Fields". I have followed the steps as shown on: https://github.com/leovitch/redmine_importer/wiki/Samplefiles

I am using Redmine 3.0.3, Ruby 2.0.0, Rails 4.2, Windows 7

This is the error I see in my production file:

Started POST "/importer/match" for ::1 at 2015-06-16 09:23:58 -0400 Processing by ImporterController#match as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"uUHfot2aNJuyGtp25wtTPqucRES0/pCz4y1vnDSzrFu3eT0ByTRZ7nbnbVx0afri7spdJyq9LnpLg+qq2+sqsw==", "project_id"=>"5", "file"=>#<ActionDispatch::Http::UploadedFile:0x99e3028 @tempfile=#<Tempfile:C:/Users/J40419/AppData/Local/Temp/RackMultipart20150616-2588-1in9yzs.csv>, @original_filename="AllStandardFields.csv", @content_type="application/vnd.ms-excel", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"AllStandardFields.csv\"\r\nContent-Type: application/vnd.ms-excel\r\n">, "encoding"=>"U", "splitter"=>",", "wrapper"=>"\"", "commit"=>"Upload File"} Current user: admin (id=1) Completed 500 Internal Server Error in 87ms (ActiveRecord: 6.0ms)

NoMethodError (undefined method find_or_create_by_user_id' for #<Class:0x93e2a28>): activerecord (4.2.1) lib/active_record/dynamic_matchers.rb:26:inmethod_missing' plugins/redmine_importer/app/controllers/importer_controller.rb:33:in match' actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:4:insend_action' actionpack (4.2.1) lib/abstract_controller/base.rb:198:in process_action' actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:inprocess_action' actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.2.1) lib/active_support/callbacks.rb:117:incall' activesupport (4.2.1) lib/active_support/callbacks.rb:117:in call' activesupport (4.2.1) lib/active_support/callbacks.rb:555:inblock (2 levels) in compile' activesupport (4.2.1) lib/active_support/callbacks.rb:505:in call' activesupport (4.2.1) lib/active_support/callbacks.rb:505:incall' activesupport (4.2.1) lib/active_support/callbacks.rb:92:in _run_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:776:in_run_process_action_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.1) lib/abstract_controller/callbacks.rb:19:inprocess_action' actionpack (4.2.1) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:32:inblock in process_action' activesupport (4.2.1) lib/active_support/notifications.rb:164:in block in instrument' activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.2.1) lib/active_support/notifications.rb:164:in instrument' actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:30:inprocess_action' actionpack (4.2.1) lib/action_controller/metal/params_wrapper.rb:250:in process_action' activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:18:inprocess_action' actionpack (4.2.1) lib/abstract_controller/base.rb:137:in process' actionview (4.2.1) lib/action_view/rendering.rb:30:inprocess' actionpack (4.2.1) lib/action_controller/metal.rb:196:in dispatch' actionpack (4.2.1) lib/action_controller/metal/rack_delegation.rb:13:indispatch' actionpack (4.2.1) lib/action_controller/metal.rb:237:in block in action' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:incall' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in dispatch' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:43:inserve' actionpack (4.2.1) lib/action_dispatch/journey/router.rb:43:in block in serve' actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:ineach' actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in serve' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:819:incall' rack-openid (1.4.2) lib/rack/openid.rb:98:in call' request_store (1.0.5) lib/request_store/middleware.rb:9:incall' rack (1.6.1) lib/rack/etag.rb:24:in call' rack (1.6.1) lib/rack/conditionalget.rb:38:incall' rack (1.6.1) lib/rack/head.rb:13:in call' actionpack-xml_parser (1.0.2) lib/action_dispatch/xml_params_parser.rb:16:incall' actionpack (4.2.1) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.2.1) lib/action_dispatch/middleware/flash.rb:260:incall' rack (1.6.1) lib/rack/session/abstract/id.rb:225:in context' rack (1.6.1) lib/rack/session/abstract/id.rb:220:incall' actionpack (4.2.1) lib/action_dispatch/middleware/cookies.rb:560:in call' activerecord (4.2.1) lib/active_record/query_cache.rb:36:incall' activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in call' actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.2.1) lib/active_support/callbacks.rb:88:in call' activesupport (4.2.1) lib/active_support/callbacks.rb:88:in_run_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:776:in _run_call_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:81:inrun_callbacks' actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.2.1) lib/action_dispatch/middleware/remote_ip.rb:78:incall' actionpack (4.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.2.1) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.2.1) lib/rails/rack/logger.rb:38:in call_app' railties (4.2.1) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.2.1) lib/active_support/tagged_logging.rb:26:intagged' activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.2.1) lib/rails/rack/logger.rb:20:incall' actionpack (4.2.1) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.6.1) lib/rack/methodoverride.rb:22:incall' rack (1.6.1) lib/rack/runtime.rb:18:in call' activesupport (4.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall' actionpack (4.2.1) lib/action_dispatch/middleware/static.rb:113:in call' rack (1.6.1) lib/rack/sendfile.rb:113:incall' railties (4.2.1) lib/rails/engine.rb:518:in call' railties (4.2.1) lib/rails/application.rb:164:incall' rack (1.6.1) lib/rack/lock.rb:17:in call' rack (1.6.1) lib/rack/content_length.rb:15:incall' rack (1.6.1) lib/rack/handler/webrick.rb:89:in service' C:/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:138:inservice' C:/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:94:in run' C:/Ruby200/lib/ruby/2.0.0/webrick/server.rb:295:inblock in start_thread'

I would greatly appreciate any help you can give me!

Baleba commented 9 years ago

Hi I made a few changes in

ended up with the following diff. Please check and let me know if it works for you. It's a quite dirty hack, but I needed it to work for me. If anybody can come up with a cleaner solution, I'll be happy to switch. and sorry for the presentation. Let me know if you need some clarification. May send you and archive with my redmine_importer folder.

I works for on this env:

Environment: Redmine version 3.0.3.stable Ruby version 1.9.3-p194 (2012-04-20) [arm-linux-eabihf] Rails version 4.2.1 Environment production Database adapter Mysql2 SCM: Git 1.7.10.4 Filesystem
Redmine plugins: csv_import_issues 0.0.2 redmine_importer 1.2.2 redmine_planning 0.7.6

Diff for redmine_importer/app/controllers/importer_controller.rb

replaced iip = ImportInProgress.find_or_create_by(user_id: User.current.id) with iip = ImportInProgress.find_or_create_by_user_id(User.current.id)

Replace

issues = Issue.find :all, :conditions => query.statement, :limit => 2, :include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ]

With

qQuery = "Select * from projects, issues where " qQuery = qQuery.concat(query.statement) qQuery = qQuery.concat(" AND projects.id = issues.project_id ") issues = Issue.find_by_sql(qQuery)

Then In for plugins/redmine_importer/app/models/import_in_progress.rb Add attr_accessible for user_id

8c8 < attr_accessible :user_id

go2null commented 9 years ago

I have fork that should work on Redmine v3.x. Give it a whirl and let me know. https://github.com/go2null/redmine_importer/tree/redmine-3.x-stable

Baleba commented 9 years ago

Hi,

Just tested your port again. The way I test. I'm loading MSP task from csv. I have two files. One for all parent tasks, the second for all children tasks. I can load all parents tasks, but when it comes to children, I get this "page not found" error, and the below in the production.log. So I think you are almost there, but the query that retrieve existing ticket from redmine is broken. That why I chenged "find all" to "find_by_query" and had to twick the query a bit. External Id" is the custom field I added to retrieve existing ticket for a given project.

Started POST "/projects/testg2nullporting/importer/result" for 192.168.0.13 at 2015-06-25 04:57:09 +0000 Processing by ImporterController#result as HTML Parameters: {"utf8"=>"â", "authenticity_token"=>"JuaNlATnVgJ6WNHpNkejnTltC/qwdJP04AaF65TvZhusC8aeKKOAD9b/MZhzIjgDsnXj6cLyOLhh27flb0oL7w==", "project_id"=>"testg2nullporting", "import_timestamp"=>"2015-06-25 04:56:58", "fields_map"=>{"Description"=>"description", "Subject"=>"subject", "Start date"=>"start_date", "Due date"=>"due_date", "Tracker"=>"tracker", "External Id"=>"External Id", "Parent task"=>"parent_issue", "Initial Cost estimate"=>"", "nothing"=>""}, "default_tracker"=>"1", "unique_field"=>"External Id", "add_categories"=>"true", "add_versions"=>"true", "use_anonymous"=>"true", "commit"=>"Submit"} Current user: baleba (id=5) Completed 404 Not Found in 1469ms (ActiveRecord: 48.5ms)

ActiveRecord::RecordNotFound (Couldn't find all Issues with 'id': (all, {:conditions=>"(issues.status_id IS NOT NULL) AND issues.id IN (SELECT issues.id FROM issues LEFT OUTER JOIN custom_values ON custom_values.customized_type='Issue' AND custom_values.customized_id=issues.id AND custom_values.custom_field_id=1 WHERE (custom_values.value IN ('MyP_21')) AND (((1=1) AND (issues.tracker_id IN (SELECT tracker_id FROM custom_fields_trackers WHERE custom_field_id = 1)) AND (EXISTS (SELECT 1 FROM custom_fields ifa WHERE ifa.is_for_all = 1 AND ifa.id = 1) OR issues.project_id IN (SELECT project_id FROM custom_fields_projects WHERE custom_field_id = 1))))) AND projects.id = 9", :limit=>2, :include=>[:assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version]}) (found 0 results, but was looking for 2)): activerecord (4.2.1) lib/active_record/relation/finder_methods.rb:336:in raise_record_not_found_exception!' activerecord (4.2.1) lib/active_record/relation/finder_methods.rb:479:infind_some' activerecord (4.2.1) lib/active_record/relation/finder_methods.rb:438:in find_with_ids' activerecord (4.2.1) lib/active_record/relation/finder_methods.rb:71:infind' activerecord (4.2.1) lib/active_record/querying.rb:3:in find' activerecord (4.2.1) lib/active_record/core.rb:128:infind' plugins/redmine_importer/app/controllers/importer_controller.rb:632:in issue_for_unique_attr' plugins/redmine_importer/app/controllers/importer_controller.rb:417:inhandle_parent_issues' plugins/redmine_importer/app/controllers/importer_controller.rb:224:in block in result' /usr/lib/ruby/1.9.1/csv.rb:1792:ineach' plugins/redmine_importer/app/controllers/importer_controller.rb:146:in result' actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:4:insend_action' actionpack (4.2.1) lib/abstract_controller/base.rb:198:in process_action' actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:inprocess_action' actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.2.1) lib/active_support/callbacks.rb:117:incall' activesupport (4.2.1) lib/active_support/callbacks.rb:117:in call' activesupport (4.2.1) lib/active_support/callbacks.rb:555:inblock (2 levels) in compile' activesupport (4.2.1) lib/active_support/callbacks.rb:505:in call' activesupport (4.2.1) lib/active_support/callbacks.rb:505:incall' activesupport (4.2.1) lib/active_support/callbacks.rb:92:in _run_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:776:in_run_process_action_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.1) lib/abstract_controller/callbacks.rb:19:inprocess_action' actionpack (4.2.1) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:32:inblock in process_action' activesupport (4.2.1) lib/active_support/notifications.rb:164:in block in instrument' activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.2.1) lib/active_support/notifications.rb:164:in instrument' actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:30:inprocess_action' actionpack (4.2.1) lib/action_controller/metal/params_wrapper.rb:250:in process_action' activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:18:inprocess_action' actionpack (4.2.1) lib/abstract_controller/base.rb:137:in process' actionview (4.2.1) lib/action_view/rendering.rb:30:inprocess' actionpack (4.2.1) lib/action_controller/metal.rb:196:in dispatch' actionpack (4.2.1) lib/action_controller/metal/rack_delegation.rb:13:indispatch' actionpack (4.2.1) lib/action_controller/metal.rb:237:in block in action' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:incall' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in dispatch' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:43:inserve' actionpack (4.2.1) lib/action_dispatch/journey/router.rb:43:in block in serve' actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:ineach' actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in serve' actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:819:incall' rack-openid (1.4.2) lib/rack/openid.rb:98:in call' request_store (1.0.5) lib/request_store/middleware.rb:9:incall' rack (1.6.1) lib/rack/etag.rb:24:in call' rack (1.6.1) lib/rack/conditionalget.rb:38:incall' rack (1.6.1) lib/rack/head.rb:13:in call' actionpack-xml_parser (1.0.2) lib/action_dispatch/xml_params_parser.rb:16:incall' actionpack (4.2.1) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.2.1) lib/action_dispatch/middleware/flash.rb:260:incall' rack (1.6.1) lib/rack/session/abstract/id.rb:225:in context' rack (1.6.1) lib/rack/session/abstract/id.rb:220:incall' actionpack (4.2.1) lib/action_dispatch/middleware/cookies.rb:560:in call' activerecord (4.2.1) lib/active_record/query_cache.rb:36:incall' activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in call' actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.2.1) lib/active_support/callbacks.rb:88:in call' activesupport (4.2.1) lib/active_support/callbacks.rb:88:in_run_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:776:in _run_call_callbacks' activesupport (4.2.1) lib/active_support/callbacks.rb:81:inrun_callbacks' actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.2.1) lib/action_dispatch/middleware/remote_ip.rb:78:incall' actionpack (4.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.2.1) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.2.1) lib/rails/rack/logger.rb:38:in call_app' railties (4.2.1) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.2.1) lib/active_support/tagged_logging.rb:26:intagged' activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.2.1) lib/rails/rack/logger.rb:20:incall' actionpack (4.2.1) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.6.1) lib/rack/methodoverride.rb:22:incall' rack (1.6.1) lib/rack/runtime.rb:18:in call' activesupport (4.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall' actionpack (4.2.1) lib/action_dispatch/middleware/static.rb:113:in call' rack (1.6.1) lib/rack/sendfile.rb:113:incall' railties (4.2.1) lib/rails/engine.rb:518:in call' railties (4.2.1) lib/rails/application.rb:164:incall' railties (4.2.1) lib/rails/railtie.rb:194:in public_send' railties (4.2.1) lib/rails/railtie.rb:194:inmethod_missing' passenger (5.0.7) lib/phusion_passenger/rack/thread_handler_extension.rb:89:in process_request' passenger (5.0.7) lib/phusion_passenger/request_handler/thread_handler.rb:155:inaccept_and_process_next_request' passenger (5.0.7) lib/phusion_passenger/request_handler/thread_handler.rb:110:in main_loop' passenger (5.0.7) lib/phusion_passenger/request_handler.rb:414:inblock (3 levels) in start_threads' passenger (5.0.7) lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'

Parent tasks CSV.

"Description","Subject","Tracker","External Id","Parent task",nothing "Executive summary: Porject aim is to use my newly discovered capabilities to hit the ground.","Crypto-Project","Meta","MyP_1","", "","MaidSafe","Meta","MyP_2","MyP_1", "","Ethereum","Meta","MyP_4","MyP_1", "","Contributing","Meta","MyP_6","MyP_1", "","Preparation","Meta","MyP_21","MyP_2", "","Preparation","Meta","MyP_22","MyP_4", "","Getting familiar with git","Meta","MyP_23","MyP_6", "","Contributing","Meta","MyP_27","MyP_6",

Children file CSV

"Description","Subject","Start date","Due date","Tracker","External Id","Parent task","Initial Cost estimate",nothing "","MaS-Review white papers","2015-05-18T08:00:00","2015-05-22T17:00:00","Action","MyP_9","MyP_21","40", "","MaS-Review code","2015-06-01T08:00:00","2015-06-05T17:00:00","Action","MyP_10","MyP_21","40", "","MaS-Install test environment","2015-06-15T08:00:00","2015-06-16T17:00:00","Action","MyP_11","MyP_21","16", "","MaS-Build personal test book","2015-06-19T08:00:00","2015-06-22T17:00:00","Action","MyP_8","MyP_21","16", "","MaS-design migration path","2015-06-25T08:00:00","2015-06-26T17:00:00","Action","MyP_7","MyP_21","16", "","Eth-Review white papers","2015-05-25T08:00:00","2015-05-29T17:00:00","Action","MyP_16","MyP_22","40", "","Eth-Review code","2015-06-08T08:00:00","2015-06-12T17:00:00","Action","MyP_17","MyP_22","40", "","Eth-Install test environment","2015-06-17T08:00:00","2015-06-18T17:00:00","Action","MyP_18","MyP_22","16", "","Eth-Build personal test book","2015-06-23T08:00:00","2015-06-24T17:00:00","Action","MyP_19","MyP_22","16", "","Eth-design migration path","2015-06-29T08:00:00","2015-06-30T17:00:00","Action","MyP_20","MyP_22","16", "","Review Git concept","2015-07-01T08:00:00","2015-07-07T17:00:00","Action","MyP_24","MyP_23","40", "","Setup Git environment","2015-07-08T08:00:00","2015-07-14T17:00:00","Action","MyP_25","MyP_23","40", "","Perform various git tests","2015-07-15T08:00:00","2015-07-21T17:00:00","Action","MyP_26","MyP_23","40", "","Getting a public git access","2015-07-22T08:00:00","2015-07-28T17:00:00","Action","MyP_28","MyP_27","40", "","Defining contribution strategy","2015-07-29T08:00:00","2015-08-04T17:00:00","Action","MyP_29","MyP_27","40", "","C++ coding principle and code reading","2015-08-05T08:00:00","2015-08-18T17:00:00","Action","MyP_30","MyP_27","80",

badpenguin commented 9 years ago

@go2null thanks! i had the same problem as this issue and your fork worked for me!!!

zh commented 8 years ago

For Redmine v3.x use go2null fork.