Refactor Library::FilterArtwork and artworks/index.php to accept ArtworkSort

This commit is contained in:
Mike Colagrosso 2024-01-30 00:17:00 -07:00 committed by Alex Cabal
parent 004a4a27c3
commit 94dce1009a
2 changed files with 10 additions and 14 deletions

View file

@ -159,10 +159,10 @@ class Library{
/**
* @param string $query
* @param string $status
* @param string $sort
* @param ArtworkSort $sort
* @return Array<mixed>
*/
public static function FilterArtwork(string $query = null, string $status = null, string $sort = null, int $submitterUserId = null, int $page = 1, int $perPage = ARTWORK_PER_PAGE): array{
public static function FilterArtwork(string $query = null, string $status = null, ArtworkSort $sort = null, int $submitterUserId = null, int $page = 1, int $perPage = ARTWORK_PER_PAGE): array{
// Returns an array of:
// ['artworks'] => Array<Artwork>,
// ['artworksCount'] => int
@ -210,10 +210,10 @@ class Library{
}
$orderBy = 'art.Created desc';
if($sort == ArtworkSort::ArtistAlpha->value){
if($sort == ArtworkSort::ArtistAlpha){
$orderBy = 'a.Name';
}
elseif($sort == ArtworkSort::CompletedNewest->value){
elseif($sort == ArtworkSort::CompletedNewest){
$orderBy = 'art.CompletedYear desc';
}