Set size to int

This commit is contained in:
jeffvli
2022-10-12 18:21:51 -07:00
parent 99f30439e1
commit 0772566637
3 changed files with 14 additions and 29 deletions
@@ -0,0 +1,9 @@
/*
Warnings:
- The `size` column on the `Song` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- AlterTable
ALTER TABLE "Song" DROP COLUMN "size",
ADD COLUMN "size" INTEGER;
+1 -1
View File
@@ -390,7 +390,7 @@ model Song {
releaseDate DateTime?
releaseYear Int?
duration Float
size String?
size Int?
lyrics String?
bitRate Int
container String
+4 -28
View File
@@ -162,6 +162,7 @@ const insertSongGroup = async (
artists: { connect: artistsConnect },
bitRate: Math.floor(song.MediaSources[0].Bitrate / 1e3),
container: song.MediaSources[0].Container,
deleted: false,
discNumber: song.ParentIndexNumber,
duration: Math.floor(song.MediaSources[0].RunTimeTicks / 1e7),
externals: { connect: externalsConnect },
@@ -179,7 +180,7 @@ const insertSongGroup = async (
remoteId: song.Id,
serverFolders: { connect: { id: serverFolder.id } },
serverId: server.id,
size: String(song.MediaSources[0].Size),
size: song.MediaSources[0].Size,
sortName: song.Name,
trackNumber: song.IndexNumber,
},
@@ -187,6 +188,7 @@ const insertSongGroup = async (
artists: { connect: artistsConnect },
bitRate: Math.floor(song.MediaSources[0].Bitrate / 1e3),
container: song.MediaSources[0].Container,
deleted: false,
discNumber: song.ParentIndexNumber,
duration: Math.floor(song.MediaSources[0].RunTimeTicks / 1e7),
externals: { connect: externalsConnect },
@@ -204,6 +206,7 @@ const insertSongGroup = async (
remoteId: song.Id,
serverFolders: { connect: { id: serverFolder.id } },
serverId: server.id,
size: song.MediaSources[0].Size,
sortName: song.Name,
trackNumber: song.IndexNumber,
},
@@ -216,33 +219,6 @@ const insertSongGroup = async (
};
});
// const artists = uniqBy(
// songs.flatMap((song) => {
// return song.ArtistItems.map((artist) => ({
// deleted: false,
// name: artist.Name,
// remoteId: artist.Id,
// serverFolders: { connect: { id: serverFolder.id } },
// serverId: server.id,
// sortName: '',
// }));
// }),
// 'remoteId'
// );
// for (const artist of artists) {
// await prisma.artist.upsert({
// create: artist,
// update: artist,
// where: {
// uniqueArtistId: {
// remoteId: artist.remoteId,
// serverId: server.id,
// },
// },
// });
// }
const uniqueArtistIds = songs
.flatMap((song) => song.ArtistItems.flatMap((artist) => artist.Id))
.filter(uniqueArray);