Skip to content

Commit

Permalink
refactor: cleaning up constructors (#5602)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofrewak authored Oct 13, 2021
1 parent bb97115 commit d209313
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 47 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ Ben Fesili @benfes
Markus Dick @markusdick
Jacek Sawoszczuk @jsawo
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(ActivityStatisticService $activityStatisticService, Contact $contact, int $year)
{
$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

0 comments on commit d209313

Please sign in to comment.