summaryrefslogtreecommitdiff
path: root/scripts/create-random-tasks.php
blob: 08aa01ddf6d6b16e0eef84557da10af92d758528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env php
<?php

require __DIR__.'/../app/common.php';

use Model\Task;
use Model\SubTask;
use Model\Project;
use Model\ProjectPermission;
use Model\User;

$task_per_column = 50;

$userModel = new User($container);
$projectModel = new Project($container);
$permissionModel = new ProjectPermission($container);
$taskModel = new Task($container);
$subtaskModel = new SubTask($container);

for ($i = 0; $i <= 100; $i++) {
    $id = $projectModel->create(array(
        'name' => 'Project #'.$i
    ));

    $permissionModel->allowUser($id, 1);
}

for ($i = 0; $i <= 500; $i++) {
    $userModel->create(array(
        'username' => 'user'.$i,
        'password' => 'password'.$i,
        'name' => 'User #'.$i,
        'email' => 'user'.$i.'@localhost',
    ));
}

foreach (array(1, 2, 3, 4) as $column_id) {

    for ($i = 1; $i <= $task_per_column; $i++) {

        $task = array(
            'title' => 'Task #'.$i.'-'.$column_id,
            'project_id' => mt_rand(1, 100),
            'column_id' => $column_id,
            'owner_id' => 1,
            'color_id' => mt_rand(0, 1) === 0 ? 'green' : 'purple',
            'score' => mt_rand(0, 21),
            'is_active' => mt_rand(0, 1),
        );

        $id = $taskModel->create($task);

        $subtaskModel->create(array(
            'title' => 'Subtask of task #'.$id,
            'user_id' => 1,
            'status' => mt_rand(0, 2),
            'task_id' => $id,
        ));
    }
}