diff options
| author | Zephyrrus <[email protected]> | 2020-07-08 03:13:51 +0300 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2020-07-08 03:13:51 +0300 |
| commit | 1a8b6602e094289a4f477c33e432e0f5e1587b45 (patch) | |
| tree | db6a8a6640b353136933682885a8d834865a3866 /src/api/routes/albums | |
| parent | fix: errors in Util caused by separating into different classes improperly (diff) | |
| download | host.fuwn.me-1a8b6602e094289a4f477c33e432e0f5e1587b45.tar.xz host.fuwn.me-1a8b6602e094289a4f477c33e432e0f5e1587b45.zip | |
refactor: change uploader component to use vuex
Diffstat (limited to 'src/api/routes/albums')
| -rw-r--r-- | src/api/routes/albums/albumsGET.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/api/routes/albums/albumsGET.js b/src/api/routes/albums/albumsGET.js index 569128c..c9ab025 100644 --- a/src/api/routes/albums/albumsGET.js +++ b/src/api/routes/albums/albumsGET.js @@ -1,3 +1,4 @@ +/* eslint-disable max-classes-per-file */ const Route = require('../../structures/Route'); const Util = require('../../utils/Util'); @@ -19,17 +20,15 @@ class albumsGET extends Route { .orderBy('createdAt', 'desc'); for (const album of albums) { - // TODO: Optimize the shit out of this. Ideally a JOIN that grabs all the needed stuff in 1 query instead of 3 - // Fetch the total amount of files each album has. - const fileCount = await db - .table('albumsFiles') // eslint-disable-line no-await-in-loop + const fileCount = await db // eslint-disable-line no-await-in-loop + .table('albumsFiles') .where('albumId', album.id) .count({ count: 'id' }); // Fetch the file list from each album but limit it to 5 per album - const files = await db - .table('albumsFiles') // eslint-disable-line no-await-in-loop + const files = await db // eslint-disable-line no-await-in-loop + .table('albumsFiles') .join('files', { 'files.id': 'albumsFiles.fileId' }) .where('albumId', album.id) .select('files.id', 'files.name') @@ -47,7 +46,7 @@ class albumsGET extends Route { return res.json({ message: 'Successfully retrieved albums', - albums + albums, }); } } @@ -64,7 +63,7 @@ class albumsDropdownGET extends Route { .select('id', 'name'); return res.json({ message: 'Successfully retrieved albums', - albums + albums, }); } } |