Skip to content

Commit

Permalink
Merge branch 'master' into feat/genericName
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurtanuki authored Nov 16, 2023
2 parents 8740caf + a99f567 commit 7beb6a0
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 44 deletions.
3 changes: 1 addition & 2 deletions lib/src/model/parameter/allergens_parameter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ class AllergensParameter extends BoolMapParameter<AllergensTag> {
String getTag(final AllergensTag key, final bool value) =>
value ? key.offTag : '-${key.offTag}';

const AllergensParameter({required final Map<AllergensTag, bool> map})
: super(map: map);
const AllergensParameter({required super.map});
}
3 changes: 1 addition & 2 deletions lib/src/model/parameter/states_tags_parameter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ class StatesTagsParameter extends BoolMapParameter<ProductState> {
String getTag(final ProductState key, final bool value) =>
value ? key.completedTag : key.toBeCompletedTag;

StatesTagsParameter({required final Map<ProductState, bool> map})
: super(map: map);
const StatesTagsParameter({required super.map});
}
4 changes: 4 additions & 0 deletions lib/src/model/search_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class SearchResult extends JsonObject {
@JsonKey(name: 'count', fromJson: JsonObject.parseInt)
final int? count;

@JsonKey(name: 'page_count', fromJson: JsonObject.parseInt)
final int? pageCount;

@JsonKey(name: 'skip', fromJson: JsonObject.parseInt)
final int? skip;

Expand All @@ -25,6 +28,7 @@ class SearchResult extends JsonObject {
this.page,
this.pageSize,
this.count,
this.pageCount,
this.skip,
this.products,
});
Expand Down
2 changes: 2 additions & 0 deletions lib/src/model/search_result.g.dart

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

15 changes: 3 additions & 12 deletions lib/src/model/sign_up_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,10 @@ class SignUpStatus extends Status {
final Iterable<SignUpStatusError>? statusErrors;

SignUpStatus._({
dynamic status,
String? statusVerbose,
String? body,
String? error,
int? imageId,
super.status,
super.error,
this.statusErrors,
}) : super(
status: status,
statusVerbose: statusVerbose,
body: body,
error: error,
imageId: imageId,
);
});

factory SignUpStatus(Status status) {
if (status.body == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ class AvailablePreferenceImportances {
/// Returns the importance from its id.
PreferenceImportance? getPreferenceImportance(final String importanceId) =>
_preferenceImportances?[importanceId] ??
_preferenceImportances?[PreferenceImportance.INDEX_NOT_IMPORTANT];
_preferenceImportances?[PreferenceImportance.ID_NOT_IMPORTANT];
}
18 changes: 5 additions & 13 deletions lib/src/utils/product_query_configurations.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'package:http/http.dart';
import 'abstract_query_configuration.dart';
import 'country_helper.dart';
import 'http_helper.dart';
import 'language_helper.dart';
import 'product_fields.dart';
import 'uri_helper.dart';
import '../model/user.dart';

Expand Down Expand Up @@ -38,16 +35,11 @@ class ProductQueryConfiguration extends AbstractQueryConfiguration {
ProductQueryConfiguration(
this.barcode, {
required this.version,
final OpenFoodFactsLanguage? language,
final List<OpenFoodFactsLanguage> languages = const [],
final OpenFoodFactsCountry? country,
final List<ProductField>? fields,
}) : super(
language: language,
languages: languages,
country: country,
fields: fields,
);
super.language,
super.languages,
super.country,
super.fields,
});

/// If the provided [ProductQueryVersion] matches the API V3 requirements
bool matchesV3() => version.matchesV3();
Expand Down
14 changes: 4 additions & 10 deletions lib/src/utils/product_search_query_configuration.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'abstract_query_configuration.dart';
import 'country_helper.dart';
import 'language_helper.dart';
import 'product_fields.dart';
import 'product_query_configurations.dart';
import '../interface/parameter.dart';
Expand All @@ -10,17 +8,13 @@ class ProductSearchQueryConfiguration extends AbstractQueryConfiguration {
/// See [AbstractQueryConfiguration.languages] for
/// parameter's description.
ProductSearchQueryConfiguration({
final OpenFoodFactsLanguage? language,
final List<OpenFoodFactsLanguage> languages = const [],
final OpenFoodFactsCountry? country,
final List<ProductField>? fields,
super.language,
super.languages,
super.country,
super.fields,
required List<Parameter> parametersList,
required this.version,
}) : super(
language: language,
languages: languages,
country: country,
fields: fields,
additionalParameters: parametersList,
);

Expand Down
11 changes: 10 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ dev_dependencies:
analyzer: ^6.0.0
build_runner: ^2.4.6
json_serializable: ^6.7.1
lints: ^2.0.1
lints: ^3.0.0
test: ^1.21.4
coverage: ^1.6.2

funding:
- "https://donate.openfoodfacts.org/"
- "https://opencollective.com/openfoodfacts-server"

topics:
- nutriscore
- ecoscore
- allergies
- nutrition
- carbonfootprint
- food
- ingredients
4 changes: 2 additions & 2 deletions test/api_get_user_products_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ void main() {
expect(result.page, 1, reason: reason); // default
expect(result.pageSize, pageSize, reason: reason);
expect(result.products, isNotNull, reason: reason);
expect(result.products!.length, result.count, reason: reason);
expect(result.products!.length, result.pageCount, reason: reason);
if (additionalCheck != null) {
for (final Product product in result.products!) {
additionalCheck(product);
}
}
return result.count!;
return result.pageCount!;
}

Future<int> getCountForAllLanguages(
Expand Down
2 changes: 1 addition & 1 deletion test/api_search_products_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ void main() {
expect(result.products!.length, 24);
expect(result.products![0].runtimeType, Product);
expect(result.count, greaterThan(1500));
});
}, skip: 'Temporarily not working (server issue)');

test('many many products', () async {
final List<String> manyBarcodes = <String>[];
Expand Down

0 comments on commit 7beb6a0

Please sign in to comment.