-
-
Notifications
You must be signed in to change notification settings - Fork 56
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: Filter insights opportunities based on type of tags #859
Conversation
tests/integration/test_api.py
Outdated
params={ | ||
"count": 5, | ||
"page": 1, | ||
"question_type": "category", |
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.
Hey @alexgarel
I am not able to pass the parameters to the functions. question_type
is always None
when passed to get_insights
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 working, but I think you pdb in the first simulate_get
above at line 576, where this parameter is None ! (that's why this is a good idea to separate tests ;-) )
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.
@Jagrutiti some comments to put you back on track.
robotoff/app/api.py
Outdated
insights = list( | ||
get_insights( | ||
keep_types=[question_type], | ||
group_by=True, |
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 don't think it's a good option to have a boolean there.
So either we put a string, the field we want to group on: here group_by=Insight.value_tag
(which as the draw back of using Insight)
or we call the parameter group_by_value_tag (which is a bit less elegant but may better do the job here).
tests/integration/test_api.py
Outdated
params={ | ||
"count": 5, | ||
"page": 1, | ||
"question_type": "category", |
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 working, but I think you pdb in the first simulate_get
above at line 576, where this parameter is None ! (that's why this is a good idea to separate tests ;-) )
product1 = ProductInsightFactory(type="category", value_tag="en:beer") | ||
insight_data1 = get_insights(keep_types=["category"]) | ||
insight_data_items1 = [item.to_dict() for item in insight_data1] | ||
assert insight_data_items1[0]["id"] == product1.id | ||
# assert insight_data_items1[0]["type"] == [] | ||
|
||
product2 = ProductInsightFactory(type="label", value_tag="en:apricots") | ||
insight_data2 = get_insights(keep_types=["label"], value_tag="en:apricots") | ||
insight_data_items2 = [item.to_dict() for item in insight_data2] | ||
assert insight_data_items2[0]["id"] == product2.id | ||
# assert insight_data_items2[0]["type"] == [] | ||
|
||
product3 = ProductInsightFactory(type="label", value_tag="en:soups") | ||
insight_data3 = get_insights(keep_types=["label"], value_tag="en:soups") | ||
insight_data_items3 = [item.to_dict() for item in insight_data3] | ||
assert insight_data_items3[0]["id"] == product3.id | ||
# assert insight_data_items3[0]["type"] == [] | ||
|
||
product4 = ProductInsightFactory(type="category", value_tag="en:chicken") | ||
insight_data4 = get_insights(keep_types=["category"], value_tag="en:chicken") | ||
insight_data_items4 = [item.to_dict() for item in insight_data4] | ||
assert insight_data_items4[0]["id"] == product4.id | ||
# assert insight_data_items4[0]["type"] == [] | ||
|
||
insight_data5 = get_insights(keep_types=["category"]) | ||
insight_data_items5 = [item.to_dict() for item in insight_data5] | ||
assert len(insight_data_items5) == 2 |
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.
You should first create all your data, and then do one or two call to get the lists.
you need insight spread on:
- at least two types
- different value_tag (but with repeated values)
- different barcodes
Co-authored-by: Alex Garel <[email protected]>
Co-authored-by: Alex Garel <[email protected]>
Co-authored-by: Alex Garel <[email protected]>
…dfacts/robotoff into get-unanswered-questions
@Jagrutiti thanks, you now only have to merge master before we can merge it back ! |
Codecov Report
@@ Coverage Diff @@
## master #859 +/- ##
==========================================
+ Coverage 44.73% 52.65% +7.91%
==========================================
Files 96 92 -4
Lines 6981 7014 +33
==========================================
+ Hits 3123 3693 +570
+ Misses 3858 3321 -537
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
What
Why
Fixes bug(s)