Board: gelber Punkt bei befördertem Wunsch, promoted_at Tracking
This commit is contained in:
@@ -146,7 +146,10 @@ router.get('/board/unread', authenticate, (req, res) => {
|
||||
const unread = lastRead
|
||||
? db.prepare("SELECT COUNT(*) c FROM board_items WHERE created_at > ? AND user_id != ?").get(lastRead, u).c
|
||||
: db.prepare('SELECT COUNT(*) c FROM board_items WHERE user_id != ?').get(u).c;
|
||||
res.json({ unread });
|
||||
const unreadPromoted = lastRead
|
||||
? db.prepare("SELECT COUNT(*) c FROM board_items WHERE promoted_at > ? AND user_id != ?").get(lastRead, u).c
|
||||
: db.prepare("SELECT COUNT(*) c FROM board_items WHERE promoted_at IS NOT NULL AND user_id != ?").get(u).c;
|
||||
res.json({ unread, unreadPromoted });
|
||||
});
|
||||
|
||||
router.post('/board/read', authenticate, (req, res) => {
|
||||
@@ -195,7 +198,7 @@ router.post('/board/:id/promote', authenticate, (req, res) => {
|
||||
const item = db.prepare('SELECT * FROM board_items WHERE id=?').get(req.params.id);
|
||||
if (!item) return res.status(404).json({ error: 'Nicht gefunden' });
|
||||
if (item.type !== 'wish') return res.status(400).json({ error: 'Nur Wünsche können befördert werden' });
|
||||
db.prepare('UPDATE board_items SET type=?, promoted_from_wish=1 WHERE id=?').run('roadmap', item.id);
|
||||
db.prepare("UPDATE board_items SET type='roadmap', promoted_from_wish=1, promoted_at=datetime('now','localtime') WHERE id=?").run(item.id);
|
||||
const updated = db.prepare(`
|
||||
SELECT b.*, u.username as author FROM board_items b
|
||||
JOIN users u ON u.id=b.user_id WHERE b.id=?
|
||||
|
||||
Reference in New Issue
Block a user