mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 18:11:52 -04:00
Sort projects by ebook title
This commit is contained in:
parent
b2191d1219
commit
a1da50fc1a
3 changed files with 74 additions and 3 deletions
|
@ -24,6 +24,7 @@ use Safe\DateTimeImmutable;
|
|||
*/
|
||||
class Project{
|
||||
use Traits\Accessor;
|
||||
use Traits\FromRow;
|
||||
use Traits\PropertyFromHttp;
|
||||
|
||||
public int $ProjectId;
|
||||
|
@ -606,20 +607,37 @@ class Project{
|
|||
* @return array<Project>
|
||||
*/
|
||||
public static function GetAllByStatus(Enums\ProjectStatusType $status): array{
|
||||
return Db::Query('SELECT * from Projects where Status = ? order by Started desc', [$status], Project::class);
|
||||
return Db::Query('SELECT * from Projects inner join Ebooks using (EbookId) where Projects.Status = ? order by Title asc', [$status], Project::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Project>
|
||||
*/
|
||||
public static function GetAllByManagerUserId(int $userId): array{
|
||||
return Db::Query('SELECT * from Projects where ManagerUserId = ? and Status in (?, ?) order by Started desc', [$userId, Enums\ProjectStatusType::InProgress, Enums\ProjectStatusType::Stalled], Project::class);
|
||||
return Db::Query('SELECT * from Projects inner join Ebooks using (EbookId) where ManagerUserId = ? and Status in (?, ?) order by Title asc', [$userId, Enums\ProjectStatusType::InProgress, Enums\ProjectStatusType::Stalled], Project::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Project>
|
||||
*/
|
||||
public static function GetAllByReviewerUserId(int $userId): array{
|
||||
return Db::Query('SELECT * from Projects where ReviewerUserId = ? and Status in (?, ?) order by Started desc', [$userId, Enums\ProjectStatusType::InProgress, Enums\ProjectStatusType::Stalled], Project::class);
|
||||
return Db::Query('SELECT * from Projects inner join Ebooks using (EbookId) where ReviewerUserId = ? and Status in (?, ?) order by Title asc', [$userId, Enums\ProjectStatusType::InProgress, Enums\ProjectStatusType::Stalled], Project::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a `Project` from a multi table array containing a `Project` and an `Ebook`.
|
||||
*
|
||||
* @param array<string, stdClass> $row
|
||||
*/
|
||||
public static function FromMultiTableRow(array $row): Project{
|
||||
$object = Project::FromRow($row['Projects']);
|
||||
|
||||
// The Action may be null if it's a Scribophile adjustment. In that case, don't initialize the Action object.
|
||||
if($row['Ebooks']->EbookId !== null){
|
||||
$row['Ebooks']->Ebookid = $object->EbookId;
|
||||
$object->Ebook = Ebook::FromRow($row['Ebooks']);
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue