Fix active source detection by including team names in lookup
- Update streams API to join with teams table and return StreamWithTeam data - Modify stream lookup maps to generate proper stream group names with team prefixes - Format: {team_name}_{stream_name}_stream to match obsClient.js logic - Update type signatures throughout to support team_name and group_name fields - Now properly matches text file contents with database streams for dropdown selection 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5dd9707f13
commit
f9363eac20
3 changed files with 20 additions and 14 deletions
|
@ -1,13 +1,20 @@
|
|||
import { NextResponse } from 'next/server';
|
||||
import { getDatabase } from '../../../lib/database';
|
||||
import { Stream } from '@/types';
|
||||
import { StreamWithTeam } from '@/types';
|
||||
import { TABLE_NAMES } from '../../../lib/constants';
|
||||
import { createSuccessResponse, createDatabaseError, withErrorHandling } from '../../../lib/apiHelpers';
|
||||
|
||||
async function getStreamsHandler() {
|
||||
try {
|
||||
const db = await getDatabase();
|
||||
const streams: Stream[] = await db.all(`SELECT * FROM ${TABLE_NAMES.STREAMS}`);
|
||||
const streams: StreamWithTeam[] = await db.all(`
|
||||
SELECT
|
||||
s.*,
|
||||
t.team_name,
|
||||
t.group_name
|
||||
FROM ${TABLE_NAMES.STREAMS} s
|
||||
LEFT JOIN ${TABLE_NAMES.TEAMS} t ON s.team_id = t.team_id
|
||||
`);
|
||||
return createSuccessResponse(streams);
|
||||
} catch (error) {
|
||||
return createDatabaseError('fetch streams', error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue