Skip to content

Commit a8831b0

Browse files
committed
Merge remote-tracking branch 'origin/master' into zoho-magento2
# Conflicts: # config.toml
2 parents a08024f + befbbb1 commit a8831b0

File tree

56 files changed

+4730
-2069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4730
-2069
lines changed

config.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,23 @@ hasChildren = true
180180
url = "connectivity/filtering"
181181
weight = 12
182182

183+
[[menu.main]]
184+
parent = "Connectivity"
185+
name = "Batch"
186+
url = "connectivity/batch"
187+
weight = 13
188+
183189
[[menu.main]]
184190
parent = "Connectivity"
185191
name = "Magento 2"
186192
url = "connectivity/magento-2"
187-
weight = 13
193+
weight = 14
188194

189195
[[menu.main]]
190196
parent = "Connectivity"
191197
name = "Zoho CRM"
192198
url = "connectivity/zoho"
193-
weight = 14
199+
weight = 15
194200

195201
[params]
196202
logo = "logo-web.svg"
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: "Batch"
3+
date: 2023-06-22T12:00:02+02:00
4+
draft: false
5+
type: "plugins"
6+
description: "Fork a single line into multiple lines, or merge multiple lines into one."
7+
weight: 13
8+
---
9+
10+
- [What is it?](#what-is-it)
11+
- [Installation](#installation)
12+
- [Usage](#usage)
13+
- [Forking a line](#forking-a-line)
14+
- [Merging multiple lines](#merging-multiple-lines)
15+
---
16+
17+
## What is it?
18+
19+
The Batch plugin can split a single line of data into multiple ones, or can merge multiple lines into a single one.
20+
21+
## Installation
22+
23+
This plugin is already integrated into the Satellite package, so you can’t require it with composer.
24+
25+
## Usage
26+
27+
### Forking a line
28+
29+
`fork` splits data into multiple lines.
30+
31+
In the following example, we have one line containing 2 fields: an `id`, and `images` which contains multiple values.
32+
Instead we want to have multiple lines, each containing a single `image` along with the `id`.
33+
34+
Our example input looks like this:
35+
```json
36+
[{"images": ["one.jpg", "two.jpg", "three.jpg"], "id": 15}]
37+
```
38+
39+
We'll use the "fork" option to split the lines for each value under `images`:
40+
41+
{{< tabs name="fork" >}}
42+
43+
{{< tab name="YAML configuration" codelang="yaml" >}}
44+
batch:
45+
fork:
46+
foreach: '@=input["images"]'
47+
do: '@={ id: input["id"], image: item }'
48+
{{< /tab >}}
49+
50+
{{< tab name="interpreted code" codelang="php" >}}
51+
$results = [];
52+
foreach ($input["images"] as $key => $item) {
53+
$results[] = ["id" => $input["id"], "image" => $item];
54+
}
55+
{{< /tab >}}
56+
{{< /tabs >}}
57+
58+
The result will be:
59+
```json
60+
[{"id": 15, "image": "one.jpg"}]
61+
[{"id": 15, "image": "two.jpg"}]
62+
[{"id": 15, "image": "three.jpg"}]
63+
```
64+
65+
### Merging multiple lines
66+
67+
`merge` concatenates many lines traversing the pipeline into fewer lines.
68+
69+
This can be useful if the targeted API can handle many batches of data in a single payload, like Akeneo for example.
70+
71+
Our example input looks like this:
72+
```json
73+
[{"foo": "bar"}]
74+
[{"lorem": "ipsum"}]
75+
[{"ga": "bu"}]
76+
[{"zo": "meu"}]
77+
[{"bla": "bli"}]
78+
```
79+
80+
We'll use the "merge" option. `size` dictates the maximum number of lines to concatenate:
81+
82+
{{< tabs name="fork" >}}
83+
84+
{{< tab name="YAML configuration" codelang="yaml" >}}
85+
batch:
86+
merge:
87+
size: 2
88+
{{< /tab >}}
89+
{{< /tabs >}}
90+
91+
When the number of item reaches `size`, the merge will be applied to the next lines, and so on.
92+
93+
The output will be:
94+
```json
95+
[{"foo": "bar"},{"lorem": "ipsum"}]
96+
[{"ga": "bu"},{"zo": "meu"}]
97+
[{"bla": "bli"}]
98+
```

content/feature/expression-language/array-expression-functions/_index.en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ foo: '@=map(input["attributes"], extractData("[fr_FR][data]"))'
6060
| intersect(`array` array, `array` ...arrays): `array` | Computes the intersection of arrays |
6161
| filterList(`string` iterator, `string` callback): `FilterIterator` | Filters elements of an array using a callback function |
6262
| mapValues(`array` input, `array{pattern: replacement}` values): `array` | Finds multiple matches in the input and replaces them with a value, with the format `{pattern: replacement, pattern: replacement ... }` |
63+
| implode(`string` $separator, `array` $array): `string` | Turns a list into a string |
6364

6465
### Closures that can be provided to reduce
6566

content/feature/expression-language/string-expression-functions/_index.en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ foo: '@=dateTime(input["updated_at"], "YYYY-MM-ddTHH:ii:ss", "Europe/Paris")'
6868
| asFloat(`string` value): `string` | Converts the value into a float number |
6969
| asInteger(`string` value): `string` | Converts the value to an integer |
7070
| asString(`string` value): `string` | Converts the value into a string |
71+
| truncate(`string` input, `int` limit): `string` | Truncates a value and adds "…" at the end of it |

content/getting-started/environment-setup/_index.en.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ After installing PHP, you must ensure that Composer 2 is installed on your machi
1919

2020
For more information on how to install Composer, go to the [official documentation](https://getcomposer.org/download/).
2121

22-
### JQ
23-
24-
Jq, a JSON processor, is also required for satellites to generate their composer.json files.
25-
26-
For more information on how to install jq, go to the [official documentation](https://stedolan.github.io/jq/download/).
27-
2822
### Docker (optional)
2923

3024
Gyroscops offers you the possibility to build your configurations as images that you can use in a dockerized environment.
3125
That's why you may also need Docker.
3226

3327
For more information on how to install Docker, go to the [official documentation](https://docs.docker.com/get-docker/).
28+
29+
## Before v0.6.6 of `php-etl/satellite`:
30+
31+
### JQ
32+
33+
Jq, a JSON processor, is also required for satellites to generate their composer.json files.
34+
35+
For more information on how to install jq, go to the [official documentation](https://stedolan.github.io/jq/download/).

docs/categories/index.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<title>Categories | Gyroscops Documentation</title>
66

7-
<meta name="generator" content="Hugo 0.92.2" />
7+
<meta name="generator" content="Hugo 0.111.3">
88

99
<!-- mobile responsive meta -->
1010
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
@@ -162,6 +162,8 @@
162162

163163
<a class="dropdown-item" href="/documentation/connectivity/filtering">Filtering, drop or reject</a>
164164

165+
<a class="dropdown-item" href="/documentation/connectivity/batch">Batch</a>
166+
165167
</div>
166168
</li>
167169

@@ -523,6 +525,22 @@ <h1 class="single-title mb-5">
523525

524526

525527

528+
529+
530+
531+
532+
533+
534+
535+
536+
537+
538+
539+
540+
541+
542+
543+
526544

527545

528546

0 commit comments

Comments
 (0)