added seed script + renamed table fields + added field
This commit is contained in:
parent
385bdc2343
commit
98106b9f25
|
@ -25,9 +25,10 @@ export default function NewLinkModal({ onClose }: Props) {
|
|||
description: "",
|
||||
type: "url",
|
||||
tags: [],
|
||||
screenshotPath: "",
|
||||
pdfPath: "",
|
||||
readabilityPath: "",
|
||||
preview: "",
|
||||
image: "",
|
||||
pdf: "",
|
||||
readable: "",
|
||||
textContent: "",
|
||||
collection: {
|
||||
name: "",
|
||||
|
|
|
@ -70,12 +70,12 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
|||
const isReady = () => {
|
||||
return (
|
||||
collectionOwner.archiveAsScreenshot ===
|
||||
(link && link.pdfPath && link.pdfPath !== "pending") &&
|
||||
(link && link.pdf && link.pdf !== "pending") &&
|
||||
collectionOwner.archiveAsPDF ===
|
||||
(link && link.pdfPath && link.pdfPath !== "pending") &&
|
||||
(link && link.pdf && link.pdf !== "pending") &&
|
||||
link &&
|
||||
link.readabilityPath &&
|
||||
link.readabilityPath !== "pending"
|
||||
link.readable &&
|
||||
link.readable !== "pending"
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -107,7 +107,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
|||
clearInterval(interval);
|
||||
}
|
||||
};
|
||||
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]);
|
||||
}, [link?.image, link?.pdf, link?.readable]);
|
||||
|
||||
const updateArchive = async () => {
|
||||
const load = toast.loading("Sending request...");
|
||||
|
@ -154,7 +154,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
|||
name={"Screenshot"}
|
||||
icon={"bi-file-earmark-image"}
|
||||
format={
|
||||
link?.screenshotPath?.endsWith("png")
|
||||
link?.image?.endsWith("png")
|
||||
? ArchivedFormat.png
|
||||
: ArchivedFormat.jpeg
|
||||
}
|
||||
|
|
|
@ -27,9 +27,10 @@ export default function UploadFileModal({ onClose }: Props) {
|
|||
description: "",
|
||||
type: "url",
|
||||
tags: [],
|
||||
screenshotPath: "",
|
||||
pdfPath: "",
|
||||
readabilityPath: "",
|
||||
preview: "",
|
||||
image: "",
|
||||
pdf: "",
|
||||
readable: "",
|
||||
textContent: "",
|
||||
collection: {
|
||||
name: "",
|
||||
|
|
|
@ -43,7 +43,7 @@ export default function PreservedFormatRow({
|
|||
})();
|
||||
|
||||
let interval: any;
|
||||
if (link?.screenshotPath === "pending" || link?.pdfPath === "pending") {
|
||||
if (link?.image === "pending" || link?.pdf === "pending") {
|
||||
interval = setInterval(async () => {
|
||||
const data = await getLink(link.id as number, isPublic);
|
||||
setLink(
|
||||
|
@ -61,7 +61,7 @@ export default function PreservedFormatRow({
|
|||
clearInterval(interval);
|
||||
}
|
||||
};
|
||||
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]);
|
||||
}, [link?.image, link?.pdf, link?.readable]);
|
||||
|
||||
const handleDownload = () => {
|
||||
const path = `/api/v1/archives/${link?.id}?format=${format}`;
|
||||
|
|
|
@ -62,12 +62,12 @@ export default function ReadableView({ link }: Props) {
|
|||
let interval: any;
|
||||
if (
|
||||
link &&
|
||||
(link?.screenshotPath === "pending" ||
|
||||
link?.pdfPath === "pending" ||
|
||||
link?.readabilityPath === "pending" ||
|
||||
!link?.screenshotPath ||
|
||||
!link?.pdfPath ||
|
||||
!link?.readabilityPath)
|
||||
(link?.image === "pending" ||
|
||||
link?.pdf === "pending" ||
|
||||
link?.readable === "pending" ||
|
||||
!link?.image ||
|
||||
!link?.pdf ||
|
||||
!link?.readable)
|
||||
) {
|
||||
interval = setInterval(() => getLink(link.id as number), 5000);
|
||||
} else {
|
||||
|
@ -81,7 +81,7 @@ export default function ReadableView({ link }: Props) {
|
|||
clearInterval(interval);
|
||||
}
|
||||
};
|
||||
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]);
|
||||
}, [link?.image, link?.pdf, link?.readable]);
|
||||
|
||||
const rgbToHex = (r: number, g: number, b: number): string =>
|
||||
"#" +
|
||||
|
@ -225,7 +225,7 @@ export default function ReadableView({ link }: Props) {
|
|||
</div>
|
||||
|
||||
<div className="flex flex-col gap-5 h-full">
|
||||
{link?.readabilityPath?.startsWith("archives") ? (
|
||||
{link?.readable?.startsWith("archives") ? (
|
||||
<div
|
||||
className="line-break px-1 reader-view"
|
||||
dangerouslySetInnerHTML={{
|
||||
|
@ -235,9 +235,7 @@ export default function ReadableView({ link }: Props) {
|
|||
) : (
|
||||
<div
|
||||
className={`w-full h-full flex flex-col justify-center p-10 ${
|
||||
link?.readabilityPath === "pending" || !link?.readabilityPath
|
||||
? "skeleton"
|
||||
: ""
|
||||
link?.readable === "pending" || !link?.readable ? "skeleton" : ""
|
||||
}`}
|
||||
>
|
||||
<svg
|
||||
|
|
|
@ -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")
|
||||
? "pending"
|
||||
: undefined,
|
||||
readabilityPath: !link.readabilityPath?.startsWith("archive")
|
||||
pdf:
|
||||
user.archiveAsPDF && !link.pdf?.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`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
"author": "Daniel31X13 <daniel31x13@gmail.com>",
|
||||
"license": "AGPL-3.0",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "node ./prisma/seed.js"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"worker": "ts-node --skip-project scripts/worker.ts",
|
||||
|
|
|
@ -125,7 +125,7 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
|||
// await prisma.link.update({
|
||||
// where: { id: linkId },
|
||||
// data: {
|
||||
// screenshotPath: `archives/${collectionPermissions?.id}/${
|
||||
// image: `archives/${collectionPermissions?.id}/${
|
||||
// linkId + suffix
|
||||
// }`,
|
||||
// lastPreserved: new Date().toISOString(),
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -73,9 +73,9 @@ const deleteArchivedFiles = async (link: Link & { collection: Collection }) => {
|
|||
id: link.id,
|
||||
},
|
||||
data: {
|
||||
screenshotPath: null,
|
||||
pdfPath: null,
|
||||
readabilityPath: null,
|
||||
image: null,
|
||||
pdf: null,
|
||||
readable: null,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `pdf` on the `Link` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `readable` on the `Link` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `screenshotPath` on the `Link` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Link" RENAME COLUMN "screenshotPath" TO "image";
|
||||
ALTER TABLE "Link" RENAME COLUMN "pdfPath" TO "pdf";
|
||||
ALTER TABLE "Link" RENAME COLUMN "readabilityPath" TO "readable";
|
||||
ALTER TABLE "Link" ADD COLUMN "preview" TEXT;
|
|
@ -46,7 +46,7 @@ model User {
|
|||
archiveAsWaybackMachine Boolean @default(false)
|
||||
isPrivate Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
}
|
||||
|
||||
model WhitelistedUser {
|
||||
|
@ -55,7 +55,7 @@ model WhitelistedUser {
|
|||
User User? @relation(fields: [userId], references: [id])
|
||||
userId Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
|
@ -63,7 +63,7 @@ model VerificationToken {
|
|||
token String @unique
|
||||
expires DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ model Collection {
|
|||
members UsersAndCollections[]
|
||||
links Link[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@unique([name, ownerId])
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ model UsersAndCollections {
|
|||
canUpdate Boolean
|
||||
canDelete Boolean
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@id([userId, collectionId])
|
||||
}
|
||||
|
@ -109,12 +109,13 @@ model Link {
|
|||
tags Tag[]
|
||||
url String?
|
||||
textContent String?
|
||||
screenshotPath String?
|
||||
pdfPath String?
|
||||
readabilityPath String?
|
||||
preview String?
|
||||
image String?
|
||||
pdf String?
|
||||
readable String?
|
||||
lastPreserved DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
}
|
||||
|
||||
model Tag {
|
||||
|
@ -124,7 +125,7 @@ model Tag {
|
|||
owner User @relation(fields: [ownerId], references: [id])
|
||||
ownerId Int
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@unique([name, ownerId])
|
||||
}
|
||||
|
@ -138,7 +139,7 @@ model Subscription {
|
|||
user User @relation(fields: [userId], references: [id])
|
||||
userId Int @unique
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
}
|
||||
|
||||
model ApiKey {
|
||||
|
@ -150,7 +151,7 @@ model ApiKey {
|
|||
expires DateTime
|
||||
lastUsedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@unique([token, userId])
|
||||
}
|
||||
|
|
|
@ -0,0 +1,571 @@
|
|||
// A dirty script to seed the database with some data
|
||||
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
const bcrypt = require("bcrypt");
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const saltRounds = 10;
|
||||
const defaultPassword = "11111111";
|
||||
const hashedPassword = bcrypt.hashSync(defaultPassword, saltRounds);
|
||||
|
||||
// Subscription dates
|
||||
const currentPeriodStart = new Date();
|
||||
const currentPeriodEnd = new Date();
|
||||
currentPeriodEnd.setFullYear(currentPeriodEnd.getFullYear() + 10);
|
||||
|
||||
// Operations to be executed within a transaction
|
||||
const transaction = await prisma.$transaction(async (prisma) => {
|
||||
// Create users with subscriptions
|
||||
const user1 = await prisma.user.create({
|
||||
data: {
|
||||
name: "John Doe",
|
||||
username: "user1",
|
||||
email: "user1@example.com",
|
||||
emailVerified: new Date(),
|
||||
password: hashedPassword,
|
||||
subscriptions: {
|
||||
create: {
|
||||
stripeSubscriptionId: "sub_4323",
|
||||
active: true,
|
||||
currentPeriodStart,
|
||||
currentPeriodEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const user2 = await prisma.user.create({
|
||||
data: {
|
||||
name: "Mary Smith",
|
||||
username: "user2",
|
||||
email: "user2@example.com",
|
||||
emailVerified: new Date(),
|
||||
password: hashedPassword,
|
||||
subscriptions: {
|
||||
create: {
|
||||
stripeSubscriptionId: "sub_5435",
|
||||
active: true,
|
||||
currentPeriodStart,
|
||||
currentPeriodEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const user3 = await prisma.user.create({
|
||||
data: {
|
||||
name: "Linda Jones",
|
||||
username: "user3",
|
||||
email: "user3@example.com",
|
||||
emailVerified: new Date(),
|
||||
password: hashedPassword,
|
||||
subscriptions: {
|
||||
create: {
|
||||
stripeSubscriptionId: "sub_6435",
|
||||
active: true,
|
||||
currentPeriodStart,
|
||||
currentPeriodEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const user4 = await prisma.user.create({
|
||||
data: {
|
||||
name: "Betty Sanchez",
|
||||
username: "user4",
|
||||
email: "user4@example.com",
|
||||
emailVerified: new Date(),
|
||||
password: hashedPassword,
|
||||
subscriptions: {
|
||||
create: {
|
||||
stripeSubscriptionId: "sub_7868",
|
||||
active: true,
|
||||
currentPeriodStart,
|
||||
currentPeriodEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const user5 = await prisma.user.create({
|
||||
data: {
|
||||
name: "Jeffrey Edwards",
|
||||
username: "user5",
|
||||
email: "user5@example.com",
|
||||
emailVerified: new Date(),
|
||||
password: hashedPassword,
|
||||
subscriptions: {
|
||||
create: {
|
||||
stripeSubscriptionId: "sub_5653",
|
||||
active: true,
|
||||
currentPeriodStart,
|
||||
currentPeriodEnd,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Define and create collections
|
||||
const collectionsUser1 = [
|
||||
{
|
||||
name: "Health and Wellness",
|
||||
description: "Latest articles on health and wellness.",
|
||||
ownerId: user1.id,
|
||||
color: "#ff1100",
|
||||
},
|
||||
{
|
||||
name: "Research",
|
||||
description: "Latest articles on research.",
|
||||
ownerId: user1.id,
|
||||
color: "#000dff",
|
||||
},
|
||||
{
|
||||
name: "Technology",
|
||||
description: "Latest articles on technology.",
|
||||
ownerId: user1.id,
|
||||
color: "#0080ff",
|
||||
},
|
||||
{
|
||||
name: "Personal Finance",
|
||||
description: "Latest articles on personal finance.",
|
||||
ownerId: user1.id,
|
||||
color: "#00ff40",
|
||||
},
|
||||
{
|
||||
name: "Productivity",
|
||||
description: "Latest articles on productivity.",
|
||||
ownerId: user1.id,
|
||||
color: "#ff00f7",
|
||||
},
|
||||
{
|
||||
name: "Recipes",
|
||||
description: "Latest recipes.",
|
||||
ownerId: user1.id,
|
||||
color: "#eeff00",
|
||||
},
|
||||
];
|
||||
|
||||
const collectionsUser2 = [
|
||||
{
|
||||
name: "Project Alpha",
|
||||
description: "Articles for Project Alpha.",
|
||||
ownerId: user2.id,
|
||||
},
|
||||
];
|
||||
|
||||
const user1Collections = await Promise.all(
|
||||
collectionsUser1.map((c) => prisma.collection.create({ data: c }))
|
||||
);
|
||||
|
||||
const user2Collections = await Promise.all(
|
||||
collectionsUser2.map((c) => prisma.collection.create({ data: c }))
|
||||
);
|
||||
|
||||
// Share one collection between users with permissions
|
||||
await Promise.allSettled([
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user1.id,
|
||||
collectionId: user2Collections[0].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user2.id,
|
||||
collectionId: user1Collections[1].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user3.id,
|
||||
collectionId: user1Collections[1].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user4.id,
|
||||
collectionId: user1Collections[1].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user5.id,
|
||||
collectionId: user1Collections[1].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user2.id,
|
||||
collectionId: user2Collections[0].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user3.id,
|
||||
collectionId: user2Collections[0].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
prisma.usersAndCollections.create({
|
||||
data: {
|
||||
userId: user2.id,
|
||||
collectionId: user1Collections[0].id,
|
||||
canCreate: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
let projectAlphaCollection = await prisma.collection.findFirst({
|
||||
where: {
|
||||
name: "Project Alpha",
|
||||
ownerId: user2.id,
|
||||
},
|
||||
});
|
||||
|
||||
const projectAlphaLinks = [
|
||||
{
|
||||
name: "More than 10,000 research papers were retracted in 2023 — a new record",
|
||||
url: "https://www.nature.com/articles/d41586-023-03974-8",
|
||||
},
|
||||
{
|
||||
name: "Advances in Liver Cancer Research",
|
||||
url: "https://www.cancer.gov/types/liver/research",
|
||||
},
|
||||
{
|
||||
name: "NEW RESEARCH REVEALS TOP AI TOOLS UTILIZED BY MUSIC PRODUCERS",
|
||||
url: "https://edm.com/gear-tech/top-ai-tools-music-producers",
|
||||
},
|
||||
{
|
||||
name: "New Google research: What we now know about 'decoding' consumer decision-making",
|
||||
url: "https://www.thinkwithgoogle.com/intl/en-emea/consumer-insights/consumer-journey/the-consumer-decision-making-process/",
|
||||
},
|
||||
{
|
||||
name: "Drug Overdose Death Rates",
|
||||
url: "https://nida.nih.gov/research-topics/trends-statistics/overdose-death-rates",
|
||||
},
|
||||
{
|
||||
name: "Explore the latest research making an impact in your field",
|
||||
url: "https://biologue.plos.org/2023/10/25/latest-biological-science-research/",
|
||||
},
|
||||
];
|
||||
|
||||
for (const link of projectAlphaLinks) {
|
||||
await prisma.link.create({
|
||||
data: {
|
||||
name: link.name,
|
||||
url: link.url,
|
||||
collectionId: projectAlphaCollection.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
for (const [collectionName, links] of Object.entries(linksAndCollections)) {
|
||||
let collection = await prisma.collection.findFirst({
|
||||
where: {
|
||||
name: collectionName,
|
||||
ownerId: user1.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!collection) {
|
||||
collection = await prisma.collection.create({
|
||||
data: {
|
||||
name: collectionName,
|
||||
ownerId: user1.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
for (const link of links) {
|
||||
await prisma.link.create({
|
||||
data: {
|
||||
name: link.name,
|
||||
url: link.url,
|
||||
collectionId: collection.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const tags = [
|
||||
{ name: "technology", ownerId: user1.id },
|
||||
{ name: "finance", ownerId: user1.id },
|
||||
{ name: "future", ownerId: user1.id },
|
||||
{ name: "health", ownerId: user1.id },
|
||||
{ name: "hacks", ownerId: user1.id },
|
||||
{ name: "lifestyle", ownerId: user1.id },
|
||||
{ name: "routine", ownerId: user1.id },
|
||||
{ name: "personal", ownerId: user1.id },
|
||||
];
|
||||
});
|
||||
|
||||
return transaction;
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
const linksAndCollections = {
|
||||
"Health and Wellness": [
|
||||
{
|
||||
name: "50 Wellness Gifts for Anyone Who Could Use Some Self-Care",
|
||||
url: "https://www.self.com/gallery/healthy-gift-ideas-for-wellness-gurus",
|
||||
},
|
||||
{
|
||||
name: "Hearing aids slow cognitive decline in people at high risk",
|
||||
url: "https://www.nih.gov/news-events/nih-research-matters/hearing-aids-slow-cognitive-decline-people-high-risk",
|
||||
},
|
||||
{
|
||||
name: "Why Are Healthy Habits Important at Work and Home?",
|
||||
url: "https://info.totalwellnesshealth.com/blog/why-are-healthy-habits-important",
|
||||
},
|
||||
{
|
||||
name: "Wellness Travel BC explores shifting travel trends as health and wellness take center stage for Canadians",
|
||||
url: "https://www.vancouverisawesome.com/sponsored/wellness-travel-bc-explores-shifting-travel-trends-as-health-and-wellness-take-center-stage-for-canadians-8004505",
|
||||
},
|
||||
{
|
||||
name: "50 Wellness Gifts for Anyone Who Could Use Some Self-Care",
|
||||
url: "https://www.self.com/gallery/healthy-gift-ideas-for-wellness-gurus",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
],
|
||||
Research: [
|
||||
{
|
||||
name: "More than 10,000 research papers were retracted in 2023 — a new record",
|
||||
url: "https://www.nature.com/articles/d41586-023-03974-8",
|
||||
},
|
||||
{
|
||||
name: "Advances in Liver Cancer Research",
|
||||
url: "https://www.cancer.gov/types/liver/research",
|
||||
},
|
||||
{
|
||||
name: "NEW RESEARCH REVEALS TOP AI TOOLS UTILIZED BY MUSIC PRODUCERS",
|
||||
url: "https://edm.com/gear-tech/top-ai-tools-music-producers",
|
||||
},
|
||||
{
|
||||
name: "New Google research: What we now know about 'decoding' consumer decision-making",
|
||||
url: "https://www.thinkwithgoogle.com/intl/en-emea/consumer-insights/consumer-journey/the-consumer-decision-making-process/",
|
||||
},
|
||||
{
|
||||
name: "Drug Overdose Death Rates",
|
||||
url: "https://nida.nih.gov/research-topics/trends-statistics/overdose-death-rates",
|
||||
},
|
||||
{
|
||||
name: "Explore the latest research making an impact in your field",
|
||||
url: "https://biologue.plos.org/2023/10/25/latest-biological-science-research/",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
],
|
||||
Technology: [
|
||||
{
|
||||
name: "These six questions will dictate the future of generative AI",
|
||||
url: "https://www.technologyreview.com/2023/12/19/1084505/generative-ai-artificial-intelligence-bias-jobs-copyright-misinformation/",
|
||||
},
|
||||
{
|
||||
name: "Q&A: People will only use technology they trust, Microsoft expert says",
|
||||
url: "https://www.euronews.com/next/2023/12/21/qa-people-will-only-use-technology-they-trust-microsoft-expert-says",
|
||||
},
|
||||
{
|
||||
name: "How technology and economics can help save endangered species",
|
||||
url: "https://news.osu.edu/how-technology-and-economics-can-help-save-endangered-species/",
|
||||
},
|
||||
{
|
||||
name: "How technology can help save Indigenous forests – and our planet",
|
||||
url: "https://www.eco-business.com/opinion/how-technology-can-help-save-indigenous-forests-and-our-planet/",
|
||||
},
|
||||
{
|
||||
name: "The most energy-efficient way to build homes",
|
||||
url: "https://www.technologyreview.com/2023/12/22/1084532/passive-house-energy-efficient-harold-orr/",
|
||||
},
|
||||
{
|
||||
name: "Using virtual reality to diagnose Alzheimer's disease",
|
||||
url: "https://www.bbc.com/news/technology-67794645",
|
||||
},
|
||||
],
|
||||
"Personal Finance": [
|
||||
{
|
||||
name: "Turn your home’s empty bedroom into $875 in monthly rent",
|
||||
url: "https://www.theglobeandmail.com/investing/personal-finance/household-finances/article-turn-your-homes-empty-bedroom-into-875-in-monthly-rent/",
|
||||
},
|
||||
{
|
||||
name: "Don’t let financial constraints slow down your gift-giving",
|
||||
url: "https://www.thespec.com/life/personal-finance/don-t-let-financial-constraints-slow-down-your-gift-giving/article_e3c99ac5-912c-59a9-a815-654befcd4c9c.html",
|
||||
},
|
||||
{
|
||||
name: "The worst retirement planning mistakes you should avoid, according to an expert",
|
||||
url: "https://www.ctvnews.ca/business/the-worst-retirement-planning-mistakes-you-should-avoid-according-to-an-expert-1.6694093",
|
||||
},
|
||||
{
|
||||
name: "What to Do About That Credit-Card Debt",
|
||||
url: "https://www.thecut.com/2023/12/what-to-do-about-that-credit-card-debt.html",
|
||||
},
|
||||
{
|
||||
name: "How to become rich: Nine golden personal finance rules that may help you make money",
|
||||
url: "https://www.livemint.com/money/personal-finance/how-to-become-rich-nine-golden-personal-finance-rules-that-may-help-you-make-money-11703059139843.html",
|
||||
},
|
||||
{
|
||||
name: "Saving Money: Smart Strategies for Keeping Your Financial New Years’ Resolutions",
|
||||
url: "https://www.tipranks.com/news/personal-finance/saving-money-smart-strategies-for-keeping-your-financial-new-years-resolutions",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
],
|
||||
Productivity: [
|
||||
{
|
||||
name: "Efficiency Vs. Productivity At Work: How To Balance Both",
|
||||
url: "https://www.forbes.com/sites/carolinecastrillon/2023/12/20/efficiency-vs-productivity-at-work-how-to-increase-both/?sh=4c7d486f1bee",
|
||||
},
|
||||
{
|
||||
name: "Is it worth measuring software developer productivity? CIOs weigh in",
|
||||
url: "https://www.cio.com/article/1255774/is-it-worth-measuring-software-developer-productivity-cios-weigh-in.html",
|
||||
},
|
||||
{
|
||||
name: "Avoid These 10 Business Habits to Increase Workplace Productivity",
|
||||
url: "https://www.entrepreneur.com/growing-a-business/10-bad-business-habits-that-destroy-productivity/466381",
|
||||
},
|
||||
{
|
||||
name: "The value of productivity",
|
||||
url: "https://www.tribuneindia.com/news/musings/the-value-of-productivity-573858",
|
||||
},
|
||||
{
|
||||
name: "This new Canonical feature solves my biggest problem with online productivity apps",
|
||||
url: "https://www.zdnet.com/article/canonical-will-soon-make-it-even-easier-to-work-with-google-workspace-and-office-365-online/",
|
||||
},
|
||||
{
|
||||
name: "10 Practical Recommendations for Increasing Work Results and Value",
|
||||
url: "https://www.inc.com/martin-zwilling/10-practical-recommendations-for-increasing-work-results-value.html",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
],
|
||||
Recipes: [
|
||||
{
|
||||
name: "Joe Woodhouse’s vegetarian standouts for Christmas day – recipes",
|
||||
url: "https://www.theguardian.com/food/2023/dec/22/joe-woodhouses-vegetarian-standouts-for-christmas-day-recipes",
|
||||
},
|
||||
{
|
||||
name: "10 cookie recipes to bake for your holiday party",
|
||||
url: "https://www.deseret.com/2023/12/21/24009656/best-holiday-cookie-recipes",
|
||||
},
|
||||
{
|
||||
name: "The Best Potato Recipes for Holiday Season and Beyond, According to Eater Staff",
|
||||
url: "https://www.eater.com/24003490/the-best-potato-recipes-for-holiday-season-and-beyond-according-to-eater-staff",
|
||||
},
|
||||
{
|
||||
name: "The Most-Saved Recipes in the Epicurious App This Week",
|
||||
url: "https://www.epicurious.com/recipes-menus/most-saved-recipes",
|
||||
},
|
||||
{
|
||||
name: "11 Brand-New Recipes to Try This Month",
|
||||
url: "https://www.tasteofhome.com/collection/new-recipes-to-try/",
|
||||
},
|
||||
{
|
||||
name: "19 Baked Pasta Recipes for Golden, Gooey Comfort",
|
||||
url: "https://www.bonappetit.com/gallery/baked-pasta-recipes",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "Example",
|
||||
url: "https://example.com",
|
||||
},
|
||||
],
|
||||
};
|
|
@ -23,7 +23,7 @@ async function processBatch() {
|
|||
archiveAsScreenshot: true,
|
||||
},
|
||||
},
|
||||
screenshotPath: null,
|
||||
image: null,
|
||||
},
|
||||
{
|
||||
collection: {
|
||||
|
@ -31,7 +31,7 @@ async function processBatch() {
|
|||
archiveAsScreenshot: true,
|
||||
},
|
||||
},
|
||||
screenshotPath: "pending",
|
||||
image: "pending",
|
||||
},
|
||||
///////////////////////
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ async function processBatch() {
|
|||
archiveAsPDF: true,
|
||||
},
|
||||
},
|
||||
pdfPath: null,
|
||||
pdf: null,
|
||||
},
|
||||
{
|
||||
collection: {
|
||||
|
@ -48,14 +48,14 @@ async function processBatch() {
|
|||
archiveAsPDF: true,
|
||||
},
|
||||
},
|
||||
pdfPath: "pending",
|
||||
pdf: "pending",
|
||||
},
|
||||
///////////////////////
|
||||
{
|
||||
readabilityPath: null,
|
||||
readable: null,
|
||||
},
|
||||
{
|
||||
readabilityPath: "pending",
|
||||
readable: "pending",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ async function processBatch() {
|
|||
archiveAsScreenshot: true,
|
||||
},
|
||||
},
|
||||
screenshotPath: null,
|
||||
image: null,
|
||||
},
|
||||
{
|
||||
collection: {
|
||||
|
@ -88,7 +88,7 @@ async function processBatch() {
|
|||
archiveAsScreenshot: true,
|
||||
},
|
||||
},
|
||||
screenshotPath: "pending",
|
||||
image: "pending",
|
||||
},
|
||||
///////////////////////
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ async function processBatch() {
|
|||
archiveAsPDF: true,
|
||||
},
|
||||
},
|
||||
pdfPath: null,
|
||||
pdf: null,
|
||||
},
|
||||
{
|
||||
collection: {
|
||||
|
@ -105,14 +105,14 @@ async function processBatch() {
|
|||
archiveAsPDF: true,
|
||||
},
|
||||
},
|
||||
pdfPath: "pending",
|
||||
pdf: "pending",
|
||||
},
|
||||
///////////////////////
|
||||
{
|
||||
readabilityPath: null,
|
||||
readable: null,
|
||||
},
|
||||
{
|
||||
readabilityPath: "pending",
|
||||
readable: "pending",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
Ŝarĝante…
Reference in New Issue