Major Backend Single Responsibility Update part 1
This commit is contained in:
1 parent
65177c7553
commit
cbdffb21e3
41 files changed
+1723
-888
No files matched your search
@@ -1,8 +1,6 @@
|
||||
const express = require('express');
|
||||
const collectionRouter = express.Router();
|
||||
|
||||
const { doGeneratePreview } = require('../services/mediaService');
|
||||
|
||||
const { Sequelize } = require('sequelize');
|
||||
const Collection = require('../models/Collection');
|
||||
const UserCollectionEntry = require('../models/UserCollectionEntry');
|
||||
@@ -13,9 +11,13 @@ const Season = require('../models/Season');
|
||||
const Genre = require('../models/Genre');
|
||||
const Media = require('../models/Media');
|
||||
|
||||
const { getCollectionParts, upsertOfficialCollection } = require('../services/models-services/collectionService');
|
||||
const { collectionPicturesUpload } = require('../services/mutlerStorageLocations');
|
||||
const { logToFile } = require('../services/logService');
|
||||
const collectionManager = require('../services/collectionManager');
|
||||
const mediaOptimizerService = require('../services/mediaOptimizerService');
|
||||
|
||||
const _mediaOptimizerService = mediaOptimizerService;
|
||||
const _collectionManager = collectionManager;
|
||||
|
||||
// ! /collections
|
||||
// * GET - ALL COLLECTIONS
|
||||
@@ -120,7 +122,7 @@ collectionRouter.put('/:id', upload, async (req, res) => {
|
||||
|
||||
if (posterPath) {
|
||||
// ? generating preview
|
||||
doGeneratePreview("collections", 'posters', posterPath).then((result) => {
|
||||
_mediaOptimizerService.doGeneratePreview("collections", 'posters', posterPath).then((result) => {
|
||||
const msg = `Collection Service | Generated Collection Preview`;
|
||||
logToFile(msg);
|
||||
}).catch((err) => {
|
||||
@@ -142,7 +144,7 @@ collectionRouter.put('/:id', upload, async (req, res) => {
|
||||
|
||||
if (backdropPath) {
|
||||
// ? generating preview
|
||||
doGeneratePreview("collections", 'backdrops', backdropPath).then((result) => {
|
||||
_mediaOptimizerService.doGeneratePreview("collections", 'backdrops', backdropPath).then((result) => {
|
||||
const msg = `Collection Routes | Generated Collection Preview`;
|
||||
logToFile(msg);
|
||||
}).catch((err) => {
|
||||
@@ -202,26 +204,7 @@ collectionRouter.put('/:id/refresh', async (req, res) => {
|
||||
const collectionId = req.params.id;
|
||||
const oldCollection = await Collection.findByPk(collectionId);
|
||||
|
||||
const collection = await upsertOfficialCollection(oldCollection.tmdbId);
|
||||
|
||||
// const collection = await Collection.findByPk(collectionId, {
|
||||
// include: [{
|
||||
// model: Entry,
|
||||
// as: 'entries',
|
||||
// include: [
|
||||
// { model: EntryId, as: 'entryId' },
|
||||
// { model: EntryRating, as: 'entryRating' },
|
||||
// { model: Season, as: 'seasons' },
|
||||
// { model: Media, as: 'medias' },
|
||||
// { model: Genre, as: 'genres' },
|
||||
// ],
|
||||
// through: {
|
||||
// model: UserCollectionEntry,
|
||||
// attributes: ['order'], // attributes (to include) from the join model
|
||||
// },
|
||||
// }],
|
||||
// order: [[Sequelize.literal("`entries->UserCollectionEntry`.`order`"), 'ASC']], // sort by 'order' in ascending order
|
||||
// });
|
||||
const collection = await _collectionManager.fetchAndSaveCollection(oldCollection.tmdbId);
|
||||
|
||||
if (collection) {
|
||||
const collectionData = collection.get({ plain: true });
|
||||
@@ -245,7 +228,7 @@ collectionRouter.put('/:id/parts', async (req, res) => {
|
||||
try {
|
||||
const collectionId = req.params.id;
|
||||
|
||||
await getCollectionParts(collectionId);
|
||||
await _collectionManager.getCollectionParts(collectionId);
|
||||
|
||||
const collection = await Collection.findByPk(collectionId, {
|
||||
include: [
|
||||
|
||||
Reference in new issue
Block a user