mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-28 22:31:22 -05:00
fa public
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
const getFreeAgentPosts = (
|
||||
testUserId: number
|
||||
testUserId: number,
|
||||
otherUserIds: number[]
|
||||
): Prisma.FreeAgentPostCreateArgs["data"][] => {
|
||||
return [
|
||||
const result: Prisma.FreeAgentPostCreateArgs["data"][] = [
|
||||
{
|
||||
canVC: "YES",
|
||||
content:
|
||||
@@ -16,6 +17,21 @@ const getFreeAgentPosts = (
|
||||
playstyles: ["FRONTLINE", "MIDLINE"],
|
||||
},
|
||||
];
|
||||
|
||||
otherUserIds
|
||||
.map((id) => ({
|
||||
canVC: "MAYBE" as const,
|
||||
content: `User with id ${id} ready to be recruited`,
|
||||
playstyles: ["BACKLINE"] as "BACKLINE"[],
|
||||
user: {
|
||||
connect: {
|
||||
id,
|
||||
},
|
||||
},
|
||||
}))
|
||||
.forEach((fa) => result.push(fa));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export default getFreeAgentPosts;
|
||||
|
||||
@@ -9,7 +9,7 @@ const main = async () => {
|
||||
throwIfNotLocalhost();
|
||||
await deleteExistingRecords();
|
||||
|
||||
const [testUser] = await Promise.all(
|
||||
const [testUser, ...otherUsers] = await Promise.all(
|
||||
getUsers().map((data) =>
|
||||
prisma.user.create({
|
||||
data,
|
||||
@@ -35,8 +35,10 @@ const main = async () => {
|
||||
|
||||
console.log("Builds created");
|
||||
|
||||
const otherUserIds = otherUsers.map((user) => user.id);
|
||||
|
||||
await Promise.all(
|
||||
getFreeAgentPosts(testUser.id).map((data) =>
|
||||
getFreeAgentPosts(testUser.id, otherUserIds).map((data) =>
|
||||
prisma.freeAgentPost.create({ data })
|
||||
)
|
||||
);
|
||||
@@ -68,6 +70,7 @@ function throwIfNotLocalhost() {
|
||||
}
|
||||
|
||||
async function deleteExistingRecords() {
|
||||
await prisma.leagueSquadMember.deleteMany();
|
||||
await prisma.freeAgentPost.deleteMany({});
|
||||
await prisma.salmonRunRecord.deleteMany({});
|
||||
await prisma.salmonRunRotation.deleteMany({});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
const getUsers = (): Prisma.UserCreateArgs["data"][] => {
|
||||
const result = [
|
||||
const result: Prisma.UserCreateArgs["data"][] = [
|
||||
{
|
||||
username: "Sendou",
|
||||
discriminator: "4059",
|
||||
@@ -28,7 +28,23 @@ const getUsers = (): Prisma.UserCreateArgs["data"][] => {
|
||||
},
|
||||
];
|
||||
|
||||
new Array(10)
|
||||
.fill(null)
|
||||
.map((_, i) => ({
|
||||
discordId: "" + i,
|
||||
discriminator: padWithZero("" + i, 4),
|
||||
username: `User ${i}`,
|
||||
}))
|
||||
.forEach((value) => result.push(value));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function padWithZero(value: string, targetLength: number) {
|
||||
return new Array(targetLength - value.length)
|
||||
.fill(0)
|
||||
.concat(value.split(""))
|
||||
.join("");
|
||||
}
|
||||
|
||||
export default getUsers;
|
||||
|
||||
Reference in New Issue
Block a user