Skip to content

Commit

Permalink
Version 2.9.0
Browse files Browse the repository at this point in the history
See CHANGELOG.
  • Loading branch information
JSn1nj4 committed Apr 17, 2024
2 parents d40818c + efd17a2 commit 281e06a
Show file tree
Hide file tree
Showing 61 changed files with 1,824 additions and 2,293 deletions.
15 changes: 0 additions & 15 deletions .vscode/launch.json-example

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/settings.json-example

This file was deleted.

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## Version 2.9.0

### Updates

- [#183][is_183]: Upgrade to Laravel 11 ([#190][pr_190])
- [#39][is_39]: Look into support for new GitHub events ([#193][pr_193])

### Development

- Purge old VS Code configs

[is_39]: https://github.com/JSn1nj4/ElliotDerhay.com/issues/39

[is_183]: https://github.com/JSn1nj4/ElliotDerhay.com/issues/183

[pr_190]: https://github.com/JSn1nj4/ElliotDerhay.com/pull/190

[pr_193]: https://github.com/JSn1nj4/ElliotDerhay.com/pull/193

## Version 2.8.6

### Fix
Expand Down
14 changes: 2 additions & 12 deletions app/Console/Commands/GithubEventPullCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ class GithubEventPullCommand extends Command
*/
protected $description = 'Fetch events from GitHub\'s events API.';

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

/**
* Execute the console command.
*
Expand All @@ -60,13 +50,13 @@ public function handle(GithubService $github): int

$events = $github->getEvents('JSn1nj4', $this->option('count'));

if($this->option('file')) {
if ($this->option('file')) {
Storage::disk('debug')->put($this->option('file'), $events->toJson());

return self::SUCCESS;
}

if($this->option('debug')) {
if ($this->option('debug')) {
dd($events);
}

Expand Down
61 changes: 43 additions & 18 deletions app/DataTransferObjects/GithubEventDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,61 @@

use Illuminate\Support\Carbon;

class GithubEventDTO
readonly class GithubEventDTO
{
public function __construct(
public readonly string $id,
public readonly string $type,
public readonly ?string $action,
public readonly string $date,
public readonly GithubUserDTO $user,
public readonly ?string $source,
public readonly string $repo,
public string $id,
public string $type,
public string|null $action,
public string $date,
public GithubUserDTO $user,
public string|null $source,
public string $repo,
) {}

public static function getAction(array $data): ?string
public static function getAction(array $data): string|null
{
return match ($data['type']) {
'IssuesEvent' => \optional($data['payload'])['action'],
'PullRequestEvent' => (\optional($data['payload'])['merged']
? 'merged'
: \optional($data['payload'])['action']),
'CommitCommentEvent' => match (optional($data['payload'])['action']) {
'created' => 'commented on',
default => 'deleted a comment on',
},

'IssuesEvent' => optional($data['payload'])['action'],

'PullRequestEvent' => match (true) {
optional($data['payload'])['merged'] !== null => 'merged',
default => optional($data['payload'])['action'],
},

'PullRequestReviewCommentEvent' => match (optional($data['payload'])['action']) {
'created' => 'commented on a review of',
'deleted' => 'deleted a review comment on',
default => 'updated a review comment on',
},

'PullRequestReviewEvent' => 'started a review on',

'ReleaseEvent' => match (optional($data['payload'])['action']) {
null => 'updated',
default => optional($data['payload'])['action'],
},

default => null,
};
}

public static function getEventSource(array $data): ?string
public static function getEventSource(array $data): string|null
{
return match ($data['type']) {
'CreateEvent', 'DeleteEvent', 'PushEvent' => $data['payload']['ref'],
'ForkEvent' => $data['payload']['forkee']['full_name'],
'IssueCommentEvent', 'IssuesEvent' => $data['payload']['issue']['number'],
'PullRequestEvent' => $data['payload']['pull_request']['number'],
'CommitCommentEvent' => $data['payload']['comment']['commit_id'],
'CreateEvent', 'DeleteEvent', 'PushEvent' => $data['payload']['ref'],
'ForkEvent' => $data['payload']['forkee']['full_name'],
'IssueCommentEvent', 'IssuesEvent' => $data['payload']['issue']['number'],
'PullRequestEvent',
'PullRequestReviewCommentEvent',
'PullRequestReviewEvent' => $data['payload']['pull_request']['number'],
'ReleaseEvent' => $data['payload']['release']['html_url'],
default => null,
};
}
Expand Down
8 changes: 2 additions & 6 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
abstract class Controller
{
use AuthorizesRequests, ValidatesRequests;
//
}
35 changes: 5 additions & 30 deletions app/Http/Controllers/GithubEventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,15 @@
namespace App\Http\Controllers;

use App\Models\GithubEvent;
use Illuminate\Database\Eloquent\Collection;

class GithubEventController extends Controller
{
/**
* GitHubEventController constructor method
*
* @method __construct
* @access public
*
* @return void
*/
public function __construct()
{
//
}

/**
* Index recent GitHub events
*
* @method index
* @access public
*
* @param integer $count
*
* @return array
*
* This will return an asociative array that should automatically be
* converted to JSON on the front-end.
*/
public function index(int $count = 7)
public function index(int $count = 7): Collection
{
return GithubEvent::with('user')
->latest('date')
->take($count)
->get();
->latest('date')
->take($count)
->get();
}
}
8 changes: 6 additions & 2 deletions app/Http/Controllers/ProjectsPortfolioController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
namespace App\Http\Controllers;

use App\Models\Project;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;

class ProjectsPortfolioController extends Controller
{
public function index(Request $request, int $count = 10)
public function index(Request $request, int $count = 10): View|Factory|Collection|Application
{
$projects = Project::take($count)->get();

if($request->wantsJson()) {
if ($request->wantsJson()) {
return $projects;
}

Expand Down
32 changes: 5 additions & 27 deletions app/Http/Controllers/TweetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,15 @@
namespace App\Http\Controllers;

use App\Models\Tweet;
use Illuminate\Database\Eloquent\Collection;

class TweetController extends Controller
{
/**
* Store instance of App\Tseet on controller instantiation
*
* @method __construct
* @access public
*
* @return void
*/
public function __construct()
{
//
}

/**
* Get a list of tweets for display in a timeline-like view
*
* @method index
* @access public
*
* @param integer $count
*
* @return object
*/
public function index(int $count = 5)
public function index(int $count = 5): Collection
{
return Tweet::with('user')
->latest('date')
->take($count)
->get();
->latest('date')
->take($count)
->get();
}
}
66 changes: 0 additions & 66 deletions app/Http/Kernel.php

This file was deleted.

17 changes: 0 additions & 17 deletions app/Http/Middleware/Authenticate.php

This file was deleted.

17 changes: 0 additions & 17 deletions app/Http/Middleware/EncryptCookies.php

This file was deleted.

Loading

0 comments on commit 281e06a

Please sign in to comment.