-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
π¨ refactor the importer #8473
π¨ refactor the importer #8473
Conversation
fca228e
to
12a3056
Compare
refs TryGhost#5422 - the new editor added the support for none null titles (null -> `(untitled)`) - all import tests relied on post.title null -> fails - we can support null titles after this PR if we want
no issue - this implementation was wrong
refs TryGhost#5422 - it was only supported to add roles by id e.g. roles = [1] or by object e.g. roles = [{....}] - we use the name strategy also for tags e.g. tags = ['my-tag'] - we support this for roles as well, this makes it easier when importing related user roles (because usually roles already exists in the database and the related id's are wrong e.g. roles_users)
refs TryGhost#5422 - if the json file contains null values for created_at/updated_at - can be handled on model layer and not on the importer layer
refs TryGhost#5422 - post or tag slugs are always safe strings - if e.g. you import a null slug, we can handle this, no need to crash or to cover this on import layer
refs TryGhost#5422 - basically nothing has changed here, just the none usage of the old importer and the result of problems/warnings while importing
12a3056
to
f9c2691
Compare
refs TryGhost#5422 - this is the new integration of the importer - i have used a class inheritance mechanismn to achieve an easier readability and maintenace - most of the logic bits were copied from the old importer or modified/easified - here a list: - schema validation (happens on model layer) was ignored - allow to import unknown user id's (see TryGhost#8365) - most of the duplication handling happens on model layer (we can use the power of unique fields and errors from the database) - this PR has not concentrated on clear error messages or logs (this comes tomorrow) - i've added debug messages - the import is splitted into three steps: - beforeImport --> prepares the data to import, sorts out relations (roles, tags), detects fields (for LTS) - doImport --> does the actual import - afterImport --> updates the data after successful import e.g. update all user reference fields e.g. published_by (compares the imported data with the current state of the database) --> the background why we are doing it after the import is that we don't have to write complicated logic to detect outdated user references before we know which user get's which id --> plus: we don't care about the order of inserting the data --> keep in mind: we never ever import id's, that's why user references are usually outdated --> e.g. you import a post with `published_by:2`, but user 2 get's a new ObjectId 'X', we have to update the reference
refs TryGhost#5422 - simply move to the correct folder
refs TryGhost#5422 - the markdown field will be removed soon, see TryGhost#8479 - if you import images the importer crashes if markdown is null e.g. the welcome post has no markdown field anymore (results in null)
f9c2691
to
81be4e3
Compare
This is ready for review. I hope you find some issues with my PR, hard to cover every case alone. Everything should work like before (+ even more cases are supported). Don't be confused about the missing menu when importing a database, see #8307 |
ef84651
to
95df9ab
Compare
- will show the user why entries weren't imported - e.g. Entry was ignored. We found a duplicate.
- return entry context objects as pretty json - do not return warnings for role duplications, no helpful information
95df9ab
to
367cddf
Compare
- we show the affected json entries as one line in the UI
- if you have a post with duplicated tags, we tell you, so that you know
812bd48
to
957099a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and LGTM
refs #5422
π βπ»
goals
we have two importer implementations, get rid of the old importer and continue with the new importer logic
remove unneeded logic to import specific cases (the specific cases are still supported, just a little bit smarter)
notes
todo's