Skip to content

Commit

Permalink
feat: 933 - added osm location fields (countryCode, osmKey, osmValue) (
Browse files Browse the repository at this point in the history
…#934)

* feat: 933 - added osm location fields (countryCode, osmKey, osmValue)

Impacted files:
* `api_get_product_test.dart`: unrelated minor test fix
* `api_get_robotoff_test.dart`: unrelated minor test fix
* `api_matched_product_v1_test.dart`: unrelated minor test fix
* `location.dart`: added fields `countryCode`, `osmKey` and `osmValue`
* `location.g.dart`: generated

* Minor typo fix
  • Loading branch information
monsieurtanuki authored May 22, 2024
1 parent 6f417be commit f653f6a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
9 changes: 9 additions & 0 deletions lib/src/prices/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class Location extends JsonObject {
@JsonKey(name: 'osm_address_country')
String? country;

@JsonKey(name: 'osm_address_country_code')
String? countryCode;

@JsonKey(name: 'osm_tag_key')
String? osmKey;

@JsonKey(name: 'osm_tag_value')
String? osmValue;

@JsonKey(name: 'osm_lat')
double? latitude;

Expand Down
6 changes: 6 additions & 0 deletions lib/src/prices/location.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/api_get_product_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,13 @@ void main() {
expect(nutritionalQuality.first.title, 'Nutri-Score D');
expect(nutritionalQuality.first.name, 'Nutri-Score');
expect(nutritionalQuality.first.match,
greaterThan(29)); // 20230602: 29.4444444444444
greaterThan(27)); // 20240522: 27.3333333333333
expect(nutritionalQuality.first.status, 'known');
expect(nutritionalQuality[1].id, 'low_salt');
expect(nutritionalQuality[2].id, 'low_fat');
expect(nutritionalQuality[3].id, 'low_sugars');
expect(nutritionalQuality[4].id, 'low_saturated_fat');
expect(nutritionalQuality.first.panelId, 'nutriscore');
expect(nutritionalQuality.first.panelId, 'nutriscore_2023');

group = result.product!.attributeGroups!
.singleWhere((element) => element.id == 'processing');
Expand Down Expand Up @@ -857,7 +857,7 @@ void main() {
'environment_card',
'health_card',
'ingredients',
'nutriscore',
'nutriscore_2023',
'root',
};
final ProductResultV3 productResult =
Expand Down
4 changes: 3 additions & 1 deletion test/api_get_robotoff_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ void main() {
}
// highly probable
expect(germanBarcodes2, isNot(frenchBarcodes1));
}, timeout: Timeout(Duration(seconds: 90)));
},
skip: 'a bit prone to 502 Bad Gateway',
timeout: Timeout(Duration(seconds: 90)));

test('get 2 random questions with no specific type', () async {
final RobotoffQuestionResult result =
Expand Down
8 changes: 5 additions & 3 deletions test/api_matched_product_v1_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ void main() {
MatchedProduct matchedProduct;

matchedProduct = MatchedProduct(result.product!, manager);
expect(matchedProduct.score, greaterThan(151));
expect(matchedProduct.status, MatchedProductStatus.YES);
expect(matchedProduct.score,
greaterThan(50)); // 20240522: was 59.2727272727272
expect(matchedProduct.status, MatchedProductStatus.NO);

await manager.setImportance(attributeId1, importanceId2);
expect(
Expand All @@ -88,7 +89,8 @@ void main() {
expect(refreshCounter, 4);

matchedProduct = MatchedProduct(result.product!, manager);
expect(matchedProduct.score, greaterThan(37.5));
expect(matchedProduct.score,
greaterThan(14)); // 20240522: was 14.8181818181818
expect(matchedProduct.status, MatchedProductStatus.NO);

await manager.clearImportances(); // no attribute parameters at all
Expand Down

0 comments on commit f653f6a

Please sign in to comment.