🐛 fix: move prisma id generator to service and repo
This commit is contained in:
@ -7,6 +7,7 @@ import { bulkInsertStudiosRepository } from "../repositories/bulkInsertStudios.r
|
||||
import { MediaFullInfoResponse } from "../types/mediaFullInfo.type";
|
||||
import { generateSlug } from "../../../helpers/characters/generateSlug";
|
||||
import { bulkInsertCharWithVAService } from "./internal/bulkInsertCharWithVA.service";
|
||||
import { generateUUIDv7 } from "../../../helpers/databases/uuidv7";
|
||||
|
||||
export const bulkInsertAnimeService = async (malId: number) => {
|
||||
try {
|
||||
@ -20,6 +21,7 @@ export const bulkInsertAnimeService = async (malId: number) => {
|
||||
const insertedCharacters = await bulkInsertCharWithVAService(malId);
|
||||
|
||||
const constructMediaPayload: Prisma.MediaUpsertArgs["create"] = {
|
||||
id: generateUUIDv7(),
|
||||
title: mediaFullInfo.data.title,
|
||||
titleAlternative: (mediaFullInfo.data
|
||||
.titles as unknown) as Prisma.InputJsonValue,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { SystemAccountId } from "../../../../config/account/system";
|
||||
import { getContentReferenceAPI } from "../../../../config/apis/media.reference";
|
||||
import { generateUUIDv7 } from "../../../../helpers/databases/uuidv7";
|
||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||
import { bulkInsertCharactersRepository } from "../../repositories/bulkInsertCharacters.repository";
|
||||
import { bulkInsertLangVARepository } from "../../repositories/bulkInsertLangVA.repository";
|
||||
@ -17,6 +18,7 @@ export const bulkInsertCharWithVAService = async (malId: number) => {
|
||||
for (const charEntry of charactersWithVAData.data) {
|
||||
// Insert character if not exists
|
||||
const characterInsertedId = await bulkInsertCharactersRepository({
|
||||
id: generateUUIDv7(),
|
||||
malId: charEntry.character.mal_id,
|
||||
name: charEntry.character.name,
|
||||
role: charEntry.role,
|
||||
@ -41,6 +43,7 @@ export const bulkInsertCharWithVAService = async (malId: number) => {
|
||||
// Link character with inserted VAs
|
||||
for (const langVA of insertedVAs) {
|
||||
await bulkInsertLangVARepository({
|
||||
id: generateUUIDv7(),
|
||||
language: langVA.lang,
|
||||
vaId: langVA.staffId,
|
||||
charId: characterInsertedId.id,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { SystemAccountId } from "../../../../config/account/system";
|
||||
import { generateUUIDv7 } from "../../../../helpers/databases/uuidv7";
|
||||
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
|
||||
import { bulkInsertVoiceActorRepository } from "../../repositories/bulkInsertVoiceActor.repository";
|
||||
import { Person } from "../../types/mediaCharWithVAInfo";
|
||||
@ -6,6 +7,7 @@ import { Person } from "../../types/mediaCharWithVAInfo";
|
||||
export const bulkInsertStaffOrPeopleService = async (peopleData: Person) => {
|
||||
try {
|
||||
return await bulkInsertVoiceActorRepository({
|
||||
id: generateUUIDv7(),
|
||||
malId: peopleData.mal_id,
|
||||
name: peopleData.name,
|
||||
imageUrl: peopleData.images.jpg.image_url,
|
||||
|
||||
Reference in New Issue
Block a user