mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-05-21 05:40:47 +00:00
WEB: Allow listing of screenshots for "other" company id
The "other" company id is an aggregation of all games whose company has edited one game.
This commit is contained in:
@@ -46,11 +46,9 @@ class ScreenshotsModel extends BasicModel
|
||||
$data = $this->getFromCache($companyId);
|
||||
if (!$data) {
|
||||
$screenshots = ScreenshotQuery::create()
|
||||
->useGameQuery()
|
||||
->filterByCompanyId($companyId)
|
||||
->endUse()
|
||||
->withColumn(self::SUBCATEGORY_COLUMN, 'subcategory')
|
||||
->find();
|
||||
->withColumn(self::SUBCATEGORY_COLUMN, 'subcategory')
|
||||
->find();
|
||||
|
||||
if ($screenshots->count() === 0) {
|
||||
throw new \ErrorException(self::INVALID_CATEGORY);
|
||||
|
||||
@@ -7,6 +7,7 @@ use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Propel;
|
||||
use ScummVM\OrmObjects\Screenshot as ChildScreenshot;
|
||||
use ScummVM\OrmObjects\Map\GameTableMap;
|
||||
use ScummVM\OrmObjects\Map\ScreenshotTableMap;
|
||||
|
||||
/**
|
||||
@@ -96,4 +97,30 @@ class ScreenshotQuery extends BaseScreenshotQuery
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function filterByCompanyId($companyId, ConnectionInterface $con = null)
|
||||
{
|
||||
if ($companyId !== 'other') {
|
||||
return $this->useGameQuery()
|
||||
->filterByCompanyId($companyId)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
// other company id means all companies with at most 1 game
|
||||
$subquery = ScreenshotQuery::create()->useGameQuery()
|
||||
->groupByCompanyId()
|
||||
->endUse()
|
||||
->withColumn('COUNT(DISTINCT((CASE
|
||||
WHEN ' . GameTableMap::COL_SERIES_ID . ' IS NULL
|
||||
THEN ' . ScreenshotTableMap::COL_ID . '
|
||||
ELSE ' . GameTableMap::COL_SERIES_ID . '
|
||||
END)))', 'cnt')
|
||||
->having('cnt <= 1')
|
||||
->withColumn(GameTableMap::COL_COMPANY_ID, 'company_id')
|
||||
->removeSelfSelectColumns();
|
||||
|
||||
return $this->joinGame()
|
||||
->addSelectQuery($subquery, 'c', false)
|
||||
->where(GameTableMap::COL_COMPANY_ID . ' = c.company_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user