UNPKG

@speakr/speakr-module-services

Version:
90 lines (75 loc) 2 kB
"use strict"; const db = require('../../db'); module.exports = { temporaryRow }; function temporaryRow(options) { let platformName = _transformPlatformIdToName(options); let accounts = options.accounts.filter(account => { if(platformName === 'Facebook') { return (account.platform === platformName && account.parent_id) } else { return account.platform === platformName; } }); const act_net_promises = options.accounts_networks.map(account_network => { return accounts.forEach(account => { return db.metrics.create({ calc_date: new Date(), accounts_networks_id: account_network.id, influencer_id: account.id, current_username: account.current_username, platform_user_id: account.platform_user_id, platform: platformName, platform_id: options.platforms.id, bio: 'Just joined the Speakr Platform. More details coming soon.', elite: false, lastlogin: new Date(), paypal_email: 'placeholder@comingsoon.com', account_category: 1, email: 'placeholder@comingsoon.com', secondary_email: 'placeholder@comingsoon.com', first_name: '', last_name: '', user_id: 123, date_of_birth: new Date(), city: 'Somewhere', state: 'Some state', country: 'Some country', will_recruit: false, join_date: new Date(), phone: '867-5309', status: 'New', active: true, profane: false, account_id: account.id, cached_avatar: account.current_username, followers: 1, following: 1, offer_price: 1, participating_rate: 0.1, market_value: 1, network_id: account_network.network_id, external: false }); }) }); return Promise.all(act_net_promises) .then(() => { return Promise.resolve(options); }) } function _transformPlatformIdToName(options) { switch(options.platforms.id) { case 1: return 'Twitter'; case 3: return 'Instagram'; case 6: return 'Snapchat'; case 8: return 'Facebook'; case 9: return 'Youtube'; } }