From 95ca14e6b8f7116d94b0ab031d5c6429069e10f4 Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Tue, 17 Dec 2019 04:44:53 +0100
Subject: [PATCH] conversion script ready
---
conversion.cr | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/conversion.cr b/conversion.cr
index f568073..2443c9c 100644
--- a/conversion.cr
+++ b/conversion.cr
@@ -50,7 +50,16 @@ old_storage.each do |old_project|
# 3.1. get list properties
extra_properties = Hash(String, JSON::Any).new
- extra_properties["columns"] = JSON.parse(old_project.columns.to_json)
+ # columns = JSON.parse(old_project.columns.to_json)
+ columns = Array(Hash(String, String)).new
+ old_project.columns.each do |col|
+ column = { "id" => col.id, "title" => col.name }
+ columns << column
+ puts "column :"
+ pp! column
+ end
+
+ extra_properties["columns"] = JSON.parse(columns.to_json)
# 3.2. get tasks, create new tasks and store them
@@ -63,9 +72,15 @@ old_storage.each do |old_project|
# 2. create a task in the new format
task_extra_properties = Hash(String, JSON::Any).new
- task_extra_properties["column"] = JSON.parse(t.column.to_json)
- task_extra_properties["backgroundColor"] = JSON.parse(t.color.to_json)
- task_extra_properties["assigneeId"] = JSON.parse(t.assigned_to.to_json)
+ task_extra_properties["column"] = JSON.parse(t.column.to_json)
+
+ # change the default color of the task, to match the new default list background color
+ if t.color == "dark"
+ task_extra_properties["backgroundColor"] = JSON.parse("white".to_json)
+ else
+ task_extra_properties["backgroundColor"] = JSON.parse(t.color.to_json)
+ end
+ task_extra_properties["assigneeId"] = JSON.parse(t.assigned_to.to_json)
newtask = ::TodoD::Task.new old_project.id, t.title, t.author,
description: (t.description || ""),
@@ -83,6 +98,7 @@ old_storage.each do |old_project|
u = User.new
list = TodoD::List.new old_project.name, u, extra_properties
+ list.id = old_project.id
list.tasks = tasks.map &.id
# puts ""