Skip to content
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

Optimizing sql and improved Log data #1883

Merged
merged 18 commits into from
Jun 23, 2023
Merged
5 changes: 2 additions & 3 deletions app/Actions/Album/SetProtectionPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SetProtectionPolicy extends Action
public function do(BaseAlbum $album, AlbumProtectionPolicy $protectionPolicy, bool $shallSetPassword, ?string $password): void
{
$album->is_nsfw = $protectionPolicy->is_nsfw;
$active_permissions = $album->public_permissions;
$active_permissions = $album->public_permissions();

if (!$protectionPolicy->is_public) {
$active_permissions?->delete();
Expand Down Expand Up @@ -58,9 +58,8 @@ public function do(BaseAlbum $album, AlbumProtectionPolicy $protectionPolicy, bo
$active_permissions->password = null;
}
}
$album->public_permissions()->save($active_permissions);
$active_permissions->base_album_id = $album->id;
$active_permissions->save();
// $album->save();

// Reset permissions for photos
$album->photos()->update(['photos.is_public' => false]);
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Album/Unlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct()
*/
public function do(BaseAlbum $album, string $password): void
{
if ($album->public_permissions !== null) {
$album_password = $album->public_permissions->password;
if ($album->public_permissions() !== null) {
$album_password = $album->public_permissions()->password;
if (
$album_password === null ||
$album_password === '' ||
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Albums/Top.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public function get(): TopAlbumsResource
}

$tagAlbumQuery = $this->albumQueryPolicy
->applyVisibilityFilter(TagAlbum::query()->with(['owner']));
->applyVisibilityFilter(TagAlbum::query()->with(['access_permissions', 'owner']));
/** @var BaseCollection<TagAlbum> $tagAlbums */
$tagAlbums = (new SortingDecorator($tagAlbumQuery))
->orderBy($this->sorting->column, $this->sorting->order)
->get();

/** @var NsQueryBuilder $query */
$query = $this->albumQueryPolicy
->applyVisibilityFilter(Album::query()->with(['owner'])->whereIsRoot());
->applyVisibilityFilter(Album::query()->with(['access_permissions', 'owner'])->whereIsRoot());

$userID = Auth::id();
if ($userID !== null) {
Expand Down
Loading