Skip to content

Commit

Permalink
feat: ask me anything (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed Sep 15, 2021
1 parent f9c57da commit 9f2eef3
Show file tree
Hide file tree
Showing 56 changed files with 3,854 additions and 9 deletions.
77 changes: 77 additions & 0 deletions app/Console/Commands/Tests/SetupDummyAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use App\Services\Company\Wiki\CreateWiki;
use App\Services\Company\Team\SetTeamLead;
use App\Services\Company\Group\CreateGroup;
use App\Models\Company\AskMeAnythingSession;
use App\Services\Company\Wiki\AddPageToWiki;
use Illuminate\Database\Eloquent\Collection;
use App\Models\Company\RateYourManagerAnswer;
Expand Down Expand Up @@ -91,7 +92,10 @@
use App\Services\Company\Adminland\EmployeeStatus\CreateEmployeeStatus;
use App\Services\Company\Employee\OneOnOne\MarkOneOnOneEntryAsHappened;
use App\Services\Company\Adminland\Expense\AllowEmployeeToManageExpenses;
use App\Services\Company\Adminland\AskMeAnything\CreateAskMeAnythingSession;
use App\Services\Company\Adminland\AskMeAnything\ToggleAskMeAnythingSession;
use App\Services\Company\Adminland\JobOpening\CreateRecruitingStageTemplate;
use App\Services\Company\Adminland\AskMeAnything\CreateAskMeAnythingQuestion;
use App\Services\Company\Employee\WorkFromHome\UpdateWorkFromHomeInformation;
use App\Services\Company\Employee\EmployeeStatus\AssignEmployeeStatusToEmployee;

Expand Down Expand Up @@ -234,6 +238,7 @@ public function handle(): void
$this->addWikis();
$this->addRecruitingStages();
$this->addJobOpenings();
$this->addAMASessions();
$this->addSecondaryBlankAccount();
$this->validateUserAccounts();
$this->stop();
Expand Down Expand Up @@ -2507,6 +2512,78 @@ private function addJobOpenings(): void
}
}

private function addAMASessions(): void
{
$this->info('☐ Add Ask Me Anything sessions');

$themes = collect([
'New office',
'New Year resolutions',
'Launch of the new marketing website',
'New plans for the next year',
'Merge with the company we just bought',
]);

$questions = collect([
'Have you ever had a nickname? What is it?',
'Do you like or dislike surprises? Why or why not?',
'In the evening, would you rather play a game, visit a relative, watch a movie, or read?',
'Would you rather vacation in Hawaii or Alaska, and why?',
'Would you rather win the lottery or work at the perfect job? And why?',
'Who would you want to be stranded with on a deserted island?',
'If money was no object, what would you do all day?',
'If you could go back in time, what year would you travel to?',
'How would your friends describe you?',
'What are your hobbies?',
'What is the best gift you have been given?',
'What is the worst gift you have received?',
'Aside from necessities, what one thing could you not go a day without?',
'List two pet peeves.',
'Where do you see yourself in five years?',
'How many pairs of shoes do you own?',
'If you were a super-hero, what powers would you have?',
'What would you do if you won the lottery?',
'What form of public transportation do you prefer? (air, boat, train, bus, car, etc.)',
'What is your favorite zoo animal?',
'If you could go back in time to change one thing, what would it be?',
'If you could share a meal with any 4 individuals, living or dead, who would they be?',
'How many pillows do you sleep with?',
'What is the longest you have gone without sleep (and why)?',
'What is the tallest building you have been to the top in?',
]);

$daysToSubtract = rand(200, 365);
foreach ($themes as $theme) {
// get random date
$date = Carbon::now()->copy()->subDays($daysToSubtract);

$ama = (new CreateAskMeAnythingSession)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'theme' => $theme,
'date' => $date->format('Y-m-d'),
]);

foreach ($questions->take(rand(10, 24)) as $question) {
(new CreateAskMeAnythingQuestion)->execute([
'company_id' => $this->company->id,
'author_id' => $this->employees->shuffle()->first()->id,
'ask_me_anything_session_id' => $ama->id,
'question' => $question,
'anonymous' => rand(0, 1) == 1,
]);
}

$daysToSubtract = $daysToSubtract + rand(200, 365);
}

(new ToggleAskMeAnythingSession)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'ask_me_anything_session_id' => AskMeAnythingSession::orderBy('id', 'desc')->first()->id,
]);
}

private function addSecondaryBlankAccount(): void
{
$this->info('☐ Create a blank account');
Expand Down
29 changes: 29 additions & 0 deletions app/Helpers/LogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,35 @@ public static function processAuditLog(AuditLog $log): string
]);
break;

case 'ask_me_anything_session_created':
$sentence = trans('account.log_ask_me_anything_session_created', [
'ask_me_anything_session_id' => $log->object->{'ask_me_anything_session_id'},
'ask_me_anything_session_theme' => $log->object->{'ask_me_anything_session_theme'},
]);
break;

case 'ask_me_anything_session_destroyed':
$sentence = trans('account.log_ask_me_anything_session_destroyed');
break;

case 'ask_me_anything_session_toggled':
$sentence = trans('account.ask_me_anything_session_toggled', [
'ask_me_anything_session_id' => $log->object->{'ask_me_anything_session_id'},
]);
break;

case 'ask_me_anything_session_updated':
$sentence = trans('account.ask_me_anything_session_updated', [
'ask_me_anything_session_id' => $log->object->{'ask_me_anything_session_id'},
]);
break;

case 'ask_me_anything_question_answered':
$sentence = trans('account.ask_me_anything_question_answered', [
'ask_me_anything_session_id' => $log->object->{'ask_me_anything_session_id'},
]);
break;

case 'project_message_comment_created':
$sentence = trans('account.log_project_message_comment_created', [
'project_id' => $log->object->{'project_id'},
Expand Down

0 comments on commit 9f2eef3

Please sign in to comment.