@@ -17,10 +17,10 @@ class CountryService {
1717 required DataRepository <Headline > headlineRepository,
1818 required DataRepository <Source > sourceRepository,
1919 Logger ? logger,
20- }) : _countryRepository = countryRepository,
21- _headlineRepository = headlineRepository,
22- _sourceRepository = sourceRepository,
23- _log = logger ?? Logger ('CountryService' );
20+ }) : _countryRepository = countryRepository,
21+ _headlineRepository = headlineRepository,
22+ _sourceRepository = sourceRepository,
23+ _log = logger ?? Logger ('CountryService' );
2424
2525 final DataRepository <Country > _countryRepository;
2626 final DataRepository <Headline > _headlineRepository;
@@ -81,9 +81,7 @@ class CountryService {
8181 return response.items;
8282 } catch (e, s) {
8383 _log.severe ('Failed to fetch all countries.' , e, s);
84- throw OperationFailedException (
85- 'Failed to retrieve all countries: $e ' ,
86- );
84+ throw OperationFailedException ('Failed to retrieve all countries: $e ' );
8785 }
8886 }
8987
@@ -113,25 +111,28 @@ class CountryService {
113111 'country' : {r'$first' : r'$eventCountry' },
114112 },
115113 },
116- {r'$replaceRoot' : {'newRoot' : r'$country' }},
114+ {
115+ r'$replaceRoot' : {'newRoot' : r'$country' },
116+ },
117117 ];
118118
119- final distinctCountriesJson =
120- await _headlineRepository.aggregate (pipeline: pipeline);
119+ final distinctCountriesJson = await _headlineRepository.aggregate (
120+ pipeline: pipeline,
121+ );
121122
122123 final distinctCountries = distinctCountriesJson
123124 .map (Country .fromJson)
124125 .toList ();
125126
126127 _cachedEventCountries = distinctCountries;
127- _log.info ('Successfully fetched and cached ${distinctCountries .length } '
128- 'event countries.' );
128+ _log.info (
129+ 'Successfully fetched and cached ${distinctCountries .length } '
130+ 'event countries.' ,
131+ );
129132 return distinctCountries;
130133 } catch (e, s) {
131134 _log.severe ('Failed to fetch event countries via aggregation.' , e, s);
132- throw OperationFailedException (
133- 'Failed to retrieve event countries: $e ' ,
134- );
135+ throw OperationFailedException ('Failed to retrieve event countries: $e ' );
135136 }
136137 }
137138
@@ -161,22 +162,31 @@ class CountryService {
161162 'country' : {r'$first' : r'$headquarters' },
162163 },
163164 },
164- {r'$replaceRoot' : {'newRoot' : r'$country' }},
165+ {
166+ r'$replaceRoot' : {'newRoot' : r'$country' },
167+ },
165168 ];
166169
167- final distinctCountriesJson =
168- await _sourceRepository.aggregate (pipeline: pipeline);
170+ final distinctCountriesJson = await _sourceRepository.aggregate (
171+ pipeline: pipeline,
172+ );
169173
170174 final distinctCountries = distinctCountriesJson
171175 .map (Country .fromJson)
172176 .toList ();
173177
174178 _cachedHeadquarterCountries = distinctCountries;
175- _log.info ('Successfully fetched and cached ${distinctCountries .length } '
176- 'headquarter countries.' );
179+ _log.info (
180+ 'Successfully fetched and cached ${distinctCountries .length } '
181+ 'headquarter countries.' ,
182+ );
177183 return distinctCountries;
178184 } catch (e, s) {
179- _log.severe ('Failed to fetch headquarter countries via aggregation.' , e, s);
185+ _log.severe (
186+ 'Failed to fetch headquarter countries via aggregation.' ,
187+ e,
188+ s,
189+ );
180190 throw OperationFailedException (
181191 'Failed to retrieve headquarter countries: $e ' ,
182192 );
0 commit comments