Trello Organization based Migration #2211
No reviewers
Labels
No Label
dependencies
duplicate
help wanted
invalid
kind/bug
kind/feature
needs reproduction
question
security
wontfix
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/vikunja#2211
Loading…
Reference in New Issue
No description provided.
Delete Branch "Elscrux/vikunja:feature/trello-per-organization-migration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrate Trello organization after organization to limit total memory allocation.
Related discussion: https://community.vikunja.io/t/trello-import-issues/2110
Looks quite good already! Please also take a look at the failing CI and fix any errors it reported.
@ -113,3 +109,1 @@
client := trello.NewClient(config.MigrationTrelloKey.GetString(), token)
client.Logger = log.GetLogger()
func getTrelloData(client *trello.Client) (trelloData []*trello.Board, err error) {
Can you rename that function? Since it now only gets the boards and not all data.
@ -197,3 +211,3 @@
// Converts all previously obtained data from trello into the vikunja format.
// `trelloData` should contain all boards with their projects and cards respectively.
func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullVikunjaHierachie []*models.ProjectWithTasksAndBuckets, err error) {
func convertTrelloDataToVikunja(organizationName string, trelloData []*trello.Board, token string) (fullVikunjaHierachie []*models.ProjectWithTasksAndBuckets, err error) {
Is the
token
parameter still used?Yes, it was used here still.
@ -39,3 +39,3 @@
time1, err := time.Parse(time.RFC3339Nano, "2014-09-26T08:25:05Z")
require.NoError(t, err)
exampleFile, err := os.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/testimage.jpg")
exampleFile, err := os.ReadFile("E:\\dev\\vikunja\\pkg\\modules\\migration\\testimage.jpg")
You should set the
VIKUNJA_SERVICE_ROOTPATH
env variable, do not change this in the test.Oops, sorry didn't mean to change this
@ -392,3 +415,1 @@
assert.NotNil(t, hierachie)
if diff, equal := messagediff.PrettyDiff(hierachie, expectedHierachie); !equal {
t.Errorf("converted trello data = %v, want %v, diff: %v", hierachie, expectedHierachie, diff)
organizationMap := createOrganizationMap(trelloData)
Can you add a test for the conversion happening in
createOrganizationMap
as well?5b502d3353
to053f0a4c7a
Hi Elscrux!
Thank you for creating a PR!
I've deployed the frontend changes of this PR on a preview environment under this URL: https://2211-feature-trello-per-organization---vikunja-frontend-preview.netlify.app
You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/.
This preview does not contain any changes made to the api, only the frontend.
Have a nice day!
@konrad let me know if this works :)
I've got another PR to add non-upload attachments links to the description which I can start after this one is merged.
I ran this locally and got the following error:
It looks like the organization id is not populated properly?
@ -33,3 +33,3 @@
)
func TestConvertTrelloToVikunja(t *testing.T) {
func GetBoard(t *testing.T) ([]*trello.Board, time.Time) {
Please make this private so that it doesn't get used accidentally. And rename it to something like
getTestBoard
to make it clear that this should only be used for the test.15b1c3e097
tode31ffa899
Not sure what happens here. If the organizationID isn't correct, wouldn't it already panic in
createOrganizationMap
when accessingboard.IDOrganization
? All Trello boards should have this id afaik. I ran multiple migrations using this code, so sadly I'm not sure how I could fix this.@konrad Any ideas on this one? I'm not sure I can do anything to resolve this issue as I'm not experiencing it.
I took a closer look and it seems like "Personal Boards" (whatever that is) do not belong to an organization and thus the
IDOrganziation
is an empty string. I would change the loop at pkg/modules/migration/trello/trello.go:423 so that it checks if the organization id is empty and in that case, puts it into a "Personal" pseudo-organization or something like that. Could also be done increateOrganizationMap
.@ -406,0 +446,4 @@
log.Debugf("[Trello Migration] Done migrating trello data for user %d for organization %s", u.ID, organizationID)
log.Debugf("[Trello Migration] Start inserting trello data for user %d for organization %s", u.ID, organizationID)
err = migration.InsertFromStructure(hierarchy, u)
Please use
insertFromStructure
frompkg/modules/migration/create_from_structure.go:48
(you need to make it public and change the name to something likeInsertFromStructureWithSession
and then create the session once before the loop and add the commit after the loop - rollback on any errors. You can wrap the whole loop in a new function which takes the session as an argument, to make it a bit less repetitive and having to do the rollback only once.This has the advantage that you won't end up with a half-done migration when something fails, as in that case, it will be retried and then you might end up with the same projects multiple times.
On second thought, it could be nice to have partial migrations (some workspaces already migrated when only one is failing - as is happening currently in my case), but then we need to make sure the migration is not attempted again when it failed the first time. This would need to happen in the queue, might be more complicated.
Should it check what projects are already present in Vikunja somehow or is there some way to check what has been imported previously? With my current knowledge I have issues working on this as I don't understand all the concepts Vikunja has here. Can you give me some pointers or work on this yourself it that's easier?
TL;DR: should be all good now, with the implementation it currently has.
I've now changed how the retry-mechanism works and opted for a "fail early" model with notifications for the user if the migration fails. That should speed up the process when the migration fails, as it won't be retried as much.
In the specific case of this migration, this might mean partial migrations can happen, but I think it's an acceptable trade-off to have users manually deleting those. My original comment here led me to rethink this.
Please take another look at the failing CI.
I've fixed the last part where the migration would try to request an organization with id
Personal
- that won't work. Instead, it now uses the string as top level project name.Should be good to merge now. Thanks a lot for this!
Great, thanks for the final polish!