-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Refactor Robotoff methods #723
fix: Refactor Robotoff methods #723
Conversation
Deprecated and routed the robotoff apis to a new file for decluttering
Removed User parameter as mentioned in the requirements along with getIngredientSpellingCorrection method. Could be a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @atharv028!
Please have a look at my comments.
lib/openfoodfacts.dart
Outdated
@@ -107,4 +107,5 @@ export 'src/utils/tag_type.dart'; | |||
export 'src/utils/unit_helper.dart'; | |||
export 'src/utils/uri_helper.dart'; | |||
export 'src/utils/uri_reader.dart'; | |||
export 'src/robotoff_api_client.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer robot_off_api_client.dart
but that's not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/src/open_food_api_client.dart
Outdated
@@ -788,226 +789,66 @@ class OpenFoodAPIClient { | |||
} | |||
} | |||
|
|||
//TODO(x): Add comments for robotoff | |||
//TODO : Remove Robotoff APIs From here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That TODO
is not very useful, please get rid of ot.
Instead, please add a specific TODO
comment for each related method, something like that:
// TODO: deprecated from 2022-12-01; remove when old enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TODO on each method in open_food_api_client.dart
which routes to RobotOffAPIClient
lib/src/open_food_api_client.dart
Outdated
@@ -2,6 +2,7 @@ import 'dart:async'; | |||
import 'dart:convert'; | |||
|
|||
import 'package:http/http.dart'; | |||
import 'package:openfoodfacts/openfoodfacts.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use src/
imports instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
lib/src/robotoff_api_client.dart
Outdated
import 'package:http/http.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
|
||
class RobotoffApiClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with OpenFoodAPIClient
, RobotOffAPIClient
would make more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the class name to RobotOffAPIClient
lib/src/robotoff_api_client.dart
Outdated
import 'dart:convert'; | ||
|
||
import 'package:http/http.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use src/
imports instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
lib/src/robotoff_api_client.dart
Outdated
class RobotoffApiClient { | ||
RobotoffApiClient._(); | ||
|
||
//TODO(x): Add comments for robotoff APIs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please get rid of that comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted the comment
lib/src/robotoff_api_client.dart
Outdated
|
||
static Future<RobotoffQuestionResult> getProductQuestions( | ||
String barcode, | ||
String lang, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be OpenFoodFactsLanguage language
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the parameter type to OpenFoodFactsLanguage
and name to language
lib/src/robotoff_api_client.dart
Outdated
} | ||
|
||
static Future<RobotoffQuestionResult> getRandomQuestions( | ||
OpenFoodFactsLanguage? lang, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be language
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Fixed import directives, also made the naming conventions for classes consistent. Added TODOs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @atharv028!
What
Screenshot
Fixes bug(s)
Part of