Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * BUG report
- * get stream 3.10.0
- * feed.addActivities() creates Activities with the same IDs.
- *
- * to run:
- * env APP_TOKEN=... APP_SECRET_TOKEN=... APP_ID=... FEED_GROUP=... FEED_ID=... node demo_bug.js
- */
- stream = require('getstream');
- const APP_TOKEN = process.env.APP_TOKEN;
- const APP_SECRET_TOKEN = process.env.APP_SECRET_TOKEN;
- const APP_ID = process.env.APP_ID;
- const FEED_GROUP = process.env.FEED_GROUP;
- const FEED_ID = process.env.FEED_ID;
- const streamClient = stream.connect(APP_TOKEN, APP_SECRET_TOKEN, APP_ID);
- const feed = streamClient.feed(FEED_GROUP, FEED_ID);
- function createNumberOfPost(count, foreignId) {
- const bigArray = ' '.repeat(count).split('')
- .map((el, ind) => `This is a post number ${ind}.`)
- .map(el => ({
- actor: 'actor',
- verb: 'post',
- object: el,
- target: '',
- time: new Date().toISOString(),
- foreign_id: foreignId,
- }));
- return feed.addActivities(bigArray)
- .then((result) => {
- console.log(`result.length=${result.activities.length}, result=`, result);
- return result;
- })
- .catch(err => {
- console.log(`err=`, err);
- return err;
- });
- }
- createNumberOfPost(10, 'auto_created');
- /**
- *
- * from console:
- *
- result.length=10, result= { activities:
- [ { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 0.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 1.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 2.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 3.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 4.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 5.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 6.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 7.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 8.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' },
- { actor: 'actor',
- foreign_id: 'auto_created',
- id: '2b035b60-f5dc-11e7-8080-800175fbcfb9',
- object: 'This is a post number 9.',
- origin: null,
- target: '',
- time: '2018-01-10T07:59:22.134000',
- verb: 'post' } ],
- duration: '77.04ms' }
- *
- * data explorer shows one record with the last object field.
- *
- */
Add Comment
Please, Sign In to add comment