Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import/Export functions #54

Merged
merged 14 commits into from
Oct 17, 2021
Merged

Import/Export functions #54

merged 14 commits into from
Oct 17, 2021

Conversation

noctera
Copy link
Member

@noctera noctera commented Jul 18, 2021

Status Type Env Vars Change
✅ Ready Feature No

Description

Serverside implementation of the import/export function, which allows to add and store vocabs from a package or group from/in a JSON file.

To do:

  • import function
  • export function

GET /api/languagePackage/:languagePackageIdexport?queryStatus=false


Response

{
    "name": "Englisch - German",
    "foreignWordLanguage": "en",
    "translatedWordLanguage": "de",
    "vocabsPerDay": 5,
    "rightWords": 2,
    "Groups": [
        {
            "name": "unit 1",
            "description": "",
            "VocabularyCards": [
                {
                    "name": "test vocab",
                    "description": "This is a test description",
                    "drawerId": "21e8e24d-5879-432f-b8bb-0db6cf38bb17",
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                },
                {
                    "name": "test vocab",
                    "description": "This is a test description",
                    "drawerId": "21e8e24d-5879-432f-b8bb-0db6cf38bb17",
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                },
                {
                    "name": "test vocab",
                    "description": "This is a test description",
                    "drawerId": "4f318312-84d6-4091-bcb1-cff4766266c9",
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                }
            ]
        }
    ],
    "Drawers": [
        {
            "id": "14f4c057-79da-4863-aa02-3bc918c0af45",
            "stage": 2,
            "queryInterval": 2
        },
        {
            "id": "ca7aadc8-9518-46ed-8652-aa57f315859e",
            "stage": 4,
            "queryInterval": 5
        },
        {
            "id": "ae1a7a74-15d6-45be-b66d-63907c4c1662",
            "stage": 7,
            "queryInterval": 60
        },
        {
            "id": "7bb1b5f2-1e55-457c-8a46-2b0a72a92c4a",
            "stage": 0,
            "queryInterval": 0
        },
        {
            "id": "4f318312-84d6-4091-bcb1-cff4766266c9",
            "stage": 1,
            "queryInterval": 1
        },
        {
            "id": "e31ee57c-27b2-4bb3-ba6c-46a7aab1cadf",
            "stage": 3,
            "queryInterval": 3
        },
        {
            "id": "cb03d329-08ae-4982-b30f-40d8f1b3fd71",
            "stage": 5,
            "queryInterval": 10
        },
        {
            "id": "d4f21553-3beb-48d9-b2c6-7a3cbd5b2274",
            "stage": 6,
            "queryInterval": 30
        },
        {
            "id": "21e8e24d-5879-432f-b8bb-0db6cf38bb17",
            "stage": 8,
            "queryInterval": 90
        }
    ]
}

GET /api/group/:groupId/export


Response

{
    "name": "unit 1",
    "description": "",
    "VocabularyCards": [
        {
            "name": "test vocab",
            "description": "test description",
            "Translations": [
                {
                    "name": "test translation"
                }
            ]
        }
    ]
}

POST /api/import?active=true&activate=false&queryStatus=false (PACKAGE)


Body (without imported query status)

{
    "version": "v1.0.1",
    "type": "vocascan/package",
    "name": "English - German",
    "foreignWordLanguage": "en",
    "translatedWordLanguage": "de",
    "vocabsPerDay": 100,
    "rightWords": 2,
    "Groups": [
        {
            "name": "unit 1",
            "description": "",
            "VocabularyCards": [
                {
                    "name": "test vocab",
                    "description": "test description",
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                }
            ]
        }
    ]
}

Body (with imported query status)
when drawerId is not specified the "activate" property will be used to store the vocab card

{
    "version": "v1.0.1",
    "type": "vocascan/package",
    "name": "Englisch - Deutsch",
    "foreignWordLanguage": "en",
    "translatedWordLanguage": "de",
    "vocabsPerDay": 5,
    "rightWords": 2,
    "Groups": [
        {
            "name": "unit 1",
            "description": "asfsfsf",
            "VocabularyCards": [
                {
                    "name": "test vocab",
                    "description": "This is a test description",
                    "drawerId": "cff3a3e2-3084-4950-a572-502e846a38b8"
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                },
                {
                    "name": "test vocab",
                    "description": "This is a test description",
                    "drawerId": "cff3a3e2-3084-4950-a572-502e846a38b8"
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                },
                {
                    "name": "test vocab",
                    "description": "This is a test description",
                    "drawerId": "36ec80d1-35d9-4404-8523-705b4919e91f", 
                    "Translations": [
                        {
                            "name": "test translation"
                        }
                    ]
                }
            ]
        }
    ],
    "Drawers": [
        {
            "id": "0b846944-5892-4205-b35e-da46264ac5ed",
            "stage": 0,
            "queryInterval": 0
        },
        {
            "id": "36ec80d1-35d9-4404-8523-705b4919e91f",
            "stage": 1,
            "queryInterval": 1
        },
        {
            "id": "be4c9336-faa3-47b5-bc33-cff177695d95",
            "stage": 2,
            "queryInterval": 2
        },
        {
            "id": "dccd2ff5-6810-4391-b17e-b2fd7976054c",
            "stage": 3,
            "queryInterval": 3
        },
        {
            "id": "2cde6dd1-62fd-4e0a-8b98-bcc99caa2c93",
            "stage": 4,
            "queryInterval": 5
        },
        {
            "id": "af37655d-f8c7-4d90-8d5f-5a69d79389ff",
            "stage": 5,
            "queryInterval": 10
        },
        {
            "id": "d831529a-4cf5-4953-a678-1bd87038bbc2",
            "stage": 6,
            "queryInterval": 30
        },
        {
            "id": "10bee574-feb4-4b5a-9cd5-2d32d18c2450",
            "stage": 7,
            "queryInterval": 60
        },
        {
            "id": "cff3a3e2-3084-4950-a572-502e846a38b8",
            "stage": 8,
            "queryInterval": 90
        }
    ]
}

POST /api/import?languagePackageId&active&activate (GROUP)


Body

{
    "name": "unit 1",
    "description": "",
    "VocabularyCards": [
        {
            "name": "test vocab",
            "description": "test description",
            "Translations": [
                {
                    "name": "test translation"
                }
            ]
        },
    ]
}

Motivation and Context

We wanted to have import and export functions to share vocabs among each other, or simply transfer them to another server, by exporting them with their current query status

Screenshots / GIFs (if appropriate):

Checklist

  • I have read the CONTRIBUTING document.
  • I have considered the accessibility of my changes (i.e. did I add proper content descriptions to images, or run my changes with talkback enabled?)
  • I have documented my code if needed

Resolves

@noctera noctera added kind/api kind/enhancement New feature or request labels Jul 18, 2021
@noctera noctera requested a review from luwol03 August 23, 2021 11:38
@luwol03
Copy link
Member

luwol03 commented Aug 26, 2021

can you please fix the ci errors.

app/Controllers/ImportController.js Outdated Show resolved Hide resolved
app/Controllers/ImportController.js Outdated Show resolved Hide resolved
app/Controllers/VocabularyController.js Outdated Show resolved Hide resolved
app/Services/ImportServiceProvider.js Outdated Show resolved Hide resolved
app/Services/ImportServiceProvider.js Outdated Show resolved Hide resolved
routes/api.js Outdated Show resolved Hide resolved
@noctera noctera requested a review from luwol03 September 16, 2021 21:42
Copy link
Member

@luwol03 luwol03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But I think we should add a unique key (maybe the version of the server and unique identifier for vocascan) in the export json to be able to check later when importing if this is really a vocab file.

@noctera
Copy link
Member Author

noctera commented Sep 20, 2021

LGTM. But I think we should add a unique key (maybe the version of the server and unique identifier for vocascan) in the export json to be able to check later when importing if this is really a vocab file.

This is a good idea. When we add the server version as a validation for imports, we can also check if some exportes json files are out of date when some structure will be changing in the future

@noctera
Copy link
Member Author

noctera commented Sep 24, 2021

The version key and the type are now built in.

Copy link
Member

@luwol03 luwol03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We'll merge that PR when the corresponding PR (vocascan/vocascan-desktop#75) is approved.

@luwol03 luwol03 merged commit dea4b16 into experimental Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api kind/enhancement New feature or request
Projects
Status: 🚀 Ready
Development

Successfully merging this pull request may close these issues.

2 participants