[Scummvm-git-logs] scummvm-web master -> 24f1fa47172bceab6fbb2074d5a19b1e4343eb2a
lephilousophe
noreply at scummvm.org
Sat Nov 9 18:06:06 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .
Summary:
8540d5da28 WEB: Allow listing of screenshots for "other" company id
24f1fa4717 WEB: Cache screenshots listings
Commit: 8540d5da28a5bd168f53df2b408f19be859d54cc
https://github.com/scummvm/scummvm-web/commit/8540d5da28a5bd168f53df2b408f19be859d54cc
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-11-09T19:03:50+01:00
Commit Message:
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.
Changed paths:
include/Models/ScreenshotsModel.php
include/OrmObjects/ScreenshotQuery.php
diff --git a/include/Models/ScreenshotsModel.php b/include/Models/ScreenshotsModel.php
index 884adf6a..a6161b39 100644
--- a/include/Models/ScreenshotsModel.php
+++ b/include/Models/ScreenshotsModel.php
@@ -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);
diff --git a/include/OrmObjects/ScreenshotQuery.php b/include/OrmObjects/ScreenshotQuery.php
index e380f6fc..f62fbb9a 100644
--- a/include/OrmObjects/ScreenshotQuery.php
+++ b/include/OrmObjects/ScreenshotQuery.php
@@ -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');
+ }
}
Commit: 24f1fa47172bceab6fbb2074d5a19b1e4343eb2a
https://github.com/scummvm/scummvm-web/commit/24f1fa47172bceab6fbb2074d5a19b1e4343eb2a
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-11-09T19:03:50+01:00
Commit Message:
WEB: Cache screenshots listings
And make sure there is no cache collision between categories and
subcategories.
Changed paths:
include/Models/ScreenshotsModel.php
diff --git a/include/Models/ScreenshotsModel.php b/include/Models/ScreenshotsModel.php
index a6161b39..379d2cfc 100644
--- a/include/Models/ScreenshotsModel.php
+++ b/include/Models/ScreenshotsModel.php
@@ -43,7 +43,8 @@ class ScreenshotsModel extends BasicModel
/* Get all screenshots in one category. */
public function getScreenshotsByCompanyId($companyId)
{
- $data = $this->getFromCache($companyId);
+ $cache_key = "c_{$companyId}";
+ $data = $this->getFromCache($cache_key);
if (!$data) {
$screenshots = ScreenshotQuery::create()
->filterByCompanyId($companyId)
@@ -59,6 +60,7 @@ class ScreenshotsModel extends BasicModel
'category' => $companyId,
'games' => $this->combineSubcategories($screenshots)
];
+ $this->saveToCache($data, $cache_key);
}
return $data;
}
@@ -66,7 +68,8 @@ class ScreenshotsModel extends BasicModel
/* Get screenshots for a specific target. */
public function getScreenshotsBySubcategory($target)
{
- $data = $this->getFromCache($target);
+ $cache_key = "s_{$target}";
+ $data = $this->getFromCache($cache_key);
if (!$data) {
$screenshots = ScreenshotQuery::create()
->joinGame()
@@ -80,6 +83,7 @@ class ScreenshotsModel extends BasicModel
}
$data = [$combinedScreenshot];
+ $this->saveToCache($data, $cache_key);
}
return $data;
}
More information about the Scummvm-git-logs
mailing list