Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 10 additions & 19 deletions src/GitHub/GetStargazersCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,28 @@

namespace App\GitHub;

use DateTimeImmutable;
use Tempest\Cache\Cache;
use Tempest\HttpClient\HttpClient;
use Throwable;

final class GetStargazersCount
{
public function __construct(
private HttpClient $httpClient,
private Cache $cache,
) {
}

public function __invoke(): ?string
{
return $this->cache->resolve(
key: 'tempest-stargazers',
cache: function () {
try {
$body = $this->httpClient->get('https://api.github.com/repos/tempestphp/tempest-framework')->body;
$stargazers = json_decode($body)->stargazers_count ?? null;
try {
$body = $this->httpClient->get('https://api.github.com/repos/tempestphp/tempest-framework')->body;
$stargazers = json_decode($body)->stargazers_count ?? null;

return $stargazers > 999
? (round($stargazers / 1000, 1) . 'K')
: $stargazers;
} catch (Throwable $e) {
ll($e);
return null;
}
},
expiresAt: new DateTimeImmutable('+12 hours'),
);
return $stargazers > 999
? (round($stargazers / 1000, 1) . 'K')
: $stargazers;
} catch (Throwable $e) {
ll($e);
return null;
}
}
}
2 changes: 1 addition & 1 deletion src/Migrations/FixDateTimeFieldsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
{
use HasConsole;

#[ConsoleCommand(name: 'fix:projections')]
public function __invoke()
{
foreach (VisitsPerDay::all() as $visitsPerDay) {
$visitsPerDay->save();
}

foreach (VisitsPerHour::all() as $visitsPerDay) {
$visitsPerDay->save();
}

$this->success('Done');
}

Check warning on line 26 in src/Migrations/FixDateTimeFieldsMigration.php

View workflow job for this annotation

GitHub Actions / Run style check

strictness/require-return-type

Method `__invoke` is missing a return type hint. Type hints improve code readability and help prevent type-related errors. Help: Consider adding a return type hint to method `__invoke`.
}
}
1 change: 1 addition & 0 deletions src/Web/Documentation/ChapterView.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Tempest\Support\Arr\ImmutableArray;
use Tempest\View\IsView;
use Tempest\View\View;

use function Tempest\Support\Arr\map_iterable;
use function Tempest\Support\str;

Expand All @@ -33,7 +34,7 @@

public function getSubChapters(): array
{
// TODO: clean up

Check warning on line 37 in src/Web/Documentation/ChapterView.php

View workflow job for this annotation

GitHub Actions / Run style check

comment/no-untagged-todo

TODO should be tagged with (@username) or (#issue). Help: Add a user tag or issue reference to the TODO comment, e.g. TODO(@azjezz), TODO(azjezz), TODO(#123).
preg_match_all('/<h2.*>.*<a.*href="(?<uri>.*?)".*<\/span>(?<title>.*)<\/a><\/h2>/', $this->currentChapter->body, $h2Matches);
preg_match_all('/<h3.*>.*<a.*href="(?<h3uri>.*?)".*<\/span>(?<h3title>.*)<\/a><\/h3>/', $this->currentChapter->body, $h3Matches);

Expand Down
4 changes: 3 additions & 1 deletion src/Web/x-header.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class="transition hover:text-(--ui-text-highlighted) <?= is_current_uri([Chapter
</a>
<a
:href="uri([BlogController::class, 'index'])"
class="transition hover:text-(--ui-text-highlighted) <?= is_current_uri([BlogController::class, 'show']) || is_current_uri([BlogController::class, 'index']) ? 'md:text-(--ui-primary)' : '' ?>"
class="transition hover:text-(--ui-text-highlighted) <?= is_current_uri([BlogController::class, 'show']) || is_current_uri([BlogController::class, 'index'])
? 'md:text-(--ui-primary)'
: '' ?>"
>Blog</a>
<a href="https://github.com/tempestphp/tempest-framework" class="transition hover:text-(--ui-text-highlighted) flex items-center gap-x-1.5 ml-4">
<x-icon name="tabler:brand-github" class="size-6" />
Expand Down
Loading