Arrow_left   Arrow_right
 
  #891

Tracks 1.7 Export failures

    • Created on: Fri, 24 Apr 2009 (almost 3 years 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.
  • Followers
     
    Ico-users lrbalt (Assigned To) , mcraven 
     
    Attachments
    Fico_jpg
    60.4 KB Added by mcraven on Apr 24 12:54 2009 UTC   Details
    Fico_jpg
    52.8 KB Added by mcraven on Apr 24 12:54 2009 UTC   Details
    Associations
     
    No associations
    Activity
     
    User picture

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

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

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

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

          on May 03, 2009 @ 08:28AM UTC * By lrbalt

    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

          on May 03, 2009 @ 08:29AM UTC * By lrbalt

    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

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

    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

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

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

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

    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

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

    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

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

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

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

    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

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

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

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

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

    Regards,
    Mark C.
    User picture

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

    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

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

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

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

    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

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

    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

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

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

    Thanks,
    Mark C.
    User picture

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

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

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

    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

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

    (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

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

    (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