Skip to content

Commit

Permalink
Merge branch 'master' into add-timeline-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Nov 13, 2024
2 parents c34ddae + f6a72dd commit 661ad7d
Show file tree
Hide file tree
Showing 21 changed files with 268 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

- name: Attest
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
with:
# Path to the artifact serving as the subject of the attestation. Must
# specify exactly one of "subject-path" or "subject-digest". May contain a
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -60,7 +60,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/autobuild@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -73,6 +73,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@83a02f7883b12e0e4e1a146174f5e2292a01e601 # v2.16.4
uses: github/codeql-action/upload-sarif@4f3212b61783c3c68e8309a0f18a699764811cda # v2.16.4
with:
sarif_file: results.sarif
17 changes: 13 additions & 4 deletions app/Actions/Statistics/Spaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function getFullSpacePerUser(?int $owner_id = null): Collection
type: 'left'
)
->joinSub(
query: DB::table('size_variants')->select(['size_variants.photo_id', 'size_variants.filesize']),
query: DB::table('size_variants')
->select(['size_variants.photo_id', 'size_variants.filesize'])
->where('size_variants.type', '!=', 7),
as: 'size_variants',
first: 'size_variants.photo_id',
operator: '=',
Expand Down Expand Up @@ -79,6 +81,7 @@ public function getSpacePerSizeVariantTypePerUser(?int $owner_id = null): Collec
'size_variants.type',
DB::raw('SUM(size_variants.filesize) as size')
)
->where('size_variants.type', '!=', 7)
->groupBy('size_variants.type')
->orderBy('size_variants.type', 'asc')
->get()
Expand Down Expand Up @@ -115,7 +118,9 @@ public function getSpacePerSizeVariantTypePerAlbum(string $album_id): Collection
second: 'descendants.id',
)
->joinSub(
query: DB::table('size_variants')->select(['size_variants.id', 'size_variants.photo_id', 'size_variants.type', 'size_variants.filesize']),
query: DB::table('size_variants')
->select(['size_variants.id', 'size_variants.photo_id', 'size_variants.type', 'size_variants.filesize'])
->where('size_variants.type', '!=', 7),
as: 'size_variants',
first: 'size_variants.photo_id',
operator: '=',
Expand Down Expand Up @@ -174,7 +179,9 @@ public function getSpacePerAlbum(?string $album_id = null, ?int $owner_id = null
second: 'albums.id'
)
->joinSub(
query: DB::table('size_variants')->select(['size_variants.id', 'size_variants.photo_id', 'size_variants.filesize']),
query: DB::table('size_variants')
->select(['size_variants.id', 'size_variants.photo_id', 'size_variants.filesize'])
->where('size_variants.type', '!=', 7),
as: 'size_variants',
first: 'size_variants.photo_id',
operator: '=',
Expand Down Expand Up @@ -234,7 +241,9 @@ public function getTotalSpacePerAlbum(?string $album_id = null, ?int $owner_id =
second: 'descendants.id'
)
->joinSub(
query: DB::table('size_variants')->select(['size_variants.id', 'size_variants.photo_id', 'size_variants.filesize']),
query: DB::table('size_variants')
->select(['size_variants.id', 'size_variants.photo_id', 'size_variants.filesize'])
->where('size_variants.type', '!=', 7),
as: 'size_variants',
first: 'size_variants.photo_id',
operator: '=',
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SettingsController extends Controller
public function getAll(GetAllConfigsRequest $request): ConfigCollectionResource
{
$editable_configs = Configs::query()
->when(config('features.hide-lychee-SE', false) === true, fn ($q) => $q->where('cat', '!=', 'lychee SE'))
->when(!$request->is_se() && !Configs::getValueAsBool('enable_se_preview'), fn ($q) => $q->where('level', '=', 0))
->orderBy('cat', 'asc')->get();

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Models/AlbumResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(Album $album)

// thumb
$this->cover_id = $album->cover_id;
$this->thumb = ThumbResource::make($album->thumb?->id, $album->thumb?->type, $album->thumb?->thumbUrl, $album->thumb?->thumb2xUrl, $album->thumb?->placeholderUrl);
$this->thumb = ThumbResource::fromModel($album->thumb);

// security
$this->policy = AlbumProtectionPolicy::ofBaseAlbum($album);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Models/SmartAlbumResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(BaseSmartAlbum $smartAlbum)
$this->photos = $smartAlbum->relationLoaded('photos') ? PhotoResource::collect($smartAlbum->getPhotos()) : null;
$this->prepPhotosCollection();

$this->thumb = ThumbResource::make($smartAlbum->thumb?->id, $smartAlbum->thumb?->type, $smartAlbum->thumb?->thumbUrl, $smartAlbum->thumb?->thumb2xUrl, $smartAlbum->thumb?->placeholderUrl);
$this->thumb = ThumbResource::fromModel($smartAlbum->thumb);
$this->policy = AlbumProtectionPolicy::ofSmartAlbum($smartAlbum);
$this->rights = new AlbumRightsResource($smartAlbum);
$url = $this->getHeaderUrl($smartAlbum);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Models/TagAlbumResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(TagAlbum $tagAlbum)
$this->prepPhotosCollection();

// thumb
$this->thumb = ThumbResource::make($tagAlbum->thumb?->id, $tagAlbum->thumb?->type, $tagAlbum->thumb?->thumbUrl, $tagAlbum->thumb?->thumb2xUrl, $tagAlbum->thumb?->placeholderUrl);
$this->thumb = ThumbResource::fromModel($tagAlbum->thumb);

// security
$this->policy = AlbumProtectionPolicy::ofBaseAlbum($tagAlbum);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Models/ThumbAlbumResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(AbstractAlbum $data)
$date_format = Configs::getValueAsString('date_format_album_thumb');

$this->id = $data->id;
$this->thumb = $data->thumb === null ? null : new ThumbResource($data->thumb->id, $data->thumb->type, $data->thumb->thumbUrl, $data->thumb->thumb2xUrl, $data->thumb->placeholderUrl);
$this->thumb = ThumbResource::fromModel($data->thumb);
$this->title = $data->title;

if ($data instanceof BaseSmartAlbum) {
Expand Down
21 changes: 8 additions & 13 deletions app/Http/Resources/Models/ThumbResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Resources\Models;

use App\Models\Extensions\Thumb;
use Spatie\LaravelData\Data;
use Spatie\TypeScriptTransformer\Attributes\TypeScript;

Expand All @@ -24,24 +25,18 @@ public function __construct(string $id, string $type, string $thumbUrl, ?string
}

/**
* @param string|null $id
* @param string|null $type
* @param string|null $thumbUrl
* @param string|null $thumb2xUrl
* @param string|null $placeholderUrl
* Produce a thumb resource from a Thumb object if existing.
*
* @return ($id is null ? null : ThumbResource)
* @param Thumb|null $thumb
*
* @return ThumbResource|null
*/
public static function make(?string $id, ?string $type, ?string $thumbUrl, ?string $thumb2xUrl = null, ?string $placeholderUrl = null): ?self
public static function fromModel(?Thumb $thumb): ?self
{
if ($id === null) {
if ($thumb === null) {
return null;
}

/** @var string $id */
/** @var string $type */
/** @var string $thumbUrl */
/** @var string $placeholderUrl */
return new self($id, $type, $thumbUrl, $thumb2xUrl, $placeholderUrl);
return new self($thumb->id, $thumb->type, $thumb->thumbUrl, $thumb->thumb2xUrl, $thumb->placeholderUrl);
}
}
Loading

0 comments on commit 661ad7d

Please sign in to comment.