getMasteryOverrides method
- String? topicId,
Fetch mastery overrides for the current user, optionally filtered by topic.
Implementation
Future<List<MasteryOverrideModel>> getMasteryOverrides({
String? topicId,
}) async {
final userId = _client.auth.currentUser?.id;
if (userId == null) return [];
var query = _client
.from('mastery_overrides')
.select()
.eq('user_id', userId);
if (topicId != null) {
query = query.eq('topic_id', topicId);
}
final response = await query.order('created_at', ascending: false);
return (response as List<dynamic>)
.map(
(row) => MasteryOverrideModel.fromJson(row as Map<String, dynamic>),
)
.toList();
}