mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-16 04:57:46 +02:00
fix(platforms): add platforms service + reduce memory consumption when rendering platform cards
This commit is contained in:
parent
d4a36f811b
commit
fe73e9fae9
7 changed files with 92 additions and 69 deletions
20
modules/Platforms/Config/Services.php
Normal file
20
modules/Platforms/Config/Services.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Platforms\Config;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
use Modules\Platforms\Platforms;
|
||||
|
||||
class Services extends BaseService
|
||||
{
|
||||
public static function platforms(bool $getShared = true): Platforms
|
||||
{
|
||||
if ($getShared) {
|
||||
return self::getSharedInstance('platforms');
|
||||
}
|
||||
|
||||
return new Platforms();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ namespace Modules\Platforms\Models;
|
|||
|
||||
use CodeIgniter\Model;
|
||||
use Modules\Platforms\Entities\Platform;
|
||||
use Modules\Platforms\Platforms;
|
||||
|
||||
class PlatformModel extends Model
|
||||
{
|
||||
|
|
@ -55,7 +54,7 @@ class PlatformModel extends Model
|
|||
{
|
||||
$cacheName = "podcast#{$podcastId}_platforms_{$platformType}_withData";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$platforms = new Platforms();
|
||||
$platforms = service('platforms');
|
||||
|
||||
$found = $this->getPlatforms($podcastId, $platformType);
|
||||
$platformsData = $platforms->getPlatformsByType($platformType);
|
||||
|
|
@ -95,7 +94,7 @@ class PlatformModel extends Model
|
|||
{
|
||||
$cacheName = "podcast#{$podcastId}_platforms_{$platformType}";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$platforms = new Platforms();
|
||||
$platforms = service('platforms');
|
||||
|
||||
/** @var Platform[] $found */
|
||||
$found = $this
|
||||
|
|
@ -134,7 +133,7 @@ class PlatformModel extends Model
|
|||
{
|
||||
$this->clearCache($podcastId);
|
||||
|
||||
$platforms = new Platforms();
|
||||
$platforms = service('platforms');
|
||||
|
||||
$platformsData = $platforms->getPlatformsByType($platformType);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use League\HTMLToMarkdown\HtmlConverter;
|
|||
use Modules\Auth\Config\AuthGroups;
|
||||
use Modules\Auth\Models\UserModel;
|
||||
use Modules\Platforms\Models\PlatformModel;
|
||||
use Modules\Platforms\Platforms;
|
||||
use Modules\PodcastImport\Entities\PodcastImportTask;
|
||||
use Modules\PodcastImport\Entities\TaskStatus;
|
||||
use PodcastFeed\PodcastFeed;
|
||||
|
|
@ -390,7 +389,7 @@ class PodcastImport extends BaseCommand
|
|||
],
|
||||
];
|
||||
|
||||
$platforms = new Platforms();
|
||||
$platforms = service('platforms');
|
||||
$platformModel = new PlatformModel();
|
||||
foreach ($platformTypes as $platformType) {
|
||||
$platformsData = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue