Skip to content

Commit

Permalink
feat: notion of groups (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed May 6, 2021
1 parent 98107bd commit cd66bfa
Show file tree
Hide file tree
Showing 107 changed files with 9,927 additions and 18 deletions.
102 changes: 102 additions & 0 deletions app/Console/Commands/Tests/SetupDummyAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,31 @@
use App\Models\Company\Employee;
use App\Models\Company\Position;
use App\Models\Company\Question;
use Illuminate\Support\Facades\DB;
use App\Models\Company\ECoffeeMatch;
use App\Services\User\CreateAccount;
use App\Models\Company\ProjectStatus;
use App\Models\Company\EmployeeStatus;
use App\Models\Company\ExpenseCategory;
use App\Services\Company\Team\SetTeamLead;
use App\Services\Company\Group\CreateGroup;
use Illuminate\Database\Eloquent\Collection;
use App\Models\Company\RateYourManagerAnswer;
use App\Models\Company\RateYourManagerSurvey;
use App\Services\Company\Group\CreateMeeting;
use App\Services\Company\Project\StartProject;
use App\Services\Company\Team\Ship\CreateShip;
use App\Models\Company\EmployeePositionHistory;
use App\Services\Company\Project\CreateProject;
use App\Services\Company\Group\CreateAgendaItem;
use App\Services\Company\Group\UpdateMeetingDate;
use Symfony\Component\Console\Helper\ProgressBar;
use App\Services\Company\Adminland\Team\CreateTeam;
use App\Services\Company\Employee\Morale\LogMorale;
use App\Services\Company\Project\CreateProjectLink;
use App\Services\Company\Project\CreateProjectTask;
use App\Services\Company\Employee\Worklog\LogWorklog;
use App\Services\Company\Group\CreateMeetingDecision;
use App\Services\Company\Project\CreateProjectStatus;
use App\Services\Company\Employee\Answer\CreateAnswer;
use App\Services\Company\Project\AddEmployeeToProject;
Expand Down Expand Up @@ -209,8 +215,10 @@ public function handle(): void
$this->createTimeTrackingEntries();
$this->setContractRenewalDates();
$this->setECoffeeProcess();
$this->addGroups();
$this->addPreviousPositionsHistory();
$this->addSecondaryBlankAccount();
$this->validateUserAccounts();
$this->stop();
}

Expand Down Expand Up @@ -2022,6 +2030,8 @@ private function setContractRenewalDates(): void

private function setECoffeeProcess(): void
{
$this->info('☐ Set e Coffee Process');

$this->company->e_coffee_enabled = true;
$this->company->save();

Expand All @@ -2043,6 +2053,92 @@ private function setECoffeeProcess(): void
});
}

private function addGroups(): void
{
$this->info('☐ Add groups');

$groupNames = collect([
'Party planning committee',
'Basketball lovers',
'Monetisation executive meeting',
'Front end developers guild',
]);

$meetingAgendaItems = collect([
'What should we do about the negociations with Home Depot?',
'Discussion about strategic learnings',
'Sales update: previous quarter’s results',
'Team structure presentation',
'Impact on shareholders',
'iPhone 42 launch',
]);

$decisionItems = collect([
'Schedule meeting with supplier',
'Angela to take responsability and pubicly apologize to Dwight',
'Prepare forecasts for Q4',
'Prepare UX for the future feature',
]);

foreach ($groupNames as $name) {
$randomEmployees = $this->employees->shuffle()->take(rand(4, 9))->pluck('id')->toArray();

// create group with random employees
$group = (new CreateGroup)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'name' => $name,
'employees' => $randomEmployees,
]);

$group->mission = 'This group was created to discuss all decisions we have to take together.';
$group->save();

// create meetings
$date = Carbon::now()->subMonths(10);
for ($i = 0; $i < rand(4, 9); $i++) {
$meeting = (new CreateMeeting)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'group_id' => $group->id,
]);

(new UpdateMeetingDate)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'group_id' => $group->id,
'meeting_id' => $meeting->id,
'date' => $date->addDays(rand(10, 57))->format('Y-m-d'),
]);

// add agenda items
foreach ($meetingAgendaItems as $item) {
$agendaItem = (new CreateAgendaItem)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'group_id' => $group->id,
'meeting_id' => $meeting->id,
'summary' => $item,
'description' => null,
'presented_by_id' => $this->employees->shuffle()->first()->id,
]);

$decisionItems = $decisionItems->shuffle()->take(rand(1, 3));
foreach ($decisionItems as $item) {
(new CreateMeetingDecision)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'group_id' => $group->id,
'meeting_id' => $meeting->id,
'agenda_item_id' => $agendaItem->id,
'description' => $item,
]);
}
}
}
}
}

private function addPreviousPositionsHistory(): void
{
foreach ($this->employees as $employee) {
Expand Down Expand Up @@ -2088,6 +2184,12 @@ private function addSecondaryBlankAccount(): void
]);
}

private function validateUserAccounts(): void
{
DB::table('users')
->update(['email_verified_at' => Carbon::now()]);
}

private function artisan(string $message, string $command, array $arguments = []): void
{
$this->info($message);
Expand Down

0 comments on commit cd66bfa

Please sign in to comment.