백품타 랭킹에 전체랭킹/학년랭킹 필터 추가
grade 쿼리파라미터를 생략하면 전체 학년 통합 랭킹을 주도록 백엔드를 바꾸고, 랭킹 화면에 "N학년"/"전체랭킹" 필 필터를 추가해 시간대 필터(오늘/이번주/전체)와 별도로 고를 수 있게 했다. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,10 +11,12 @@ class StudyRankingController extends ChangeNotifier {
|
||||
|
||||
bool _isLoading = true;
|
||||
String _period = 'today'; // today / week / total
|
||||
String _scope = 'grade'; // grade / all
|
||||
List<dynamic> _ranking = [];
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
String get period => _period;
|
||||
String get scope => _scope;
|
||||
List<dynamic> get ranking => _ranking;
|
||||
|
||||
Future<void> init() => fetchRanking();
|
||||
@@ -25,12 +27,19 @@ class StudyRankingController extends ChangeNotifier {
|
||||
await fetchRanking();
|
||||
}
|
||||
|
||||
Future<void> setScope(String scope) async {
|
||||
if (_scope == scope) return;
|
||||
_scope = scope;
|
||||
await fetchRanking();
|
||||
}
|
||||
|
||||
Future<void> fetchRanking() async {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
final gradeParam = _scope == 'grade' ? '&grade=$grade' : '';
|
||||
final response = await http.get(
|
||||
Uri.parse('$baseUrl/api/study/ranking?grade=$grade&period=$_period'),
|
||||
Uri.parse('$baseUrl/api/study/ranking?period=$_period$gradeParam'),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(utf8.decode(response.bodyBytes));
|
||||
|
||||
Reference in New Issue
Block a user