added seed script + renamed table fields + added field

This commit is contained in:
daniel31x13
2023-12-22 13:13:43 -05:00
parent 385bdc2343
commit 98106b9f25
15 changed files with 957 additions and 370 deletions
+13 -16
View File
@@ -46,18 +46,15 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
where: { id: link.id },
data: {
type: linkType,
screenshotPath:
user.archiveAsScreenshot &&
!link.screenshotPath?.startsWith("archive")
image:
user.archiveAsScreenshot && !link.image?.startsWith("archive")
? "pending"
: undefined,
pdfPath:
user.archiveAsPDF && !link.pdfPath?.startsWith("archive")
pdf:
user.archiveAsPDF && !link.pdf?.startsWith("archive")
? "pending"
: undefined,
readabilityPath: !link.readabilityPath?.startsWith("archive")
? "pending"
: undefined,
readable: !link.readable?.startsWith("archive") ? "pending" : undefined,
lastPreserved: new Date().toISOString(),
},
});
@@ -107,7 +104,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await prisma.link.update({
where: { id: link.id },
data: {
readabilityPath: `archives/${targetLink.collectionId}/${link.id}_readability.json`,
readable: `archives/${targetLink.collectionId}/${link.id}_readability.json`,
textContent: articleText,
},
});
@@ -156,10 +153,10 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await prisma.link.update({
where: { id: link.id },
data: {
screenshotPath: user.archiveAsScreenshot
image: user.archiveAsScreenshot
? `archives/${linkExists.collectionId}/${link.id}.png`
: undefined,
pdfPath: user.archiveAsPDF
pdf: user.archiveAsPDF
? `archives/${linkExists.collectionId}/${link.id}.pdf`
: undefined,
},
@@ -179,13 +176,13 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
await prisma.link.update({
where: { id: link.id },
data: {
readabilityPath: !finalLink.readabilityPath?.startsWith("archives")
readable: !finalLink.readable?.startsWith("archives")
? "unavailable"
: undefined,
screenshotPath: !finalLink.screenshotPath?.startsWith("archives")
image: !finalLink.image?.startsWith("archives")
? "unavailable"
: undefined,
pdfPath: !finalLink.pdfPath?.startsWith("archives")
pdf: !finalLink.pdf?.startsWith("archives")
? "unavailable"
: undefined,
},
@@ -245,7 +242,7 @@ const imageHandler = async ({ url, id }: Link, extension: string) => {
await prisma.link.update({
where: { id },
data: {
screenshotPath: `archives/${linkExists.collectionId}/${id}.${extension}`,
image: `archives/${linkExists.collectionId}/${id}.${extension}`,
},
});
}
@@ -269,7 +266,7 @@ const pdfHandler = async ({ url, id }: Link) => {
await prisma.link.update({
where: { id },
data: {
pdfPath: `archives/${linkExists.collectionId}/${id}.pdf`,
pdf: `archives/${linkExists.collectionId}/${id}.pdf`,
},
});
}
+7 -10
View File
@@ -1,26 +1,23 @@
export function screenshotAvailable(link: any) {
return (
link &&
link.screenshotPath &&
link.screenshotPath !== "pending" &&
link.screenshotPath !== "unavailable"
link.image &&
link.image !== "pending" &&
link.image !== "unavailable"
);
}
export function pdfAvailable(link: any) {
return (
link &&
link.pdfPath &&
link.pdfPath !== "pending" &&
link.pdfPath !== "unavailable"
link && link.pdf && link.pdf !== "pending" && link.pdf !== "unavailable"
);
}
export function readabilityAvailable(link: any) {
return (
link &&
link.readabilityPath &&
link.readabilityPath !== "pending" &&
link.readabilityPath !== "unavailable"
link.readable &&
link.readable !== "pending" &&
link.readable !== "unavailable"
);
}