···
-
export function getAllTranscriptions(): Array<{
-
user_name: string | null;
-
original_filename: string;
-
error_message: string | null;
-
user_name: string | null;
-
original_filename: string;
-
error_message: string | null;
-
LEFT JOIN users u ON t.user_id = u.id
-
ORDER BY t.created_at DESC`,
export function deleteTranscription(transcriptionId: string): void {
···
subscription_id: string | null;
-
export function getAllUsersWithStats(): UserWithStats[] {
-
.query<UserWithStats, []>(
-
COUNT(DISTINCT t.id) as transcription_count,
-
s.status as subscription_status,
-
s.id as subscription_id
-
LEFT JOIN transcriptions t ON u.id = t.user_id
-
LEFT JOIN subscriptions s ON u.id = s.user_id AND s.status IN ('active', 'trialing', 'past_due')
-
ORDER BY u.created_at DESC`,
···
+
export function getAllTranscriptions(
+
user_name: string | null;
+
original_filename: string;
+
error_message: string | null;
+
nextCursor: string | null;
+
type TranscriptionRow = {
+
user_name: string | null;
+
original_filename: string;
+
error_message: string | null;
+
let transcriptions: TranscriptionRow[];
+
const { decodeCursor } = require("./cursor");
+
const parts = decodeCursor(cursor);
+
if (parts.length !== 2) {
+
throw new Error("Invalid cursor format");
+
const cursorTime = Number.parseInt(parts[0] || "", 10);
+
const id = parts[1] || "";
+
if (Number.isNaN(cursorTime) || !id) {
+
throw new Error("Invalid cursor format");
+
.query<TranscriptionRow, [number, number, string, number]>(
+
LEFT JOIN users u ON t.user_id = u.id
+
WHERE t.created_at < ? OR (t.created_at = ? AND t.id < ?)
+
ORDER BY t.created_at DESC, t.id DESC
+
.all(cursorTime, cursorTime, id, limit + 1);
+
.query<TranscriptionRow, [number]>(
+
LEFT JOIN users u ON t.user_id = u.id
+
ORDER BY t.created_at DESC, t.id DESC
+
const hasMore = transcriptions.length > limit;
+
let nextCursor: string | null = null;
+
if (hasMore && transcriptions.length > 0) {
+
const { encodeCursor } = require("./cursor");
+
const last = transcriptions[transcriptions.length - 1];
+
nextCursor = encodeCursor([last.created_at.toString(), last.id]);
export function deleteTranscription(transcriptionId: string): void {
···
subscription_id: string | null;
+
export function getAllUsersWithStats(
+
nextCursor: string | null;
+
let users: UserWithStats[];
+
const { decodeCursor } = require("./cursor");
+
const parts = decodeCursor(cursor);
+
if (parts.length !== 2) {
+
throw new Error("Invalid cursor format");
+
const cursorTime = Number.parseInt(parts[0] || "", 10);
+
const cursorId = Number.parseInt(parts[1] || "", 10);
+
if (Number.isNaN(cursorTime) || Number.isNaN(cursorId)) {
+
throw new Error("Invalid cursor format");
+
.query<UserWithStats, [number, number, number, number]>(
+
COUNT(DISTINCT t.id) as transcription_count,
+
s.status as subscription_status,
+
s.id as subscription_id
+
LEFT JOIN transcriptions t ON u.id = t.user_id
+
LEFT JOIN subscriptions s ON u.id = s.user_id AND s.status IN ('active', 'trialing', 'past_due')
+
WHERE u.created_at < ? OR (u.created_at = ? AND u.id < ?)
+
ORDER BY u.created_at DESC, u.id DESC
+
.all(cursorTime, cursorTime, cursorId, limit + 1);
+
.query<UserWithStats, [number]>(
+
COUNT(DISTINCT t.id) as transcription_count,
+
s.status as subscription_status,
+
s.id as subscription_id
+
LEFT JOIN transcriptions t ON u.id = t.user_id
+
LEFT JOIN subscriptions s ON u.id = s.user_id AND s.status IN ('active', 'trialing', 'past_due')
+
ORDER BY u.created_at DESC, u.id DESC
+
const hasMore = users.length > limit;
+
let nextCursor: string | null = null;
+
if (hasMore && users.length > 0) {
+
const { encodeCursor } = require("./cursor");
+
const last = users[users.length - 1];
+
nextCursor = encodeCursor([last.created_at.toString(), last.id.toString()]);