-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
feat: 4020 - instant answers for hunger games #4099
feat: 4020 - instant answers for hunger games #4099
Conversation
New files: * `background_task_hunger_games.dart`: Background task about answering a hunger games question. * `random_questions_query.dart`: Robotoff questions helper, for random product questions. Deleted file: * `product_question_page.dart` Impacted files: * `abstract_background_task.dart`: added "hunger games" * `background_task_crop.dart`: minor refactoring * `background_task_details.dart`: minor refactoring * `background_task_image.dart`: minor refactoring * `background_task_manager.dart`: simplified the code, as we now always work on tasks with different stamps * `background_task_refresh.dart`: minor refactoring * `background_task_unselect.dart`: minor refactoring * `new_product_page.dart`: minor refactoring * `offline_data_page.dart`: minor refactoring * `operation_type.dart`: added a type for "hunger games" background task * `product_list_import_export.dart`: minor refactoring * `product_list_page.dart`: minor refactoring * `product_questions_query.dart`: pre-loads the product if relevant * `product_questions_widget.dart`: minor refactoring * `product_refresher.dart`: new standard configuration for product lists; new silent download of product lists; minor refactoring * `question_card.dart`: now downloading the product only if not in the local database * `question_page.dart`: now saving the answer with background tasks; refactored * `questions_query.dart`: refactored as abstract, with code moved to new file `random_questions_query.dart` * `robotoff_insight_helper.dart`: minor refactoring
Codecov Report
@@ Coverage Diff @@
## develop #4099 +/- ##
===========================================
- Coverage 10.88% 10.84% -0.05%
===========================================
Files 271 273 +2
Lines 13466 13517 +51
===========================================
Hits 1466 1466
- Misses 12000 12051 +51
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Just a few feedbacks, but in general LGTM
@@ -198,7 +198,7 @@ class BackgroundTaskCrop extends BackgroundTaskUpload { | |||
final LocalDatabase localDatabase, | |||
final bool success, | |||
) async { | |||
localDatabase.upToDate.terminate(uniqueId); | |||
await super.postExecute(localDatabase, success); |
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.
If you say await here, wouldn't be better to also have an async call for the delete just below?
(Just a suggestion)
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.
If you say await here, wouldn't be better to also have an async call for the delete just below? (Just a suggestion)
That would probably work the same, wouldn't it? Especially here, where we delete just one file in a background task.
return result; | ||
} | ||
} catch (e) { | ||
// |
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 think there's something missing 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.
I think there's something missing here :)
Actually, nothing's missing here. We just try to fromJson a map, and very often it's going to fail because some expected fields won't be there - if it is a background task from a different class. All other background tasks work on the same principle. cf. AbstractBackgroundTask.fromJson
.
That said, I agree that it's not very elegant.
Feel free to create an issue to refactor that fromJson
.
insightAnnotation.value, | ||
uniqueId, | ||
); | ||
await task.addToManager(localDatabase, widget: widget); |
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.
why not return
here, instead of the await
?
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.
why not
return
here, instead of theawait
?
As far as I know that would be exactly the same, wouldn't it?
Future<void> upload() async { | ||
final InsightAnnotation? annotation = | ||
_getInsightAnnotation(insightAnnotation); | ||
if (annotation == null) { |
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.
Wouldn't be a good idea to log this kind of error to measure the volume of potentials errors?
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.
It's very very unlikely to happen, as we previously populated the task field as InsightAnnotation
.
Feel free to create an issue if really needed.
Thank you @g123k for your review! Feel free to approve this PR if my answers made sense to you. |
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.
After a quick discussion with @g123k, let's merge as it
What
Fixes bug(s)
Files
New files:
background_task_hunger_games.dart
: Background task about answering a hunger games question.random_questions_query.dart
: Robotoff questions helper, for random product questions.Deleted file:
product_question_page.dart
Impacted files:
abstract_background_task.dart
: added "hunger games"background_task_crop.dart
: minor refactoringbackground_task_details.dart
: minor refactoringbackground_task_image.dart
: minor refactoringbackground_task_manager.dart
: simplified the code, as we now always work on tasks with different stampsbackground_task_refresh.dart
: minor refactoringbackground_task_unselect.dart
: minor refactoringnew_product_page.dart
: minor refactoringoffline_data_page.dart
: minor refactoringoperation_type.dart
: added a type for "hunger games" background taskproduct_list_import_export.dart
: minor refactoringproduct_list_page.dart
: minor refactoringproduct_questions_query.dart
: pre-loads the product if relevantproduct_questions_widget.dart
: minor refactoringproduct_refresher.dart
: new standard configuration for product lists; new silent download of product lists; minor refactoringquestion_card.dart
: now downloading the product only if not in the local databasequestion_page.dart
: now saving the answer with background tasks; refactoredquestions_query.dart
: refactored as abstract, with code moved to new filerandom_questions_query.dart
robotoff_insight_helper.dart
: minor refactoring