Skip to content

Instantly share code, notes, and snippets.

@christianparpart
Created September 22, 2010 09:21
Show Gist options
  • Save christianparpart/591402 to your computer and use it in GitHub Desktop.
Save christianparpart/591402 to your computer and use it in GitHub Desktop.
#! /home/trapni/local/src/redmine/script/runner -edevelopment
require 'rubygems';
require 'faster_csv';
require 'iconv';
require 'logger';
project = Project.find('stg')
tracker = Tracker.find_by_name('Feature')
author = User.find_by_login('trapni')
precond_id = CustomField.find_by_name('Vorbedingungen')
dod_id = CustomField.find_by_name('Akzeptanzkriterien')
timespan_id = CustomField.find_by_name('Zeitaufwand')
lane_id = CustomField.find_by_name('Lane')
class String
def to_iso
return Iconv.conv('UTF-8', 'ISO-8859-15', self)
end
end
class NilClass
def to_iso
return nil
end
end
FasterCSV.foreach("/home/trapni/work/backlog2.csv", :quote_char => '"', :col_sep => ';', :row_sep => :auto) do |row|
id = row[0]
# skip header and empty rows
next if id == "Nummer" or id == ""
subject = sprintf("%s (%s)", row[1].to_iso, id)
description = row[2].to_iso
definitionOfDone= row[3].to_iso
ActiveRecord::Base.logger = Logger.new(STDOUT);
ActiveRecord::Base.logger.level = Logger::DEBUG;
# create ticket
issue = Issue.create! :subject => subject, :description => description, :project => project , :tracker => tracker, :author => author
# set custom values
issue.custom_field_values = {
dod_id.to_s => definitionOfDone,
timespan_id.to_s => 'L',
precond_id.to_s => '(keine)',
lane_id.to_s => 'Platform' # 'Product Owner'
}
issue.save
printf("rm-id: %s, id: %s, subject: %s\n", issue.id, id, subject, definitionOfDone)
#break
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment