fa public

This commit is contained in:
Kalle (Sendou)
2021-01-06 21:08:37 +02:00
parent 41f6509ac8
commit 52c8133e28
9 changed files with 162 additions and 10 deletions

View File

@@ -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;

View File

@@ -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({});

View File

@@ -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;