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

feat: launch the exports for all organizations that have the checkbox… #10561

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 42 additions & 24 deletions scripts/export_producers_platform_data_to_public_database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,48 @@

export PERL5LIB="lib:${PERL5LIB}"

PRODUCERS=(
org-barilla-france-sa
org-ferrero-france-commerciale
org-unilever-france-gms
org-unilever-france-rhd
org-nestle-france
org-panzani-sa
org-cristalco
org-materne
org-garofalo-france
org-brasseries-kronenbourg
org-carrefour
org-lustucru-frais
org-nestle-waters
org-kambly
org-kambly-france
org-saint-hubert
org-d-aucy
org-lea-nature
org-auchan-apaw
org-les-mousquetaires
)

for producer in ${PRODUCERS[@]}
filter_organizations_that_have_automated_export() {
Copy link
Member

Choose a reason for hiding this comment

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

Shan't we leverage having orgs in MongoDB now and just make a mongoDB request (you can even user mongo client) to get all orgs with activate_automated_daily_export_to_public_platform on ?

cc: @stephanegigandet

Copy link
Member Author

@4nt0ineB 4nt0ineB Jul 18, 2024

Choose a reason for hiding this comment

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

Oh yes I forgot, sure we can do that.

my @res = get_orgs_collection()
->find({ activate_automated_daily_export_to_public_platform => "on" })
->fields({ org_id => 1 })
->all;

perl -e '
use strict;
use warnings;
use ProductOpener::Data qw/get_orgs_collection/;

my %producers = map { $_,1 } qw(
org-barilla-france-sa
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably should remove the hardcoded values, and ensure all those orgs have the checkbox checked

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. But I'm not an admin so I can't see the checkbox in the platform.

org-ferrero-france-commerciale
org-unilever-france-gms
org-unilever-france-rhd
org-nestle-france
org-panzani-sa
org-cristalco
org-materne
org-garofalo-france
org-brasseries-kronenbourg
org-carrefour
org-lustucru-frais
org-nestle-waters
org-kambly
org-kambly-france
org-saint-hubert
org-d-aucy
org-lea-nature
org-auchan-apaw
org-les-mousquetaires
);

my @res = get_orgs_collection()
->find({ activate_automated_daily_export_to_public_platform => "on" })
->fields({ org_id => 1 })
->all;

$producers{"org-" . $_->{org_id}} = undef for @res;

print "$_\n" for keys %producers;

'
}

for producer in $(filter_organizations_that_have_automated_export)
do
scripts/export_and_import_to_public_database.pl --query states_tags=en:to-be-exported --owner $producer
done
Loading