Skip to content

Commit

Permalink
Query playlists by site name and docker volume fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitkonikov committed Feb 9, 2024
1 parent 142571e commit 975fbe1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions backend/src/routers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@ import express from 'express';
import File from '../models/file.js';
import Trailer from '../models/trailer.js';
import Playlist from '../models/playlist.js';
import Site from '../models/site.js';

const router = express.Router();

router.get('/playlists', async (req, res) => {
const playlists = await Playlist.find()
.sort({ published: -1 }) // Sort in descending order based on the 'published' field
.limit(10); // Limit the result to the last 10 files
try {
const { site } = req.body;

const siteDoc = await Site.findOne({ name: site });

if (!siteDoc) {
console.log('No site found by the name ', site);
res.json({ error: 'No site found by the name.' });
return;
}

res.json({ playlists });
const playlists = await Playlist.find({ site: siteDoc._id })
.sort({ published: -1 }) // Sort in descending order based on the 'published' field
.limit(10); // Limit the result to the last 10 files

res.json({ playlists });
} catch (exception) {
console.log(exception);
res.json({ error: 'Internal server error' });
}
});

router.get('/films', async (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
ports:
- "27017:27017"
volumes:
- ~/data:/data
- ~/data/db:/data/db
networks:
- gateway_app-net

Expand Down

0 comments on commit 975fbe1

Please sign in to comment.