Skip to content

MEP | Merge develop into main #292

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

Merged
merged 16 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main

Expand All @@ -21,7 +21,7 @@ jobs:
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
Expand Down
3 changes: 3 additions & 0 deletions app/Filament/Resources/ArticleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public static function table(Table $table): Table
->label('Auteur')
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('created_at')
->label(__('Date de création'))
->date(),
Tables\Columns\IconColumn::make('published_at')
->label('Publié')
->getStateUsing(fn (Article $record) => $record->isPublished())
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Api/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function register(RegisterRequest $request): JsonResponse

$user->assignRole('company');

//TODO: Send new company registration notification on Slack
// TODO: Send new company registration notification on Slack
event(new ApiRegistered($user));

return response()->json(
Expand Down Expand Up @@ -81,9 +81,9 @@ public function googleAuthenticator(Request $request): JsonResponse
'avatar' => $socialUser['photoUrl'],
]);

//TODO: Send welcome email to user 1 hour after registration
// TODO: Send welcome email to user 1 hour after registration

//TODO: Send new company registration notification on Slack
// TODO: Send new company registration notification on Slack

$user->last_login_at = Carbon::now();
$user->last_login_ip = $request->ip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Livewire;
namespace App\Livewire\Components;

use App\Contracts\ReactableInterface;
use App\Models\Reaction;
Expand Down Expand Up @@ -40,6 +40,6 @@ public function userReacted(string $reaction): void

public function render(): View
{
return view('livewire.reactions');
return view('livewire.components.reactions');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Livewire;
namespace App\Livewire\Components;

use App\Actions\ReportSpamAction;
use App\Contracts\SpamReportableContract;
Expand Down
12 changes: 9 additions & 3 deletions app/Livewire/Pages/Forum/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ final class Index extends Component
use WithoutUrlPagination;
use WithPagination;

#[Url(as: 'channel')]
#[Url]
public ?string $channel = null;

#[Url(as: 'solved')]
#[Url]
public ?string $solved = null;

#[Url(as: 'me')]
Expand All @@ -36,7 +36,7 @@ final class Index extends Component
#[Url(as: 'no-replies')]
public ?string $unAnswered = null;

#[Url]
#[Url(as: 'follow')]
public ?string $subscribe = null;

public ?Channel $currentChannel = null;
Expand Down Expand Up @@ -129,6 +129,12 @@ protected function applyChannel(Builder $query): Builder

protected function applySubscribe(Builder $query): Builder
{
if (Auth::check() && $this->subscribe) {
$query->whereHas('subscribes', function (Builder $query): void {
$query->where('user_id', Auth::id());
});
}

return $query;
}

Expand Down
49 changes: 49 additions & 0 deletions app/Livewire/Pages/Forum/Leaderboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace App\Livewire\Pages\Forum;

use App\Models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Cache;
use Livewire\Attributes\Layout;
use Livewire\Component;

#[Layout('layouts.forum')]
final class Leaderboard extends Component
{
public function render(): View
{
$startPosition = 1;
$leaders = collect();

/** @var Collection $leaderboard */
$leaderboard = User::mostSolutionsInLastDays(365)
->take(30)
->get()
->reject(fn ($leaderboard) => $leaderboard->solutions_count === 0); // @phpstan-ignore-line

if ($leaderboard->count() > 3) {
$leaders = $leaderboard->slice(0, 3);
$startPosition = 4;
}

return view('livewire.pages.forum.leaderboard', [
'members' => Cache::remember(
key: 'members',
ttl: now()->addWeek(),
callback: fn () => $leaderboard->reject(
fn (User $user) => in_array($user->id, $leaders->pluck('id')->toArray()) // @phpstan-ignore-line
)
),
'leaders' => Cache::remember(
key: 'leaders',
ttl: now()->addWeek(),
callback: fn () => $leaders
),
'startPosition' => $startPosition,
]);
}
}
8 changes: 3 additions & 5 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public function countThreads(): int
public function scopeMostSolutions(Builder $query, ?int $inLastDays = null): Builder
{
return $query->withCount(['replyAble as solutions_count' => function ($query) use ($inLastDays) {
$query->where('replyable_type', 'threads')
$query->where('replyable_type', 'thread')
->join('threads', 'threads.solution_reply_id', '=', 'replies.id');

if ($inLastDays) {
Expand Down Expand Up @@ -477,10 +477,8 @@ public function scopeWithCounts(Builder $query): Builder
'articles as articles_count',
'threads as threads_count',
'replyAble as replies_count',
'replyAble as solutions_count' => function (Builder $query) {
return $query->join('threads', 'threads.solution_reply_id', '=', 'replies.id')
->where('replyable_type', 'thread');
},
'replyAble as solutions_count' => fn (Builder $query) => $query->join('threads', 'threads.solution_reply_id', '=', 'replies.id')
->where('replyable_type', 'thread'),
]);
}

Expand Down
2 changes: 2 additions & 0 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Blade;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Vormkracht10\FilamentMails\FilamentMailsPlugin;

final class AdminPanelProvider extends PanelProvider
{
Expand Down Expand Up @@ -51,6 +52,7 @@ public function panel(Panel $panel): Panel
->plugins([
SpatieLaravelTranslatablePlugin::make()
->defaultLocales(['fr', 'en']),
FilamentMailsPlugin::make(),
])
->renderHook(
'body.start',
Expand Down
24 changes: 0 additions & 24 deletions app/View/Composers/TopMembersComposer.php

This file was deleted.

10 changes: 4 additions & 6 deletions app/Widgets/MostActiveUsersPerWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ public function run(): View
$users = User::with('activities')
->withCount('activities')
->verifiedUsers()
->whereHas('activities', function (Builder $query) {
return $query->whereBetween('created_at', [
now()->startOfWeek(),
now()->endOfWeek(),
]);
})
->whereHas('activities', fn (Builder $query) => $query->whereBetween('created_at', [
now()->startOfWeek(),
now()->endOfWeek(),
]))
->orderByDesc('activities_count')
->limit(5)
->get();
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"symfony/http-client": "^7.1.8",
"symfony/mailgun-mailer": "^7.1",
"torchlight/torchlight-laravel": "^0.6",
"vormkracht10/filament-mails": "^1.0",
"wire-elements/modal": "^2.0",
"wire-elements/spotlight": "^2.0",
"yarri/link-finder": "^2.7.10",
Expand Down
Loading
Loading