<<

NAME

ProductOpener::Producers - functions specific to the platform for producers

SYNOPSIS

ProductOpener::Producers contains the functions specific to the producers platform:

- Functions to import CSV / Excel files, match column names, convert to OFF csv format - Minion tasks for import and export

DESCRIPTION

..

get_minion()

Function to get the backend minion

Arguments

None

Return values

The backend minion $minion

FUNCTIONS

load_csv_or_excel_file ( $file )

Load a CSV or Excel file in a Perl structure.

- CSV files should be in UTF-8 and separated with a comma. They are processed with Text::CSV. - Excel files are first converted to CSV with gnumeric's ssconvert.

Arguments

file name with absolute path

CSV or Excel file

Return values

A hash ref with:

headers

A reference to an array of header names.

rows

A reference to an array of rows, containing each an array of column values

init_fields_columns_names_for_lang ( $l )

Populates global $fields_columns_names_for_lang for the specified language.

The function creates a hash of all the possible localized column names that we can automatically recognize, and maps them to the corresponding field in OFF.

Arguments

$l - required

Language code (string)

Return value

Reference to the column names hash.

Minion tasks

Minion tasks that can be added to the queue by standalone scripts or the web site, that are then executed by the minion-off and minion-off-pro daemons.

The daemons are configured in /etc/systemd/system

e.g. /etc/systemd/system/minion-off.service

[Unit] Description=off minion workers After=postgresql.service

[Service] Type=simple User=off WorkingDirectory=/srv/off/scripts Environment="PERL5LIB=/srv/off/lib/" ExecStart=/srv/off/scripts/minion_producers.pl minion worker -m production -q openfoodfacts.org KillMode=process

[Install] WantedBy=multi-user.target

<<