Skip to content

Commit 60b3bcc

Browse files
committed
refactor(data-operation): simplify country data operation
- Remove specialized filtering logic for 'usage' and 'name' in country data operation - Delegate all country read operations to DataRepository<Country> - Remove unused import of CountryService
1 parent c8c729e commit 60b3bcc

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

lib/src/registry/data_operation_registry.dart

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:core/core.dart';
22
import 'package:dart_frog/dart_frog.dart';
33
import 'package:data_repository/data_repository.dart';
44
import 'package:flutter_news_app_api_server_full_source_code/src/middlewares/ownership_check_middleware.dart';
5-
import 'package:flutter_news_app_api_server_full_source_code/src/services/country_service.dart';
65
import 'package:flutter_news_app_api_server_full_source_code/src/services/dashboard_summary_service.dart';
76

87
// --- Typedefs for Data Operations ---
@@ -129,32 +128,12 @@ class DataOperationRegistry {
129128
sort: s,
130129
pagination: p,
131130
),
132-
'country': (c, uid, f, s, p) async {
133-
final usage = f?['usage'] as String?;
134-
final name = f?['name'] as String?;
135-
136-
// If either 'usage' or 'name' filter is present, delegate to CountryService.
137-
// Sorting and pagination are handled by CountryService for these specialized queries.
138-
if ((usage != null && usage.isNotEmpty) ||
139-
(name != null && name.isNotEmpty)) {
140-
final countryService = c.read<CountryService>();
141-
final countries = await countryService.getCountries(f);
142-
return PaginatedResponse<Country>(
143-
items: countries,
144-
cursor: null, // No cursor for this type of filtered list
145-
hasMore: false, // No more items as it's a complete filtered set
146-
);
147-
} else {
148-
// For standard requests without specialized filters, use the repository
149-
// which supports pagination/sorting.
150-
return c.read<DataRepository<Country>>().readAll(
151-
userId: uid,
152-
filter: f,
153-
sort: s,
154-
pagination: p,
155-
);
156-
}
157-
},
131+
'country': (c, uid, f, s, p) => c.read<DataRepository<Country>>().readAll(
132+
userId: uid,
133+
filter: f,
134+
sort: s,
135+
pagination: p,
136+
),
158137
'language': (c, uid, f, s, p) => c
159138
.read<DataRepository<Language>>()
160139
.readAll(userId: uid, filter: f, sort: s, pagination: p),

0 commit comments

Comments
 (0)