Skip to content

Commit

Permalink
style: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanHjelsethStorstad committed Nov 22, 2024
1 parent df392c8 commit 2b45305
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
66 changes: 35 additions & 31 deletions src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ export default async function migrateImages(
return migrateImageIdMap
}

type Locations = {
fsLocationOriginal: string,
fsLocationSmallSize: string,
type Locations = {
fsLocationOriginal: string,
fsLocationSmallSize: string,
fsLocationMediumSize: string,
fsLocationLargeSize: string
}
Expand All @@ -183,35 +183,39 @@ async function fetchAllImagesAndUploadToStore<X extends {
}
return acc
}, [[]] as X[][])

const uploadOne = async (image: X) => {
manifest.info(`Migrating image number ${imageCounter++} of ${images.length}`)
const ext = image.originalName.split('.').pop() || ''
const fsLocationDefaultOldVev = `${process.env.VEVEN_STORE_URL}/image/default/${image.name}`
+ `?url=/store/images/${image.name}.${ext}`
const fsLocationMediumOldVev = `${process.env.VEVEN_STORE_URL}/image/resize/${imageSizes.medium}/`
+ `${imageSizes.medium}/${image.name}?url=/store/images/${image.name}.${ext}`
const fsLocationSmallOldVev = `${process.env.VEVEN_STORE_URL}/image/resize/${imageSizes.small}/`
+ `${imageSizes.small}/${image.name}?url=/store/images/${image.name}.${ext}`
const fsLocationLargeOldVev = `${process.env.VEVEN_STORE_URL}/image/resize/${imageSizes.large}/`
+ `${imageSizes.large}/${image.name}?url=/store/images/${image.name}.${ext}`
const fsLocationOriginal = await fetchImageAndUploadToStore(fsLocationDefaultOldVev)
const fsLocationMediumSize = await fetchImageAndUploadToStore(fsLocationMediumOldVev)
const fsLocationSmallSize = await fetchImageAndUploadToStore(fsLocationSmallOldVev)
const fsLocationLargeSize = await fetchImageAndUploadToStore(fsLocationLargeOldVev)
if (!fsLocationOriginal || !fsLocationMediumSize || !fsLocationSmallSize || !fsLocationLargeSize) {
console.error(`Failed to fetch image from ${fsLocationDefaultOldVev}`)
ret.push(null)
} else {
ret.push({
...image,
fsLocationSmallSize,
fsLocationMediumSize,
fsLocationOriginal,
fsLocationLargeSize
})
}
}


for (const imageBatch of imageBatches) {
await Promise.all(imageBatch.map(async image => {
manifest.info(`Migrating image number ${imageCounter++} of ${images.length}`)
const ext = image.originalName.split('.').pop() || ''
const fsLocationDefaultOldVev = `${process.env.VEVEN_STORE_URL}/image/default/${image.name}`
+ `?url=/store/images/${image.name}.${ext}`
const fsLocationMediumOldVev = `${process.env.VEVEN_STORE_URL}/image/resize/${imageSizes.medium}/`
+ `${imageSizes.medium}/${image.name}?url=/store/images/${image.name}.${ext}`
const fsLocationSmallOldVev = `${process.env.VEVEN_STORE_URL}/image/resize/${imageSizes.small}/`
+ `${imageSizes.small}/${image.name}?url=/store/images/${image.name}.${ext}`
const fsLocationLargeOldVev = `${process.env.VEVEN_STORE_URL}/image/resize/${imageSizes.large}/`
+ `${imageSizes.large}/${image.name}?url=/store/images/${image.name}.${ext}`
const fsLocationOriginal = await fetchImageAndUploadToStore(fsLocationDefaultOldVev)
const fsLocationMediumSize = await fetchImageAndUploadToStore(fsLocationMediumOldVev)
const fsLocationSmallSize = await fetchImageAndUploadToStore(fsLocationSmallOldVev)
const fsLocationLargeSize = await fetchImageAndUploadToStore(fsLocationLargeOldVev)
if (!fsLocationOriginal || !fsLocationMediumSize || !fsLocationSmallSize || !fsLocationLargeSize) {
console.error(`Failed to fetch image from ${fsLocationDefaultOldVev}`)
ret.push(null)
} else {
ret.push({
...image,
fsLocationSmallSize,
fsLocationMediumSize,
fsLocationOriginal,
fsLocationLargeSize
})
}
}))
await Promise.all(imageBatch.map(uploadOne))
}
return ret
}
Expand Down
6 changes: 3 additions & 3 deletions src/prisma/prismaservice/src/dobbelOmega/migrateUsers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { PrismaClient as PrismaClientPn, SEX } from '@/generated/pn'
import type { PrismaClient as PrismaClientVeven, enum_Users_sex as SEXVEVEN } from '@/generated/veven'
import type { Limits } from './migrationLimits'
import upsertOrderBasedOnDate from './upsertOrderBasedOnDate'
import { type IdMapper, vevenIdToPnId } from './IdMapper'
import manifest from '@/src/logger'
import type { PrismaClient as PrismaClientPn, SEX } from '@/generated/pn'
import type { PrismaClient as PrismaClientVeven, enum_Users_sex as SEXVEVEN } from '@/generated/veven'
import type { Limits } from './migrationLimits'

/**
* TODO: Need migrate reservations (mail reservations) ?, and flairs
Expand Down

0 comments on commit 2b45305

Please sign in to comment.