Increase page size for languages, no need to use pagination for this

Categories and muscles will probably never get so big, but it doesn't do any
harm doing it as well.
This commit is contained in:
Roland Geider
2026-01-12 21:56:59 +01:00
parent c989733e5d
commit cbdc4a0c56
3 changed files with 79 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (C) 2020, 2021 wger Team
* Copyright (c) 2020 - 2026 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -234,7 +234,12 @@ class ExercisesProvider with ChangeNotifier {
Future<void> fetchAndSetCategoriesFromApi() async {
_logger.info('Loading exercise categories from API');
final categories = await baseProvider.fetchPaginated(baseProvider.makeUrl(categoriesUrlPath));
final categories = await baseProvider.fetchPaginated(
baseProvider.makeUrl(
categoriesUrlPath,
query: {'limit': API_MAX_PAGE_SIZE},
),
);
for (final category in categories) {
_categories.add(ExerciseCategory.fromJson(category));
}
@@ -242,7 +247,12 @@ class ExercisesProvider with ChangeNotifier {
Future<void> fetchAndSetMusclesFromApi() async {
_logger.info('Loading muscles from API');
final muscles = await baseProvider.fetchPaginated(baseProvider.makeUrl(musclesUrlPath));
final muscles = await baseProvider.fetchPaginated(
baseProvider.makeUrl(
musclesUrlPath,
query: {'limit': API_MAX_PAGE_SIZE},
),
);
for (final muscle in muscles) {
_muscles.add(Muscle.fromJson(muscle));
@@ -251,7 +261,12 @@ class ExercisesProvider with ChangeNotifier {
Future<void> fetchAndSetEquipmentsFromApi() async {
_logger.info('Loading equipment from API');
final equipments = await baseProvider.fetchPaginated(baseProvider.makeUrl(equipmentUrlPath));
final equipments = await baseProvider.fetchPaginated(
baseProvider.makeUrl(
equipmentUrlPath,
query: {'limit': API_MAX_PAGE_SIZE},
),
);
for (final equipment in equipments) {
_equipment.add(Equipment.fromJson(equipment));
@@ -261,7 +276,12 @@ class ExercisesProvider with ChangeNotifier {
Future<void> fetchAndSetLanguagesFromApi() async {
_logger.info('Loading languages from API');
final languageData = await baseProvider.fetchPaginated(baseProvider.makeUrl(languageUrlPath));
final languageData = await baseProvider.fetchPaginated(
baseProvider.makeUrl(
languageUrlPath,
query: {'limit': API_MAX_PAGE_SIZE},
),
);
for (final language in languageData) {
_languages.add(Language.fromJson(language));

View File

@@ -1,3 +1,21 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (c) 2026 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:convert';
import 'package:drift/native.dart';
@@ -100,19 +118,25 @@ void main() {
SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty();
// Mock categories
when(mockBaseProvider.makeUrl(categoryUrl)).thenReturn(tCategoryEntriesUri);
when(
mockBaseProvider.makeUrl(categoryUrl, query: anyNamed('query')),
).thenReturn(tCategoryEntriesUri);
when(
mockBaseProvider.fetchPaginated(tCategoryEntriesUri),
).thenAnswer((_) => Future.value(tCategoryMap['results']));
// Mock muscles
when(mockBaseProvider.makeUrl(muscleUrl)).thenReturn(tMuscleEntriesUri);
when(
mockBaseProvider.makeUrl(muscleUrl, query: anyNamed('query')),
).thenReturn(tMuscleEntriesUri);
when(
mockBaseProvider.fetchPaginated(tMuscleEntriesUri),
).thenAnswer((_) => Future.value(tMuscleMap['results']));
// Mock equipment
when(mockBaseProvider.makeUrl(equipmentUrl)).thenReturn(tEquipmentEntriesUri);
when(
mockBaseProvider.makeUrl(equipmentUrl, query: anyNamed('query')),
).thenReturn(tEquipmentEntriesUri);
when(
mockBaseProvider.fetchPaginated(tEquipmentEntriesUri),
).thenAnswer((_) => Future.value(tEquipmentMap['results']));

View File

@@ -1,3 +1,21 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (c) 2026 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:convert';
import 'package:drift/drift.dart';
@@ -105,19 +123,25 @@ void main() {
driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;
// Mock categories
when(mockBaseProvider.makeUrl(categoryUrl)).thenReturn(tCategoryEntriesUri);
when(
mockBaseProvider.makeUrl(categoryUrl, query: anyNamed('query')),
).thenReturn(tCategoryEntriesUri);
when(
mockBaseProvider.fetchPaginated(tCategoryEntriesUri),
).thenAnswer((_) => Future.value(tCategoryMap['results']));
// Mock muscles
when(mockBaseProvider.makeUrl(muscleUrl)).thenReturn(tMuscleEntriesUri);
when(
mockBaseProvider.makeUrl(muscleUrl, query: anyNamed('query')),
).thenReturn(tMuscleEntriesUri);
when(
mockBaseProvider.fetchPaginated(tMuscleEntriesUri),
).thenAnswer((_) => Future.value(tMuscleMap['results']));
// Mock equipment
when(mockBaseProvider.makeUrl(equipmentUrl)).thenReturn(tEquipmentEntriesUri);
when(
mockBaseProvider.makeUrl(equipmentUrl, query: anyNamed('query')),
).thenReturn(tEquipmentEntriesUri);
when(
mockBaseProvider.fetchPaginated(tEquipmentEntriesUri),
).thenAnswer((_) => Future.value(tEquipmentMap['results']));