mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
feat(import): bring the account's own mood vocabulary along
A full backup carries the account's own mood tags, rated factors and tag groups, and the JSON import left them out: a mood entry imported into another account landed without every link to a tag the person had made. Before the entries are written, every key they or the file name is resolved once. A catalogue tag or one the account owns is used as it is; an own tag whose label the file states differently is kept, never overwritten, and named in keptMoodTagKeys (keptMoodCategoryKeys for a group). A tag the file defines and the account lacks is created in its group, the group created the same way, within the account's caps of 50 tags and 12 groups. A key another account of the server holds comes over under a key derived from the account and the file's key, so a second import of the same file finds the copy instead of minting another. The links are written through that resolution, own rated factors included, inside the entry's transaction; anything unresolved is still dropped and named. The import card names kept keys in all nine locales. The field-coverage guard now holds the backup's customMoodTags and customMoodTagCategories to the import schema. The round trip moves a backup to another server (the same seeded catalogue, none of the account's rows), imports it into a fresh account and compares the re-export, own tags, group and rated factor included; a second case imports into another account of the same server, and a third keeps a renamed own tag.
This commit is contained in:
1 parent
d1545cf554
commit
2357807706
25 files changed
+995
-67
No files matched your search
@@ -56,10 +56,14 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
stats: written,
|
||||
writeFailed,
|
||||
droppedLinkKeys,
|
||||
keptMoodTagKeys,
|
||||
keptMoodCategoryKeys,
|
||||
} = await runJsonImport({
|
||||
userId: user.id,
|
||||
measurements: parsed.data.measurements,
|
||||
moodEntries: parsed.data.moodEntries,
|
||||
customMoodTagCategories: parsed.data.customMoodTagCategories,
|
||||
customMoodTags: parsed.data.customMoodTags,
|
||||
ipAddress: getClientIp(request),
|
||||
});
|
||||
const stats = {
|
||||
@@ -68,6 +72,10 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
// The mood links the account could not resolve, by key, only when there
|
||||
// are any: "imported" alone told the person their tags had landed.
|
||||
...droppedLinkKeysForWire(droppedLinkKeys),
|
||||
// The account's own tags and groups the file names differently: kept as
|
||||
// they are, and said so, only when there are any.
|
||||
...(keptMoodTagKeys.length > 0 ? { keptMoodTagKeys } : {}),
|
||||
...(keptMoodCategoryKeys.length > 0 ? { keptMoodCategoryKeys } : {}),
|
||||
};
|
||||
|
||||
if (writeFailed) {
|
||||
|
||||
Reference in new issue
Block a user