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

Smart album - On This Day - new feature #1607

Merged
merged 19 commits into from
Dec 6, 2022
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
2 changes: 2 additions & 0 deletions app/Factories/AlbumFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Extensions\BaseAlbum;
use App\Models\TagAlbum;
use App\SmartAlbums\BaseSmartAlbum;
use App\SmartAlbums\OnThisDayAlbum;
use App\SmartAlbums\PublicAlbum;
use App\SmartAlbums\RecentAlbum;
use App\SmartAlbums\StarredAlbum;
Expand All @@ -24,6 +25,7 @@ class AlbumFactory
StarredAlbum::ID => StarredAlbum::class,
PublicAlbum::ID => PublicAlbum::class,
RecentAlbum::ID => RecentAlbum::class,
OnThisDayAlbum::ID => OnThisDayAlbum::class,
];

/**
Expand Down
1 change: 1 addition & 0 deletions app/Locale/ChineseSimplified.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => '星标',
'RECENT' => '最新',
'PUBLIC' => '公开',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => '照片',

'CREATE_ALBUM' => '创建相册',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/ChineseTraditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => '我的最愛',
'RECENT' => '最新',
'PUBLIC' => '公開',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => '照片',

'CREATE_ALBUM' => '創建相簿',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Czech.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Oblíbené',
'RECENT' => 'Poslední',
'PUBLIC' => 'Veřejné',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'fotografií',

'CREATE_ALBUM' => 'Vytvořit album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Dutch.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Met ster',
'RECENT' => 'Recentelijk',
'PUBLIC' => 'Publiekelijk',
'ON_THIS_DAY' => 'Deze Dag',
'NUM_PHOTOS' => 'Foto’s',

'CREATE_ALBUM' => 'Maak Album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/English.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Starred',
'RECENT' => 'Recent',
'PUBLIC' => 'Public',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Photos',

'CREATE_ALBUM' => 'Create Album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/French.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Favoris',
'RECENT' => 'Récent',
'PUBLIC' => 'Public',
'ON_THIS_DAY' => 'Ce jour-là',
'NUM_PHOTOS' => 'Photos',

'CREATE_ALBUM' => 'Créer un album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/German.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Favoriten',
'RECENT' => 'Zuletzt benutzt',
'PUBLIC' => 'Öffentlich',
'ON_THIS_DAY' => 'An diesem Tag',
'NUM_PHOTOS' => 'Fotos',

'CREATE_ALBUM' => 'Album erstellen',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Greek.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Με Αστέρι',
'RECENT' => 'Πρόσφατα',
'PUBLIC' => 'Δημόσια',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Φωτογραφίες',

'CREATE_ALBUM' => 'Δημιουργία Λευκώματος',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Italian.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Speciali',
'RECENT' => 'Recenti',
'PUBLIC' => 'Pubbliche',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Foto',

'CREATE_ALBUM' => 'Crea Album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/NorwegianBokmal.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Favoritter',
'RECENT' => 'Nylige',
'PUBLIC' => 'Offentlige',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Bilder',

'CREATE_ALBUM' => 'Lag Album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Polish.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Oznaczone',
'RECENT' => 'Ostatnie',
'PUBLIC' => 'Publiczne',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Zdjęć',

'CREATE_ALBUM' => 'Utwórz album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Portuguese.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Favoritas',
'RECENT' => 'Recentes',
'PUBLIC' => 'Públicas',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Fotografias',

'CREATE_ALBUM' => 'Criar Álbum',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Russian.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Отмеченные',
'RECENT' => 'Последние',
'PUBLIC' => 'Общие',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'фотографий',

'CREATE_ALBUM' => 'Создать альбом',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Slovak.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Obľúbený',
'RECENT' => 'Naposledy použitý',
'PUBLIC' => 'Verejný',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'obrázkov',

'CREATE_ALBUM' => 'Album vytvoriť',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Spanish.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Destacado',
'RECENT' => 'Reciente',
'PUBLIC' => 'Público',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Fotos',

'CREATE_ALBUM' => 'Crear Álbum',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Swedish.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Stjärnmärkta',
'RECENT' => 'Nyligen',
'PUBLIC' => 'Publika',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Fotografier',

'CREATE_ALBUM' => 'Skapa album',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Vietnamese.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function get_locale(): array
'STARRED' => 'Được dánh dấu sao',
'RECENT' => 'Gần đây',
'PUBLIC' => 'Công cộng',
'ON_THIS_DAY' => 'On This Day',
'NUM_PHOTOS' => 'Hình ảnh',

'CREATE_ALBUM' => 'Tạo album',
Expand Down
49 changes: 49 additions & 0 deletions app/SmartAlbums/OnThisDayAlbum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\SmartAlbums;

use App\Exceptions\ConfigurationKeyMissingException;
use App\Exceptions\Internal\FrameworkException;
use Carbon\Exceptions\InvalidFormatException;
use Carbon\Exceptions\InvalidTimeZoneException;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;

class OnThisDayAlbum extends BaseSmartAlbum
{
private static ?self $instance = null;
public const ID = 'on_this_day';
public const TITLE = 'On This Day';

/**
* @throws InvalidFormatException
* @throws InvalidTimeZoneException
* @throws ConfigurationKeyMissingException
* @throws FrameworkException
*/
protected function __construct()
{
$today = Carbon::today();

parent::__construct(
self::ID,
self::TITLE,
false,
function (Builder $query) use ($today) {
$query->where(fn (Builder $q) => $q
->whereMonth('photos.taken_at', '=', $today->month)
->whereDay('photos.taken_at', '=', $today->day))
->orWhere(fn (Builder $q) => $q
->whereNull('photos.taken_at')
->whereYear('photos.created_at', '<', $today->year)
->whereMonth('photos.created_at', '=', $today->month)
->whereDay('photos.created_at', '=', $today->day));
}
);
}

public static function getInstance(): self
{
return self::$instance ??= new self();
}
}
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parameters:
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::insert\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::select\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::orderBy\(\)#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::where(Not)?(Null|In|Between|Exists|Column)?\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::where(Not)?(Null|In|Between|Exists|Column|Year|Month|Day)?\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::delete\(\)#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::without\(\)#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::count\(\).#'
Expand Down
Loading