Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/src/config/app_dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:flutter_news_app_api_server_full_source_code/src/config/environm
import 'package:flutter_news_app_api_server_full_source_code/src/rbac/permission_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/auth_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/auth_token_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/country_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/dashboard_summary_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/database_seeding_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/default_user_preference_limit_service.dart';
Expand Down Expand Up @@ -62,7 +61,6 @@ class AppDependencies {
late final EmailRepository emailRepository;

// Services
late final CountryService countryService;
late final TokenBlacklistService tokenBlacklistService;
late final AuthTokenService authTokenService;
late final VerificationCodeStorageService verificationCodeStorageService;
Expand Down Expand Up @@ -239,12 +237,6 @@ class AppDependencies {
connectionManager: _mongoDbConnectionManager,
log: Logger('MongoDbRateLimitService'),
);
countryService = CountryService(
countryRepository: countryRepository,
headlineRepository: headlineRepository,
sourceRepository: sourceRepository,
logger: Logger('CountryService'),
);

_isInitialized = true;
_log.info('Application dependencies initialized successfully.');
Expand Down
33 changes: 6 additions & 27 deletions lib/src/registry/data_operation_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:core/core.dart';
import 'package:dart_frog/dart_frog.dart';
import 'package:data_repository/data_repository.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/middlewares/ownership_check_middleware.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/country_service.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/dashboard_summary_service.dart';

// --- Typedefs for Data Operations ---
Expand Down Expand Up @@ -129,32 +128,12 @@ class DataOperationRegistry {
sort: s,
pagination: p,
),
'country': (c, uid, f, s, p) async {
final usage = f?['usage'] as String?;
final name = f?['name'] as String?;

// If either 'usage' or 'name' filter is present, delegate to CountryService.
// Sorting and pagination are handled by CountryService for these specialized queries.
if ((usage != null && usage.isNotEmpty) ||
(name != null && name.isNotEmpty)) {
final countryService = c.read<CountryService>();
final countries = await countryService.getCountries(f);
return PaginatedResponse<Country>(
items: countries,
cursor: null, // No cursor for this type of filtered list
hasMore: false, // No more items as it's a complete filtered set
);
} else {
// For standard requests without specialized filters, use the repository
// which supports pagination/sorting.
return c.read<DataRepository<Country>>().readAll(
userId: uid,
filter: f,
sort: s,
pagination: p,
);
}
},
'country': (c, uid, f, s, p) => c.read<DataRepository<Country>>().readAll(
userId: uid,
filter: f,
sort: s,
pagination: p,
),
'language': (c, uid, f, s, p) => c
.read<DataRepository<Language>>()
.readAll(userId: uid, filter: f, sort: s, pagination: p),
Expand Down
Loading
Loading