Working with dynamic fields
Adds a new attribute to a dimension (creates a column in the postgress and clickhouse table, displays it in dimensions and in admin forms): ibatyr dynamic add [dimension] [attribute] [Russian label] [English label]
ibatyr dynamic add agent_account physicalDeliveryOfficeName Комната Room
Removes an attribute from a dimension, drops columns: ibatyr dynamic delete [dimension] [attribute]
ibatyr dynamic delete agent_account physicalDeliveryOfficeName
Displays dynamic attributes: ibatyr dynamic list
ibatyr dynamic list
{
"agent_account": [
{
"name": "physicaldeliveryofficename",
"label": {
"ru": "Комната",
"en": "Room"
}
}
]
}
Information about dynamic attributes is stored in the file /var/lib/ibatyr/dynamic.json
The name of the AD attribute must match the name of the dynamic attribute. After synchronization with AD, the data is filled in.
Uploading employee data via csv
To load data, use the ibatyr update_models_from_csv command.
Allows you to update data in the model, including dynamic fields from a csv file.
Naturally, dynamic fields must be added to the table.
Command line switches:
—search-key search_expr* - the field by which the record to be updated will be searched and what value from the line of the csv file will be used for the search.
—map map_expr* - one or more of these options indicate which fields need to be updated and which values from the line of the csv file will be used for this.
—no-dry-run* - actually update the data. By default, no update occurs - only the update protocol is displayed on the screen.
—coding* — encoding of the input csv file
—skip-header* — skip the first line of the csv file (it may contain a header). Disabled by default.
-v / —verbosity* — logging level (0 - disable)
—delimiter* — column delimiter in the csv file. Default ‘;’
Command line expressions in the –search-key and –map options
The expression looks like: <field_name>=<columns in a line of a csv file separated by commas>
For example: “—search_expression mail=1” - means that the mail field will be used to search for records to update, and the values will be taken from the column of the first line of the csv file
“—map office=1,2,3” - means that if a record is found, the office field will be updated for it, which will take the combined value from columns 1,2,3
Additionally, you can specify a merging symbol: “—map office=1,2,3:.” - means that if a record is found, the office field will be updated for it, which will accept the merging through ‘.’ value from columns 1,2,3
You don’t have to list all the numbers, but use a range. The last number is not included (as in Python) “—map office=1-4:.” - means that if the record is found, then the office field for it will be updated, which will accept the combined through ‘.’ value from columns 1,2,3
And you can use combinations of column numbers and ranges “—map office=1-4,10:.” - means that if a record is found, then the office field will be updated for it, which will accept the combined through ‘.’ value from columns 1,2,3,10
Intersection and duplication of column numbers in expressions is allowed. In this case, the column value will simply be duplicated, as many times as a certain column number appears in the expression (including ranges).
Instead of the last column number, you can use the * symbol - this is also true for ranges.
0-* - means take values from all columns
Restrictions:
For now, you can only update one model (table) - Users (agent_account)
Not all fields can be updated - for agent_account this is:
‘comment’—Comment
‘skype’ — Skype number/login
‘phone’ — Phone number
‘post’ — Position
‘full_name’ — Full Name
‘office’ — Department/office
‘www’ — Web page
‘company’ — Organization
‘manager’ — Manager
‘All dynamic fields that were added by the ibatyr dynamic add …. ‘ command
Not all fields can be searched (not all fields can be specified in –search-key) for agent_account this is:
mail - user email
user_name - user name
Searching for records occurs only in text fields. Using the ‘like’ expression This means that the search can find several suitable records for updating. Everything will be updated!
csv file format
Example:
Сотрудник;Корпоративный email;Подразделение1;;;;;;;;
;;;;;;;;;;
Иванов Александр Петрович;a.ivanov@atloc.ru;Хозяйственное управление;;;;;;;;
Петров Антон Александрович;a.petrov@atloc.ru;Департамент страхования;;;;;;;;
Дихтярь Илья Сергеевич;i.dictyar@atloc.ru;Департамент клиентского обслуживания;;;;;;;;
;;;;;;;;;;
Download based on the example above:
ibatyr update_models_from_csv путь_к_csv --search-key mail=1 --map англ_имя_кастомного_поля_ Подразделение1=2 --no-dry-run