added hourly and money budgets to activity, project and customer (#843)
This commit is contained in:
@@ -32,6 +32,8 @@ class CustomerFixtures extends Fixture
|
||||
public const MAX_CUSTOMERS = 15;
|
||||
public const MIN_BUDGET = 0;
|
||||
public const MAX_BUDGET = 100000;
|
||||
public const MIN_TIME_BUDGET = 0;
|
||||
public const MAX_TIME_BUDGET = 10000000;
|
||||
public const MIN_GLOBAL_ACTIVITIES = 5;
|
||||
public const MAX_GLOBAL_ACTIVITIES = 30;
|
||||
public const MIN_PROJECTS_PER_CUSTOMER = 2;
|
||||
@@ -100,6 +102,14 @@ class CustomerFixtures extends Fixture
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
if (rand(0, 3) % 3) {
|
||||
$entry->setBudget(rand(self::MIN_BUDGET, self::MAX_BUDGET));
|
||||
}
|
||||
|
||||
if (rand(0, 3) % 3) {
|
||||
$entry->setTimeBudget(rand(self::MIN_TIME_BUDGET, self::MAX_TIME_BUDGET));
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
@@ -115,12 +125,19 @@ class CustomerFixtures extends Fixture
|
||||
|
||||
$entry
|
||||
->setName($faker->catchPhrase . ($visible ? '' : ' (x)'))
|
||||
->setBudget(rand(self::MIN_BUDGET, self::MAX_BUDGET))
|
||||
->setComment($faker->text)
|
||||
->setCustomer($customer)
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
if (rand(0, 3) % 3) {
|
||||
$entry->setBudget(rand(self::MIN_BUDGET, self::MAX_BUDGET));
|
||||
}
|
||||
|
||||
if (rand(0, 3) % 3) {
|
||||
$entry->setTimeBudget(rand(self::MIN_TIME_BUDGET, self::MAX_TIME_BUDGET));
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
@@ -140,6 +157,14 @@ class CustomerFixtures extends Fixture
|
||||
->setVisible($visible)
|
||||
;
|
||||
|
||||
if (rand(0, 3) % 3) {
|
||||
$entry->setBudget(rand(self::MIN_BUDGET, self::MAX_BUDGET));
|
||||
}
|
||||
|
||||
if (rand(0, 3) % 3) {
|
||||
$entry->setTimeBudget(rand(self::MIN_TIME_BUDGET, self::MAX_TIME_BUDGET));
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class TagFixtures extends Fixture
|
||||
} elseif ($i % 2 == 0) {
|
||||
$tagName = $faker->colorName;
|
||||
} elseif ($i % 1 == 0) {
|
||||
$tagName = $faker->text(rand(10, 20));
|
||||
$tagName = $faker->text(rand(5, 15));
|
||||
}
|
||||
|
||||
if (in_array($tagName, $existing)) {
|
||||
@@ -72,15 +72,12 @@ class TagFixtures extends Fixture
|
||||
|
||||
$manager->persist($tag);
|
||||
|
||||
if ($i % self::BATCH_SIZE == 0) {
|
||||
if ($i % self::BATCH_SIZE === 0) {
|
||||
$manager->flush();
|
||||
$manager->clear(Tag::class);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
$manager->clear(Tag::class);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
$manager->clear(Tag::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class UserFixtures extends Fixture
|
||||
public const MIN_RATE = 30;
|
||||
public const MAX_RATE = 120;
|
||||
|
||||
// lower batch size, as user preferences are added in the same run
|
||||
public const BATCH_SIZE = 50;
|
||||
|
||||
/**
|
||||
@@ -131,15 +132,31 @@ class UserFixtures extends Fixture
|
||||
private function loadTestUsers(ObjectManager $manager)
|
||||
{
|
||||
$passwordEncoder = $this->encoder;
|
||||
|
||||
$faker = Factory::create();
|
||||
$existingName = [];
|
||||
$existingEmail = [];
|
||||
|
||||
for ($i = 1; $i <= self::AMOUNT_EXTRA_USER; $i++) {
|
||||
$username = $faker->userName;
|
||||
$email = $faker->email;
|
||||
|
||||
if (in_array($username, $existingName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($email, $existingEmail)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$existingName[] = $username;
|
||||
$existingEmail[] = $email;
|
||||
|
||||
$user = new User();
|
||||
$user
|
||||
->setAlias($faker->name)
|
||||
->setTitle(substr($faker->jobTitle, 0, 49))
|
||||
->setUsername($faker->userName)
|
||||
->setEmail($faker->email)
|
||||
->setUsername($username)
|
||||
->setEmail($email)
|
||||
->setRoles([User::ROLE_USER])
|
||||
->setAvatar(self::DEFAULT_AVATAR)
|
||||
->setEnabled(true)
|
||||
@@ -147,12 +164,12 @@ class UserFixtures extends Fixture
|
||||
->setPreferences($this->getUserPreferences($user))
|
||||
;
|
||||
|
||||
if ($i % self::BATCH_SIZE == 0) {
|
||||
$manager->persist($user);
|
||||
|
||||
if ($i % self::BATCH_SIZE === 0) {
|
||||
$manager->flush();
|
||||
$manager->clear();
|
||||
}
|
||||
|
||||
$manager->persist($user);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
||||
Reference in New Issue
Block a user