Skip to content

Commit 60fb335

Browse files
committed
fix(country): improve search specificity and cache initialization
- Modify regex in search query to match only the beginning of country names - Refactor constructor formatting for better readability - Initialize _cleanupTimer in constructor body for proper functionality
1 parent 259f028 commit 60fb335

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/src/services/country_query_service.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class CountryQueryService {
2020
required DataRepository<Country> countryRepository,
2121
required Logger log,
2222
Duration cacheDuration = const Duration(minutes: 15),
23-
}) : _countryRepository = countryRepository,
24-
_log = log,
25-
_cacheDuration = cacheDuration {
23+
}) : _countryRepository = countryRepository,
24+
_log = log,
25+
_cacheDuration = cacheDuration {
2626
_cleanupTimer = Timer.periodic(const Duration(minutes: 5), (_) {
2727
_cleanupCache();
2828
});
@@ -35,7 +35,7 @@ class CountryQueryService {
3535
final Duration _cacheDuration;
3636

3737
final Map<String, ({PaginatedResponse<Country> data, DateTime expiry})>
38-
_cache = {};
38+
_cache = {};
3939
Timer? _cleanupTimer;
4040
bool _isDisposed = false;
4141

@@ -132,7 +132,7 @@ class CountryQueryService {
132132
if (qValue is String && qValue.isNotEmpty) {
133133
compoundMatchStages.add({
134134
'name': {
135-
r'$regex': qValue,
135+
r'$regex': '^$qValue',
136136
r'$options': 'i', // Case-insensitive
137137
},
138138
});

0 commit comments

Comments
 (0)