or #  
 
  #891

Tracks 1.7 Export failures

    • Created on: Fri, Apr 24 2009 (over 1 year ago)
    • Reported by: mcraven
    • Assigned to: lrbalt
    • Milestone: 1.7.1
    • Severity: normal
    • Keywords: export
    • Status: Fixed
    • Priority: Normal (3)
    • Component: Functionality (app)
    • Type: defect
    • Resolution:
    • Version: 1.7
    Tracks 1.7 on Windows Server 2003 using Ruby 186-26 and Gems 1.3.1. Export to CVS actions and XML fail displaying the attached error screens. Export to YAML and CVS notes works correctly.
  • Notifications List
    Ico-users lrbalt (Assigned To) Delete-np, mcraven Delete
     
     
     
    Attachments
    Fico_jpg
    60.4 KB Added by mcraven on Apr 24 17:54 2009 UTC Details
    Fico_jpg
    52.8 KB Added by mcraven on Apr 24 17:54 2009 UTC Details
    Associations
     
    No associations
    Activity
     
    User picture

    By mcraven on Apr 24, 2009 @ 05:54PM UTC *

    attachment ActionController_Exceptioncaughtxml_export.jpg added
    file:bchQN8moGr3Ox_eJe5aVNr: XML export failure
    User picture

    By mcraven on Apr 24, 2009 @ 05:54PM UTC *

    attachment ActionController_Exceptioncaughtcsv_actions.jpg added
    file:bb23EKmoGr3Ox_eJe5aVNr: CVS export failure
    User picture

    By lrbalt on May 03, 2009 @ 01:28PM UTC *

    Resolution set to
    assigned_to set to lrbalt
    milestone set to 1.7.1
    status changed from New to Accepted
    I've confirmed the second issue with xml export.
    User picture

    By lrbalt on May 03, 2009 @ 01:29PM UTC *

    I think you missed a rake db:migrate during your upgrade to 1.7? This could be the explanation for the first error.
    User picture

    By lrbalt on May 03, 2009 @ 09:36PM UTC *

    status changed from Accepted to Fixed
    (In revision:a826fb9a11ed9ec7dce36aaf445f8646889f316c) improve data controller and fix #891 where the export of xml did not work because of the removal of tag.user_id

    Branch: master
    User picture

    By lrbalt on May 03, 2009 @ 09:40PM UTC *

    please reopen if the first error is not solved with a rake db:migrate
    User picture

    By mcraven on May 04, 2009 @ 05:57PM UTC *

    This was a new install of 1.7. Do I still need to run db:migrate? If so how do I specify a password?

    Mark C.
    User picture

    By mcraven on May 06, 2009 @ 05:09PM UTC *

    status changed from Fixed to New
    Ran db.migrate. It ran without error but it made no difference. Both exports reported above still fail.

    Regards,
    Mark C.
    User picture

    By lrbalt on May 06, 2009 @ 08:32PM UTC *

    I assume you got the 1.7.1devel code from github to try again? At least the xml export should work again?
    User picture

    By mcraven on May 07, 2009 @ 01:33AM UTC *

    I haven't had a chance to grab the development code and try. I will try in the next couple of days.

    Regards,
    Mark C.
    User picture

    By lrbalt on May 07, 2009 @ 07:36PM UTC *

    ok, please try the fix first. It will probably fix one of the two exports.
    User picture

    By mcraven on May 08, 2009 @ 08:25PM UTC *

    The fix does correct the XML export. The CSV actions export still fails.

    Regards,
    Mark C.
    User picture

    By lrbalt on May 10, 2009 @ 03:26PM UTC *

    Since I cannot reproduce, could you try the following?

    In /path/to/tracks/app/controller/data_controller.rb replace the method csv_actions with this one

    <codeblock>
    def csv_actions
    content_type = 'text/csv'
    CSV::Writer.generate(result = "") do |csv|
    csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
    "Created at", "Due", "Completed at", "User ID", "Show from",
    "state"]
    current_user.todos.find(:all, :include => [:context, :project]).each do |todo|
    1. Format dates in ISO format for easy sorting in spreadsheet Print
    2. context and project names for easy viewing
    csv << [todo.id, todo.context.name,
    todo.project_id.nil? ? "" : todo.project.name,
    todo.description,
    todo.notes, todo.tags.collect{|t| t.name}.join(', '),
    todo.created_at.to_formatted_s(:db),
    todo.due? ? todo.due.to_formatted_s(:db) : "",
    todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "",
    todo.user_id,
    todo.show_from? ? todo.show_from.to_formatted_s(:db) : "",
    todo.state]
    end
    end
    send_data(result, :filename => "todos.csv", :type => content_type)
    end
    </codeblock>
    User picture

    By lrbalt on May 10, 2009 @ 03:27PM UTC *

    hm, please ignore the <codeblock> and </codeblock>
    User picture

    By mcraven on May 11, 2009 @ 06:07PM UTC *

    Here is the original code:
      def csv_actions
        content_type = 'text/csv'
        CSV::Writer.generate(result = "") do |csv|
          csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
            "Created at", "Due", "Completed at", "User ID", "Show from",
            "state"]
          current_user.todos.find(:all, :include => [:context, :project]).each do |todo|
            csv << [todo.id, todo.context.name, 
              todo.project_id = todo.project_id.nil? ? "" : todo.project.name,
              todo.description, 
              todo.notes, todo.tags.collect{|t| t.name}.join(', '),
              todo.created_at.to_formatted_s(:db),
              todo.due = todo.due? ? todo.due.to_formatted_s(:db) : "",
              todo.completed_at = todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "", 
              todo.user_id, 
              todo.show_from = todo.show_from? ? todo.show_from.to_formatted_s(:db) : "",
              todo.state] 
          end
        end
        send_data(result, :filename => "todos.csv", :type => content_type)
      end

    When I insert the following:
    def csv_actions
        content_type = 'text/csv'
        CSV::Writer.generate(result = "") do |csv|
        csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
            "Created at", "Due", "Completed at", "User ID", "Show from",
            "state"]
        current_user.todos.find(:all, :include => [:context, :project]).each do |todo|
           csv << [todo.id, todo.context.name,
             todo.project_id.nil? ? "" : todo.project.name,
             todo.description,
             todo.notes, todo.tags.collect{|t| t.name}.join(’, ’),
             todo.created_at.to_formatted_s(:db),
             todo.due? ? todo.due.to_formatted_s(:db) : "",
             todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "",
             todo.user_id,
             todo.show_from? ? todo.show_from.to_formatted_s(:db) : "",
             todo.state]
            end
        end
        send_data(result, :filename => "todos.csv", :type => content_type)
    end

    It exits with a syntax error.

    Ideas?
    Mark C.
    User picture

    By lrbalt on May 11, 2009 @ 08:49PM UTC *

    When I copy-and-pasted your code, my editor complained about the ', ' in the 11th line. Don't know why, but if you replace it with a single quote, a comma, a space and a closing single quote, it works for me.
    User picture

    By mcraven on May 11, 2009 @ 10:51PM UTC *

    OK, that did it. An output file is now generated.

    Thanks,
    Mark C.
    User picture

    By lrbalt on May 11, 2009 @ 11:41PM UTC *

    Ok, thanks for testing it. I'll apply it for 1.7.1/1.8
    User picture

    By lrbalt on May 13, 2009 @ 09:11PM UTC *

    status changed from New to Fixed
    (In revision:ceba3679421ed7fac4d018e861878e83dfd23a64) fix #891. Somehow the assignment causes an error for some people.

    Don't know why though, but this fix is harmless anyway.

    Branch: master
    User picture

    By lrbalt on Jun 10, 2009 @ 07:59PM UTC *

    (In revision:a826fb9a11ed9ec7dce36aaf445f8646889f316c) improve data controller and fix #891 where the export of xml did not work because of the removal of tag.user_id

    Branch: master
    User picture

    By lrbalt on Jun 10, 2009 @ 07:59PM UTC *

    (In revision:ceba3679421ed7fac4d018e861878e83dfd23a64) fix #891. Somehow the assignment causes an error for some people.

    Don't know why though, but this fix is harmless anyway.

    Branch: master
    Time Expenditure
    Loading