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

refactor: 移出导出数据中的 post.user #43

Merged
merged 4 commits into from
Mar 29, 2024
Merged

Conversation

Chilfish
Copy link
Owner

@Chilfish Chilfish commented Mar 29, 2024

将导出格式改为

{
  "user": {},
  "weibo": [],
}

同时还要兼容旧版的导入😅做数据库版本迁移

Copy link

vercel bot commented Mar 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
weibo-archiver ✅ Ready (Inspect) Visit Preview Mar 29, 2024 9:15am

@Chilfish
Copy link
Owner Author

看起来做好了🥳🥳在导入旧数据之前都会先转换到新的格式,有点 trick

if (Array.isArray(data)) {
posts = data.map(post => parseOldPost(post))
const _user = data[0].user as any
// @ts-expect-error bad
user = toRaw(publicStore.users.find(u => u.uid === _user?.id))
if (!user) {
user = {
uid: _user.id,
name: _user.screen_name,
avatar: _user.profile_image_url,
postCount: posts.length,
followers: 0,
followings: 0,
bio: '',
birthday: '',
createdAt: '',
}
}
}
else {
posts = data.weibo
user = data.user
}

@Chilfish Chilfish marked this pull request as ready for review March 29, 2024 09:31
@Chilfish Chilfish merged commit 91ed57e into main Mar 29, 2024
2 checks passed
@Chilfish Chilfish changed the title refactor: 移出导出数据中的 post.user (#42) refactor: 移出导出数据中的 post.user Mar 29, 2024
@Chilfish
Copy link
Owner Author

Chilfish commented Mar 29, 2024

忘了迁移旧数据库里的数据了😅😅

好了:

async function migrateUser() {

@Chilfish Chilfish deleted the refactor-exported-data branch March 29, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant