Initial Product release

This commit is contained in:
2026-07-13 21:44:49 +01:00
parent 2d3ff69c6e
commit 0837f4f529
84 changed files with 13174 additions and 36 deletions
+44
View File
@@ -0,0 +1,44 @@
function slugify(value) {
return String(value || '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '')
.replace(/-{2,}/g, '-');
}
async function uniqueScreenSlug(pool, baseSlug) {
const start = baseSlug || `screen-${Date.now()}`;
let candidate = start;
let counter = 2;
while (true) {
const [rows] = await pool.query('SELECT id FROM screens WHERE slug = ?', [candidate]);
if (!rows.length) {
return candidate;
}
candidate = `${start}-${counter}`;
counter += 1;
}
}
async function fetchScreenById(pool, id) {
const [rows] = await pool.query(`
SELECT s.*, p.name AS playlist_name
FROM screens s
LEFT JOIN playlists p ON p.id = s.playlist_id
WHERE s.id = ?
`, [id]);
return rows[0] || null;
}
async function fetchScreenEditData(pool) {
const [playlists] = await pool.query('SELECT * FROM playlists ORDER BY id DESC');
return { playlists };
}
module.exports = {
slugify,
uniqueScreenSlug,
fetchScreenById,
fetchScreenEditData
};