Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cleaning up constructors #5602

Merged
merged 4 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ Michael Bianco <mike@mikebian.co>
Ben Fesili @benfes
Markus Dick @markusdick
Dung Nguyen @nhymxu
Krzysztof Rewak @krzysztofrewak
11 changes: 2 additions & 9 deletions app/Console/Commands/SentryRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ class SentryRelease extends Command
*/
private const SENTRY_URL = 'https://sentry.io/get-cli/';

/**
* Create a new command.
*/
public function __construct()
{
$this->install_dir = env('SENTRY_ROOT', getenv('HOME').'/.local/bin');
parent::__construct();
}

/**
* Execute the console command.
*
Expand All @@ -73,6 +64,8 @@ public function handle()
}

if ($this->confirmToProceed()) {
$this->install_dir = env('SENTRY_ROOT', getenv('HOME').'/.local/bin');

$release = $this->option('release') ?? config('sentry.release');
$commit = $this->option('commit') ??
(is_dir(__DIR__.'/../../../.git') ? trim(exec('git log --pretty="%H" -n1 HEAD')) : $release);
Expand Down
21 changes: 1 addition & 20 deletions app/Console/Commands/Tests/SetupFrontEndTestUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,14 @@ class SetupFrontEndTestUser extends Command
*/
protected $description = 'Create a user exclusively for front-end testing with Cypress.';

/**
* The migrator instance.
*
* @var \Illuminate\Database\Migrations\Migrator
*/
protected $migrator;

/**
* Create a new command.
*
* @return void
*/
public function __construct()
{
parent::__construct();

$this->migrator = app('migrator');
}

/**
* Execute the console command.
*
* @return void
*/
public function handle(): void
{
$this->migrator->setConnection($this->option('database'));
app('migrator')->setConnection($this->option('database'));

$user = factory(User::class)->create();
$user->account->populateDefaultFields();
Expand Down
23 changes: 5 additions & 18 deletions app/Http/Controllers/Contacts/ActivitiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Models\Contact\Contact;
use App\Models\Account\Activity;
use Illuminate\Support\Collection;
use App\Http\Controllers\Controller;
use App\Models\Account\ActivityType;
Expand All @@ -17,18 +16,6 @@ class ActivitiesController extends Controller
{
use JsonRespondController;

/**
* Statistics about an activity.
*
* @var ActivityStatisticService
*/
protected $activityStatisticService;

public function __construct(ActivityStatisticService $service)
{
$this->activityStatisticService = $service;
}

/**
* Get the list of activities.
*
Expand Down Expand Up @@ -126,21 +113,21 @@ public function summary(Request $request, Contact $contact)
/**
* Get all the activities for this contact for a specific year.
*/
public function year(Request $request, Contact $contact, int $year)
public function year(Request $request, Contact $contact, ActivityStatisticService $activityStatisticService, int $year)
asbiin marked this conversation as resolved.
Show resolved Hide resolved
{
$startDate = Carbon::create($year, 1, 1);
$endDate = Carbon::create($year, 12, 31);

$activitiesLastTwelveMonths = $this->activityStatisticService
$activitiesLastTwelveMonths = $activityStatisticService
->activitiesWithContactInTimeRange($contact, now()->subMonths(12), now())
->count();

$uniqueActivityTypes = $this->activityStatisticService
$uniqueActivityTypes = $activityStatisticService
->uniqueActivityTypesInTimeRange($contact, $startDate, $endDate);

$activitiesPerYear = $this->activityStatisticService->activitiesPerYearWithContact($contact);
$activitiesPerYear = $activityStatisticService->activitiesPerYearWithContact($contact);

$activitiesPerMonthForYear = $this->activityStatisticService
$activitiesPerMonthForYear = $activityStatisticService
->activitiesPerMonthForYear($contact, $year)
->sortByDesc('month');

Expand Down