Skip to content
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

chore: add script to gather organization data daily #10447

Conversation

TheSussex
Copy link
Collaborator

What

I added a script to the scripts/migrations folder, this script fetches organzaition products based on the product owner id.

Copy link

sonarcloud bot commented Jun 17, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.51%. Comparing base (dc04d18) to head (0b08094).
Report is 412 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10447      +/-   ##
==========================================
- Coverage   49.54%   49.51%   -0.04%     
==========================================
  Files          67       75       +8     
  Lines       20650    21573     +923     
  Branches     4980     5175     +195     
==========================================
+ Hits        10231    10681     +450     
- Misses       9131     9582     +451     
- Partials     1288     1310      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheSussex TheSussex marked this pull request as ready for review July 10, 2024 20:44
@TheSussex TheSussex requested a review from a team as a code owner July 10, 2024 20:44
Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, that's going in the right direction.

deps/openfoodfacts-shared-services Outdated Show resolved Hide resolved
scripts/save_org_product_data_daily.pl Outdated Show resolved Hide resolved
scripts/save_org_product_data_daily.pl Outdated Show resolved Hide resolved
scripts/save_org_product_data_daily.pl Outdated Show resolved Hide resolved
@github-actions github-actions bot added 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies categories 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org labels Jul 13, 2024
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Jul 14, 2024
@TheSussex TheSussex requested a review from alexgarel July 15, 2024 08:57
@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Jul 15, 2024
'_id' => '$owner',
'number_of_products' => {'$sum' => 1},
'number_of_data_quality_errors' => {
'$sum' => {'$size' => '$data_quality_errors_tags'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my dev account, I got this error when running the script:

MongoDB::DatabaseError: The argument to $size must be an array, but was of type: missing

Can you check that the array exist before calling $size? There is an example here: https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/#example

(same for other array below)

'$cond' => [{'$in' => ['en:nutriscore-not-computed', '$misc_tags']}, 1, 0]
}
},
'opportunities_to_improve_nutriscore' => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is only available on the pro platform, so I think we should run this script on the pro platform.

Can you also add the number of products with states_tags = en:exported , and states_tags = en:to-be-exported ?

]
)->next;

my $number_of_products = $org_data->{number_of_products} // 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In another PR, we will need to make another query for number_of_products, but on the public platform, in order to get the number of products from the pro platform that have been exported to the pro platform.

Copy link
Contributor

@stephanegigandet stephanegigandet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@stephanegigandet stephanegigandet enabled auto-merge (squash) July 22, 2024 11:43
@stephanegigandet stephanegigandet merged commit 1391573 into openfoodfacts:main Jul 22, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
categories multilingual products 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Create a script to gather organisation data nightly from the products database
4 participants