More refactor

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/563/head
Varun Patil 2023-03-23 21:57:54 -07:00
parent bf5d26e71a
commit c867cc68ed
9 changed files with 20 additions and 24 deletions

View File

@ -26,7 +26,6 @@ namespace OCA\Memories\AppInfo;
use OCA\Memories\ClustersBackend;
use OCA\Memories\Listeners\PostDeleteListener;
use OCA\Memories\Listeners\PostWriteListener;
use OCA\Memories\Manager\ClustersBackendManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@ -76,11 +75,11 @@ class Application extends App implements IBootstrap
$context->registerEventListener(NodeDeletedEvent::class, PostDeleteListener::class);
// Register clusters backends
ClustersBackendManager::register('albums', ClustersBackend\AlbumsBackend::class);
ClustersBackendManager::register('tags', ClustersBackend\TagsBackend::class);
ClustersBackendManager::register('places', ClustersBackend\PlacesBackend::class);
ClustersBackendManager::register('recognize', ClustersBackend\RecognizeBackend::class);
ClustersBackendManager::register('facerecognition', ClustersBackend\FaceRecognitionBackend::class);
ClustersBackend\Manager::register('albums', ClustersBackend\AlbumsBackend::class);
ClustersBackend\Manager::register('tags', ClustersBackend\TagsBackend::class);
ClustersBackend\Manager::register('places', ClustersBackend\PlacesBackend::class);
ClustersBackend\Manager::register('recognize', ClustersBackend\RecognizeBackend::class);
ClustersBackend\Manager::register('facerecognition', ClustersBackend\FaceRecognitionBackend::class);
}
public function boot(IBootContext $context): void

View File

@ -21,12 +21,11 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Memories\Manager;
namespace OCA\Memories\ClustersBackend;
use OCA\Memories\ClustersBackend\Backend;
use OCP\IRequest;
class ClustersBackendManager
class Manager
{
/** Mapping of backend name to className */
public static array $backends = [];

View File

@ -23,9 +23,8 @@ declare(strict_types=1);
namespace OCA\Memories\Controller;
use OCA\Memories\ClustersBackend\Backend;
use OCA\Memories\ClustersBackend;
use OCA\Memories\Exceptions;
use OCA\Memories\Manager\ClustersBackendManager;
use OCA\Memories\Util;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
@ -34,7 +33,7 @@ use OCP\AppFramework\Http\JSONResponse;
class ClustersController extends GenericApiController
{
/** Current backend for this instance */
protected Backend $backend;
protected ClustersBackend\Backend $backend;
/**
* @NoAdminRequired
@ -112,7 +111,7 @@ class ClustersController extends GenericApiController
{
Util::getUser();
$this->backend = ClustersBackendManager::get($backend);
$this->backend = ClustersBackend\Manager::get($backend);
if (!$this->backend->isEnabled()) {
throw Exceptions::NotEnabled($this->backend->appName());

View File

@ -23,8 +23,8 @@ declare(strict_types=1);
namespace OCA\Memories\Controller;
use OCA\Memories\ClustersBackend;
use OCA\Memories\Exceptions;
use OCA\Memories\Manager\ClustersBackendManager;
use OCA\Memories\Util;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
@ -146,7 +146,8 @@ class DaysController extends GenericApiController
$transforms = [];
// Add clustering transforms
$transforms = array_merge($transforms, ClustersBackendManager::getTransforms($this->request));
$clusterTs = ClustersBackend\Manager::getTransforms($this->request);
$transforms = array_merge($transforms, $clusterTs);
// Other transforms not allowed for public shares
if (!Util::isLoggedIn()) {

View File

@ -24,8 +24,8 @@ declare(strict_types=1);
namespace OCA\Memories\Controller;
use OCA\Memories\AppInfo\Application;
use OCA\Memories\Db\FsManager;
use OCA\Memories\Db\TimelineQuery;
use OCA\Memories\Manager\FsManager;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\Files\IRootFolder;

View File

@ -3,6 +3,7 @@
namespace OCA\Memories\Controller;
use OCA\Memories\AppInfo\Application;
use OCA\Memories\Db\FsManager;
use OCA\Memories\Db\TimelineQuery;
use OCP\AppFramework\AuthPublicShareController;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
@ -98,7 +99,7 @@ class PublicController extends AuthPublicShareController
throw new NotFoundException();
}
if (!\OCA\Memories\Manager\FsManager::validateShare($share)) {
if (!FsManager::validateShare($share)) {
throw new NotFoundException();
}

View File

@ -21,10 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Memories\Manager;
namespace OCA\Memories\Db;
use OCA\Memories\Db\AlbumsQuery;
use OCA\Memories\Db\TimelineRoot;
use OCA\Memories\Exceptions;
use OCA\Memories\Exif;
use OCA\Memories\Util;

View File

@ -36,8 +36,7 @@ class TimelineQuery
{
if (null === $this->_root) {
$this->_root = new TimelineRoot();
$fsManager = \OC::$server->get(\OCA\Memories\Manager\FsManager::class);
$fsManager->populateRoot($this->_root);
\OC::$server->get(FsManager::class)->populateRoot($this->_root);
}
return $this->_root;

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace OCA\Memories\Db;
use OCA\Memories\Manager\ClustersBackendManager;
use OCA\Memories\ClustersBackend;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@ -275,7 +275,7 @@ trait TimelineQueryDays
}
// All cluster transformations
ClustersBackendManager::applyDayPostTransforms($this->request, $row);
ClustersBackend\Manager::applyDayPostTransforms($this->request, $row);
// We don't need these fields
unset($row['datetaken']);