Skip to content

Commit

Permalink
fix: 🐛 enable some options
Browse files Browse the repository at this point in the history
  • Loading branch information
touv committed May 5, 2021
1 parent fded8de commit bbadf08
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 79 deletions.
80 changes: 41 additions & 39 deletions docs/plugin-analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ npm install @ezs/analytics
- [bufferize](#bufferize)
- [groupingByModulo](#groupingbymodulo)
- [reducing](#reducing)
- [upload](#upload)
- [aggregate](#aggregate)
- [slice](#slice)
- [upload](#upload)
- [distinct](#distinct)
- [exploding](#exploding)
- [graph](#graph)
Expand Down Expand Up @@ -352,44 +352,6 @@ Output:

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### upload

save all objects in a temporary file
For non Buffer chunks, each object is transformed into a
string of characters in a raw way (no separator)

```json
[
{ year: 2000, dept: 54 },
{ year: 2001, dept: 55 },
{ year: 2003, dept: 54 },
]
```

Script:

```ini
[use]
plugin = analytics

[upload]
cleanupDelay = 5
```

Output:

```json
[
{ id: '/tmp/31234qdE33334dZE', value:3 },
]
```

#### Parameters

- `cleanupDelay` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** TTL in seconds, before cleanup the file (EZS_DELAY) (optional, default `3600`)

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### aggregate

Aggregate by id and count
Expand Down Expand Up @@ -472,6 +434,46 @@ Output:

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### upload

save all objects in a temporary file
For non Buffer chunks, each object is transformed into a
string of characters in a raw way (no separator)

```json
[
{ year: 2000, dept: 54 },
{ year: 2001, dept: 55 },
{ year: 2003, dept: 54 },
]
```

Script:

```ini
[use]
plugin = analytics

[upload]
cleanupDelay = 5
```

Output:

```json
[
{ id: '/tmp/31234qdE33334dZE', value:3 },
]
```

#### Parameters

- `extension` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** set the file extension (optional, default `bin`)
- `prefix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** set the file prefix (optional, default `upload`)
- `cleanupDelay` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** TTL in seconds, before cleanup the file (EZS_DELAY) (optional, default `3600`)

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### distinct

Take `Object` object getting some fields with json path, and do ...
Expand Down
80 changes: 41 additions & 39 deletions packages/analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ npm install @ezs/analytics
- [bufferize](#bufferize)
- [groupingByModulo](#groupingbymodulo)
- [reducing](#reducing)
- [upload](#upload)
- [aggregate](#aggregate)
- [slice](#slice)
- [upload](#upload)
- [distinct](#distinct)
- [exploding](#exploding)
- [graph](#graph)
Expand Down Expand Up @@ -352,44 +352,6 @@ Output:

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### upload

save all objects in a temporary file
For non Buffer chunks, each object is transformed into a
string of characters in a raw way (no separator)

```json
[
{ year: 2000, dept: 54 },
{ year: 2001, dept: 55 },
{ year: 2003, dept: 54 },
]
```

Script:

```ini
[use]
plugin = analytics

[upload]
cleanupDelay = 5
```

Output:

```json
[
{ id: '/tmp/31234qdE33334dZE', value:3 },
]
```

#### Parameters

- `cleanupDelay` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** TTL in seconds, before cleanup the file (EZS_DELAY) (optional, default `3600`)

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### aggregate

Aggregate by id and count
Expand Down Expand Up @@ -472,6 +434,46 @@ Output:

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### upload

save all objects in a temporary file
For non Buffer chunks, each object is transformed into a
string of characters in a raw way (no separator)

```json
[
{ year: 2000, dept: 54 },
{ year: 2001, dept: 55 },
{ year: 2003, dept: 54 },
]
```

Script:

```ini
[use]
plugin = analytics

[upload]
cleanupDelay = 5
```

Output:

```json
[
{ id: '/tmp/31234qdE33334dZE', value:3 },
]
```

#### Parameters

- `extension` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** set the file extension (optional, default `bin`)
- `prefix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** set the file prefix (optional, default `upload`)
- `cleanupDelay` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** TTL in seconds, before cleanup the file (EZS_DELAY) (optional, default `3600`)

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

### distinct

Take `Object` object getting some fields with json path, and do ...
Expand Down
6 changes: 5 additions & 1 deletion packages/analytics/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ import tempy from 'tempy';
* ```
*
* @name upload
* @param {String} [extension=bin] set the file extension
* @param {String} [prefix=upload] set the file prefix
* @param {Number} [cleanupDelay=3600] TTL in seconds, before cleanup the file (EZS_DELAY)
* @returns {Object}
*/
export default async function upload(data, feed) {
const { ezs } = this;
if (this.isFirst()) {
const extension = String(this.getParam('extension', 'bin'));
const prefix = String(this.getParam('prefix', 'upload'));
this.input = ezs.createStream(ezs.objectMode());
const stream = this.input.pipe(ezs.toBuffer());
this.whenWrote = tempy.write(stream);
this.whenWrote = tempy.write(stream, { extension, prefix });
}
if (this.isLast()) {
const cleanupDelayDefault = ezs.settings.cacheDelay;
Expand Down

0 comments on commit bbadf08

Please sign in to comment.