getAllProgressForDomain method

Future<List<UserTopicProgressModel>> getAllProgressForDomain(
  1. String domainId
)

Fetch all progress rows for topics in a given domain.

Implementation

Future<List<UserTopicProgressModel>> getAllProgressForDomain(
  String domainId,
) async {
  final userId = _client.auth.currentUser?.id;
  if (userId == null) return [];

  final response = await _client
      .from('user_topic_progress')
      .select('*, topics!inner(domain_id)')
      .eq('user_id', userId)
      .eq('topics.domain_id', domainId);
  return (response as List<dynamic>)
      .map(
        (row) => UserTopicProgressModel.fromJson(row as Map<String, dynamic>),
      )
      .toList();
}