Commit d962dedc authored by Ermolaev Timur's avatar Ermolaev Timur

#43 изменил чуть логику

parent da2988e0
...@@ -39,6 +39,16 @@ const loadFixtures = async () => { ...@@ -39,6 +39,16 @@ const loadFixtures = async () => {
await user.save(); await user.save();
users.push(user) users.push(user)
} }
const projects:Project[] = []
for (let i = 0; i < 5; i++) {
const newProject = new Project();
newProject.title = `Project ${faker.random.words(1)}`;
newProject.color = faker.random.words(4);
newProject.admin = faker.helpers.arrayElement(users);
newProject.workers = faker.helpers.arrayElements(users, randomIntFromInterval(1, 3));
await newProject.save();
projects.push(newProject)
}
const tasks:Task[] = [] const tasks:Task[] = []
type taskFinishType = "opened" | "done" |"failed"; type taskFinishType = "opened" | "done" |"failed";
type priorityType = "A" | "B" |"C"; type priorityType = "A" | "B" |"C";
...@@ -53,6 +63,7 @@ const loadFixtures = async () => { ...@@ -53,6 +63,7 @@ const loadFixtures = async () => {
newTask.dateTimeDue = faker.date.soon(randomIntFromInterval(1, 15)); newTask.dateTimeDue = faker.date.soon(randomIntFromInterval(1, 15));
newTask.dateTimeStart = faker.date.recent((randomIntFromInterval(0, 8))); newTask.dateTimeStart = faker.date.recent((randomIntFromInterval(0, 8)));
newTask.author = faker.helpers.arrayElement(users); newTask.author = faker.helpers.arrayElement(users);
newTask.project = faker.helpers.arrayElement(projects);
newTask.accomplish = faker.helpers.arrayElement(accomplish); newTask.accomplish = faker.helpers.arrayElement(accomplish);
newTask.priority = faker.helpers.arrayElement(priorities); newTask.priority = faker.helpers.arrayElement(priorities);
await newTask.save(); await newTask.save();
...@@ -64,6 +75,7 @@ const loadFixtures = async () => { ...@@ -64,6 +75,7 @@ const loadFixtures = async () => {
newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3)); newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));
newTask.dateTimeDue = null; newTask.dateTimeDue = null;
newTask.dateTimeStart = null; newTask.dateTimeStart = null;
newTask.project = faker.helpers.arrayElement(projects);
newTask.author = faker.helpers.arrayElement(users); newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = accomplish[0]; newTask.accomplish = accomplish[0];
newTask.priority = faker.helpers.arrayElement(priorities); newTask.priority = faker.helpers.arrayElement(priorities);
...@@ -71,15 +83,6 @@ const loadFixtures = async () => { ...@@ -71,15 +83,6 @@ const loadFixtures = async () => {
tasks.push(newTask) tasks.push(newTask)
} }
} }
for (let i = 0; i < 5; i++) {
const newProject = new Project();
newProject.title = `Project ${faker.random.words(1)}`;
newProject.color = faker.random.words(4);
newProject.admin = faker.helpers.arrayElement(users);
newProject.workers = faker.helpers.arrayElements(users, randomIntFromInterval(1, 3));
newProject.tasks = faker.helpers.arrayElements(tasks, randomIntFromInterval(0, 19));
await newProject.save();
}
console.log('========================== ' + '\n' + 'Fixtures done!' +'\n' + '==========================') console.log('========================== ' + '\n' + 'Fixtures done!' +'\n' + '==========================')
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment