getChunksForTopic method

Future<List<ContentChunkModel>> getChunksForTopic(
  1. String topicId
)

Implementation

Future<List<ContentChunkModel>> getChunksForTopic(String topicId) async {
  // Explicit column list excludes the vector(384) `embedding` column
  // (~4KB/row), which ContentChunkModel discards — a bare select() shipped
  // it on every lesson/content open (audit H8). The embedding-aware sync
  // path uses getChunksWithEmbeddings instead.
  final response = await _client
      .from('content_chunks')
      .select(
        'id, topic_id, book_id, chunk_index, content, page_number, '
        'token_count, metadata',
      )
      .eq('topic_id', topicId)
      .order('chunk_index', ascending: true);
  return (response as List<dynamic>)
      .map((row) => ContentChunkModel.fromJson(row as Map<String, dynamic>))
      .toList();
}