Skip to content

Instantly share code, notes, and snippets.

@mlimaloureiro
Created October 3, 2017 18:37
Show Gist options
  • Save mlimaloureiro/7ebef5f60ff726d9998451bbb0911a08 to your computer and use it in GitHub Desktop.
Save mlimaloureiro/7ebef5f60ff726d9998451bbb0911a08 to your computer and use it in GitHub Desktop.
'use strict';
const delimiter = "\n";
const utils = require('./utils.js');
function transform(item) {
// don't worry about this utils function, just look at transformProfile is doing,
// receiving the streamData and creating an array of object literals with the atomic facts
// we want to store
return utils.arrayObjectToString(transformProfile(item), delimiter);
}
function transformProfile(streamData) {
return [
{
id: streamData['id'],
event_name: 'accommodation_provider_updated_name',
accommodation_provider_id: streamData['accommodation_provider_id'],
field: 'name',
value: streamData['profile']['name'],
timestamp: streamData['timestamp']
},
{
id: streamData['id'],
event_name: 'accommodation_provider_updated_email_address',
accommodation_provider_id: streamData['accommodation_provider_id'],
field: 'email_address',
value: streamData['profile']['email_address']['email_address'],
timestamp: streamData['timestamp']
},
];
}
exports.transform = transform;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment