Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/api/clips/[clipId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export async function GET(
const { clipId } = await params;

try {
const clipRow = getClipById(clipId);
const clipRow = await getClipById(clipId);

if (!clipRow) {
return NextResponse.json({ error: "Clip not found" }, { status: 404 });
}

const recording = getRecordingById(clipRow.recording_id);
const recording = await getRecordingById(clipRow.recording_id);
const clip = {
...dbRowToClip(clipRow),
recordingTitle: recording?.title ?? "Unknown Recording",
Expand All @@ -37,7 +37,7 @@ export async function DELETE(
const { clipId } = await params;

try {
const deleted = deleteClip(clipId);
const deleted = await deleteClip(clipId);

if (!deleted) {
return NextResponse.json({ error: "Clip not found" }, { status: 404 });
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/clips/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getAllClipsWithRecordingTitle, dbRowToClip } from "@/lib/db";

export async function GET() {
try {
const clipRows = getAllClipsWithRecordingTitle();
const clipRows = await getAllClipsWithRecordingTitle();
const clips = clipRows.map((row) => ({
...dbRowToClip(row),
recordingTitle: row.recording_title,
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/participants/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getAllUniqueParticipants } from "@/lib/db";

export async function GET() {
try {
const participants = getAllUniqueParticipants();
const participants = await getAllUniqueParticipants();
return NextResponse.json(participants);
} catch (error) {
console.error("Failed to fetch participants:", error);
Expand Down
8 changes: 4 additions & 4 deletions src/app/api/recordings/[id]/clips/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export async function GET(
const { id: recordingId } = await params;

try {
const recording = getRecordingById(recordingId);
const recording = await getRecordingById(recordingId);
if (!recording) {
return NextResponse.json(
{ error: "Recording not found" },
{ status: 404 }
);
}

const clipRows = getClipsByRecordingId(recordingId);
const clipRows = await getClipsByRecordingId(recordingId);
const clips = clipRows.map(dbRowToClip);

return NextResponse.json(clips);
Expand All @@ -42,7 +42,7 @@ export async function POST(
const { id: recordingId } = await params;

try {
const recording = getRecordingById(recordingId);
const recording = await getRecordingById(recordingId);
if (!recording) {
return NextResponse.json(
{ error: "Recording not found" },
Expand Down Expand Up @@ -82,7 +82,7 @@ export async function POST(
}

const clipId = nanoid(8);
const clipRow = insertClip({
const clipRow = await insertClip({
id: clipId,
recordingId,
title: title || undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/recordings/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function PATCH(
const { customTitle } = body;

// Verify recording exists
const recording = getRecordingById(id);
const recording = await getRecordingById(id);
if (!recording) {
return NextResponse.json(
{ error: "Recording not found" },
Expand All @@ -58,7 +58,7 @@ export async function PATCH(
}

// Update custom title (null to revert to original)
updateRecordingCustomTitle(id, customTitle ?? null);
await updateRecordingCustomTitle(id, customTitle ?? null);

return NextResponse.json({ success: true, customTitle: customTitle ?? null });
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/recordings/[id]/summary/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function GET(
const { id } = await params;

try {
const summaryRow = getSummaryByRecordingId(id);
const summaryRow = await getSummaryByRecordingId(id);

if (!summaryRow) {
return NextResponse.json(
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function POST(

try {
// Get transcript segments
const segments = getSegmentsByRecordingId(id);
const segments = await getSegmentsByRecordingId(id);

if (segments.length === 0) {
return NextResponse.json(
Expand All @@ -68,7 +68,7 @@ export async function POST(
const summary = await generateTranscriptSummary(transcriptSegments);

// Save to database
upsertSummary({
await upsertSummary({
recordingId: id,
content: JSON.stringify(summary),
model: SUMMARY_MODEL,
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/recordings/paginated/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export async function GET(request: Request) {

const sourceFilter = source === "zoom" || source === "gong" ? source : "all";

const result = getRecordingsPaginated(sourceFilter, limit, cursor);
const result = await getRecordingsPaginated(sourceFilter, limit, cursor);

const speakersByRecording = getSpeakersByRecordingIds(
const speakersByRecording = await getSpeakersByRecordingIds(
result.items.map((r) => r.id)
);

// Fetch summaries if requested (for grid view)
const summariesByRecording = includeSummaries
? getSummariesByRecordingIds(result.items.map((r) => r.id))
? await getSummariesByRecordingIds(result.items.map((r) => r.id))
: {};

const recordingsWithMeta = result.items.map((recording) => {
Expand Down
12 changes: 10 additions & 2 deletions src/app/api/speakers/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { NextResponse } from "next/server";
import { getAllUniqueSpeakers } from "@/lib/db";

export async function GET() {
const speakers = getAllUniqueSpeakers();
return NextResponse.json(speakers);
try {
const speakers = await getAllUniqueSpeakers();
return NextResponse.json(speakers);
} catch (error) {
console.error("Failed to fetch speakers:", error);
return NextResponse.json(
{ error: "Failed to fetch speakers" },
{ status: 500 }
);
}
}
6 changes: 3 additions & 3 deletions src/app/c/[clipId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export async function generateMetadata({
params: Promise<{ clipId: string }>;
}): Promise<Metadata> {
const { clipId } = await params;
const clipRow = getClipById(clipId);
const clipRow = await getClipById(clipId);

if (!clipRow) {
return { title: "Clip Not Found" };
}

const recording = getRecordingById(clipRow.recording_id);
const recording = await getRecordingById(clipRow.recording_id);
const clip = dbRowToClip(clipRow);
const duration = formatDuration(clip.endTime - clip.startTime);
const recordingTitle = recording?.custom_title ?? recording?.title ?? "Recording";
Expand Down Expand Up @@ -51,7 +51,7 @@ export default async function ClipRedirectPage({
params: Promise<{ clipId: string }>;
}) {
const { clipId } = await params;
const clipRow = getClipById(clipId);
const clipRow = await getClipById(clipId);

if (!clipRow) {
notFound();
Expand Down
18 changes: 9 additions & 9 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default async function HomePage({

// If clips view, fetch clips instead of recordings
if (isClipsView) {
const clipRows = getAllClipsWithRecordingTitle();
const clipRows = await getAllClipsWithRecordingTitle();
const clipsWithRecordings = clipRows.map((row) => ({
...dbRowToClip(row),
recordingTitle: row.recording_title,
Expand All @@ -76,21 +76,21 @@ export default async function HomePage({

if (speakers.length > 0) {
// Speaker search - filter by all selected speakers (AND logic)
const results = searchRecordingsWithSpeaker(q ?? "", speakers, sourceFilter);
const results = await searchRecordingsWithSpeaker(q ?? "", speakers, sourceFilter);
recordings = results.map((r) => ({ ...r, match_type: "speaker" as const, match_text: null, match_time: null }));
} else if (participant) {
// Participant search by email
const results = searchRecordingsWithParticipant(q ?? "", participant, sourceFilter);
const results = await searchRecordingsWithParticipant(q ?? "", participant, sourceFilter);
recordings = results.map((r) => ({ ...r, match_type: "speaker" as const, match_text: null, match_time: null }));
} else if (q) {
recordings = searchRecordingsWithContext(q, sourceFilter);
recordings = await searchRecordingsWithContext(q, sourceFilter);
} else if (isCalendarView) {
// Calendar view needs all recordings to display the full timeline
const allRecordings = getRecordingsBySource(sourceFilter);
const allRecordings = await getRecordingsBySource(sourceFilter);
recordings = allRecordings.map((r) => ({ ...r, match_type: "title" as const, match_text: null, match_time: null }));
} else {
// Use paginated query for initial load (faster)
const result = getRecordingsPaginated(sourceFilter, 20);
const result = await getRecordingsPaginated(sourceFilter, 20);
paginatedResult = {
items: result.items.map((r) => ({ ...r, match_type: "title" as const, match_text: null, match_time: null })),
hasMore: result.hasMore,
Expand All @@ -107,13 +107,13 @@ export default async function HomePage({
if (!gongConfigured) missingCredentials.push("Gong");

// Prepare recordings data for client components
const speakersByRecording = getSpeakersByRecordingIds(
const speakersByRecording = await getSpeakersByRecordingIds(
recordings.map((r) => r.id)
);

// Fetch summaries for grid view
const summariesByRecording = isGridView
? getSummariesByRecordingIds(recordings.map((r) => r.id))
? await getSummariesByRecordingIds(recordings.map((r) => r.id))
: {};

const recordingsWithMeta = recordings.map((recording) => {
Expand Down Expand Up @@ -151,7 +151,7 @@ export default async function HomePage({
<SourceFilter currentSource={sourceFilter} />
<SearchInput defaultValue={q} defaultSpeakers={speakers} defaultParticipant={participant} />
<span className="shrink-0 text-sm text-zinc-500">
{getTotalRecordingsCount(sourceFilter)} videos
{await getTotalRecordingsCount(sourceFilter)} videos
</span>
</div>
</Suspense>
Expand Down
22 changes: 11 additions & 11 deletions src/app/recordings/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@ export default async function RecordingPage({
return <RecordingPageContent recording={mockRecording} relatedRecordings={[]} videoViews={[]} summary={null} activeClip={null} clips={[]} participants={[]} />;
}

// Try SQLite database
const row = getRecordingById(id);
// Try D1 database
const row = await getRecordingById(id);
if (!row) {
notFound();
}

const segments = getSegmentsByRecordingId(id);
const speakers = getSpeakersByRecordingId(id);
const participants = getParticipantsByRecordingId(id);
const relatedRecordings = getRelatedRecordings(row.title, id);
const videoFiles = getVideoFilesByRecordingId(id);
const chatMessages = getChatMessagesByRecordingId(id);
const summaryRow = getSummaryByRecordingId(id);
const clipRows = getClipsByRecordingId(id);
const segments = await getSegmentsByRecordingId(id);
const speakers = await getSpeakersByRecordingId(id);
const participants = await getParticipantsByRecordingId(id);
const relatedRecordings = await getRelatedRecordings(row.title, id);
const videoFiles = await getVideoFilesByRecordingId(id);
const chatMessages = await getChatMessagesByRecordingId(id);
const summaryRow = await getSummaryByRecordingId(id);
const clipRows = await getClipsByRecordingId(id);
const clips = clipRows.map(dbRowToClip);

// Get active clip if specified
let activeClip: Clip | null = null;
if (clipId) {
const clipRow = getClipById(clipId);
const clipRow = await getClipById(clipId);
if (clipRow && clipRow.recording_id === id) {
activeClip = dbRowToClip(clipRow);
}
Expand Down
Loading