Skip to content

Commit

Permalink
Merge pull request #1382 from shikorism/develop
Browse files Browse the repository at this point in the history
Release 2024.12.4
  • Loading branch information
shibafu528 authored Dec 13, 2024
2 parents a9b4811 + cecf632 commit 3d535bb
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 162 deletions.
15 changes: 7 additions & 8 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Tag;
use App\Utilities\Formatter;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
Expand All @@ -30,13 +31,12 @@ public function index(Request $request)
]);

$results = Ejaculation::query()
->whereHas('user', function ($query) {
$query->where('is_protected', false);
->where(function (Builder $query) {
$query->where('is_private', false)->whereHas('user', fn ($q) => $q->where('is_protected', false));
if (Auth::check()) {
$query->orWhere('id', Auth::id());
$query->orWhereHas('user', fn ($q) => $q->where('id', Auth::id()));
}
})
->where('is_private', false)
->orderBy('ejaculated_date', 'desc')
->with(['user', 'tags'])
->withLikes()
Expand Down Expand Up @@ -140,13 +140,12 @@ public function collection(Request $request)
->select('collection_items.*')
->join('collections', 'collections.id', '=', 'collection_items.collection_id')
->with(['collection', 'collection.user', 'tags'])
->whereHas('collection.user', function ($query) {
$query->where('is_protected', false);
->where(function (Builder $query) {
$query->where('collections.is_private', false)->whereHas('collection.user', fn (Builder $q) => $q->where('is_protected', false));
if (Auth::check()) {
$query->orWhere('id', Auth::id());
$query->orWhereHas('collection.user', fn (Builder $q) => $q->where('id', Auth::id()));
}
})
->where('collections.is_private', false)
->orderByDesc('id');

try {
Expand Down
12 changes: 10 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ public function stats($name)
->with(compact('user', 'graphData', 'availableMonths', 'tags', 'tagsIncludesMetadata'));
}

public function statsYearly($name, $year)
public function statsYearly(Request $request, $name, $year)
{
$user = User::where('name', $name)->first();
if (empty($user)) {
abort(404);
}
$comparePrev = $request->query('compare') === 'prev';

$validator = Validator::make(compact('year'), [
'year' => 'required|date_format:Y'
Expand All @@ -113,8 +114,15 @@ public function statsYearly($name, $year)
$tagsIncludesMetadata = collect($this->countUsedTagsIncludesMetadata($user, $dateSince, $dateUntil));
$mostFrequentlyUsedRanking = collect($this->countMostFrequentlyUsedOkazu($user, $dateSince, $dateUntil));

$compareData = null;
if ($comparePrev) {
$compareDateSince = Carbon::createFromDate($year - 1, 1, 1, config('app.timezone'))->startOfDay();
$compareDateUntil = Carbon::createFromDate($year - 1, 1, 1, config('app.timezone'))->addYear()->startOfDay();
$compareData = $this->makeGraphData($user, $compareDateSince, $compareDateUntil);
}

return view('user.stats.yearly')
->with(compact('user', 'graphData', 'availableMonths', 'tags', 'tagsIncludesMetadata', 'mostFrequentlyUsedRanking'))
->with(compact('user', 'graphData', 'availableMonths', 'tags', 'tagsIncludesMetadata', 'mostFrequentlyUsedRanking', 'compareData'))
->with('currentYear', (int) $year);
}

Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"sentry/sentry-laravel": "^4.1.0",
"symfony/css-selector": "^6.0",
"symfony/dom-crawler": "^6.0",
"symfony/mailer": "~7.1.0",
"t1gor/robots-txt-parser": "^0.2.4"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 3d535bb

Please sign in to comment.