fn : function(req, res, query) { var results = []; for (var i = 0; i < query.pageSize; i++) { results.push({ id : faker.random.number(), advName: faker.name.firstName(), date : faker.date.past().getTime(), numOfAdReq : faker.random.number(),// 请求数量 numOfAdRes : faker.random.number(),// 有效请求数量 numOfAdClicks : faker.random.number(),// 点击数 numOfAdImpressions : faker.random.number(),// 展现数量 chargeOfImpressions : faker.finance.amount(),// 展示收入 chargeOfClicks : faker.finance.amount(),// 点击收入 ctr : faker.finance.amount(),// 点击率 cpm : faker.finance.amount()//千次展现收入 }); } return { ret : 1, result : { pageSize : query.pageSize, pageNum : query.pageNum, total : 400, list : results } }; },
function generateData () { // Championships generation var championships = []; for (var i = 0; i < 10; i++) { championships.push({ "id": i, "name": faker.commerce.product(), "country": { "name": faker.address.country() }, "arjel": faker.random.boolean() }); } // Matches generation var matches = []; for (var j = 0; j < 50; j++) { matches.push({ "id": j, "championshipId": faker.random.arrayElement(championships).id, "home": faker.address.city(), "away": faker.address.city(), "date": faker.date.recent(), "homeOdds": generateDoubleList(10, 1.2, 1.6), "homeStatistics": { "evo": -0.4 }, "drawOdds": generateDoubleList(10, 2.8, 3.4), "drawStatistics": { "evo": 0.0 }, "awayOdds": generateDoubleList(10, 1.9, 2.5), "awayStatistics": { "evo": 0.2 }, "score": faker.random.number({min: 0, max: 10}) + " - " + faker.random.number({min: 0, max: 10}), "status": 0 }); } // Stats by championship generation var statsBychampionships = []; for (var k = 0; k < championships.length; k++) { statsBychampionships.push({ "id": k, "homeMean": faker.finance.amount(1.2, 1.6, 2), "drawMean": faker.finance.amount(2.8, 3.4, 2), "awayMean": faker.finance.amount(1.9, 2.5, 2) }); } return { "championship": championships, "soccermatch": matches, "soccermatchstats": statsBychampionships }; }
static createRowObjectData(index):OperationShape { return { id: uid.type('Invoice--O'), index: index, date: faker.date.past(), type: faker.random.arrayElement(['Expense' | 'Check']), refNo: 1000 + index, payee: faker.fake('{{name.firstName}} {{name.lastName}}'), category: faker.finance.accountName(), total: faker.finance.amount(), }; }
function createComplexEntity(i){ return { user: createEntity(i), adress: adressJSON, finance: { name: faker.finance.accountName(), amount: faker.finance.amount(), currency: faker.finance.currencyName(), test: true, moves: _createFinancialMoves() } } }
Category.create(newCategory, function(err, createdCategory){ if(err) console.log(err); // Get the ID of the parent Category var categoryId = createdCategory.id; // Get random number between 1 and maxProducts number of Products var numOfProducts = Math.floor(Math.random() * maxProducts) + minProducts; // Create numOfProducts for(var j = 0; j < numOfProducts; j++) { // Define new Product var newProduct = { categoryId: categoryId, name: faker.company.catchPhrase(), description: faker.lorem.sentence(), company: faker.company.companyName(), price: faker.finance.amount(), image: faker.image.image() } // Create the Product Product.create(newProduct, function(err){ if(err) console.log(err); }); } // Log it console.log('Category', categoryId, 'has', numOfProducts, 'Products'); });
function generateOrder(customers, products, neededProducts) { if (neededProducts === undefined) { neededProducts = 5; } var customer = getRandomElement(customers); var customerProducts = []; for (var i = 0; i < neededProducts; i++) { var currentProduct = getRandomElement(products); if (!containsId(customerProducts, currentProduct._id)) { customerProducts.push(currentProduct); } } var order = { date: faker.date.past(), total_sum: customerProducts.reduce(function (memo, item) { return memo + item.price; }, 0), customer: customer, payment: { card_owner: [customer.name, customer.surname].join(' '), cardId: faker.finance.account() }, order_items_id: customerProducts.map(function (item) { return { "$ref": COLLECTION.PRODUCT, "$id": item._id }; }) }; return order; }
function generateRandomItem( index ) { return { invoiceNumber: index, total: parseFloat(faker.finance.amount()), createdAt: faker.date.past( 0, new Date() ) } }
function getRandomName(long) { if (long) { return faker.internet.domainName() + ' ' + faker.finance.accountName(); // long enough for layout testing purposes } else { return faker.internet.domainName(); } }
app.get('/api/fake/finance', function(req, res) { res.json([ { account: faker.finance.account(), accountName: faker.finance.accountName(), mask: faker.finance.mask(), amount: faker.finance.amount(), transactionType: faker.finance.transactionType(), currencyCode: faker.finance.currencyCode(), currencyName: faker.finance.currencyName(), currencySymbol: faker.finance.currencySymbol(), bitcoinAddress: faker.finance.bitcoinAddress() } ]) });
.get('/feeds', (ctx, next) => { const feeds = []; for (let index = 1; index <= 5; index += 1) { const feed = { id: faker.random.uuid(), total_price: faker.finance.amount(), modified_date: faker.date.past(), winner_account: { profile_img_url: faker.image.avatar(), address: faker.finance.bitcoinAddress(), }, asset: { name: faker.lorem.word(), }, }; feeds.push(feed); } ctx.body = feeds; });
var makeAccountList = function() { var accounts = []; for (var i = 0; i < 3; i++) { accounts.push({ display_name: faker.name.findName(), id: faker.finance.account() }); } return accounts; };
'05 - Checkout payment': function (browser) { browser = browser .waitForElementPresent('#cardNumber', maxWait) .setValue('#cardNumber', '4242424242424242') .setValue('#cvc', Faker.finance.account(3)) .setValue('#expMonth', moment().month() + 1) .setValue('#expYear', moment().add(1, 'year').year()) .click('.btn') .waitForElementVisible('body.confirm-order', 5000) },
function generateDoubleList(numberOfElement, min, max) { var doubles = []; for (var i = 0; i < numberOfElement; i++) { doubles.push( parseFloat(faker.finance.amount(min, max, 2)) ); } return doubles; }
.always(function() { var account_id = faker.finance.account(); vm.connectExistingAccount(account_id) .always(function() { assert.calledWith(stub, importAuthUrl, { external_account_id: account_id }); done(); }); });
const seedingMyMessages = () => { for (let i = 1; i <= 5000; i += 1) { const month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; const year = ['2015', '2016', '2017', '2018', '2019']; const message = faker.lorem.sentences(); const listing = faker.random.number({ min: 1, max: 100 }); const username = faker.name.firstName(); const userId = faker.random.number(800); const profilePic = faker.internet.avatar(); const date = `${month[Math.floor(Math.random() * 12)]} ${year[Math.floor(Math.random() * 5)]}`; const accuracy = faker.finance.amount(0, 5, 2); const communication = faker.finance.amount(0, 5, 2); const cleanliness = faker.finance.amount(0, 5, 2); const checkIn = faker.finance.amount(0, 5, 2); const value = faker.finance.amount(0, 5, 2); const location = faker.finance.amount(0, 5, 2); db.query(`INSERT INTO Messages(message, user_id, username, profile_picture, listing, date, accuracy, communication, cleanliness, check_in, value, location) VALUES('${message}', ${userId}, '${username}', '${profilePic}', ${listing}, '${date}', ${accuracy}, ${communication}, ${cleanliness}, ${checkIn}, ${value}, ${location});`, (err, data) => { if (err) { console.log('ERROR GETTING DATA INSERTED', err); } else { console.log('SUCCESSFUL ENTRY', data); } }); } };
const seedingMyMessages = () => { for (let i = 1; i <= 500; i += 1) { const message = faker.lorem.sentences(); const listing = faker.random.number({ min: 1, max: 100 }); const username = faker.internet.userName(); const userId = faker.random.number(800); const profilePic = faker.internet.avatar(); const date = faker.date.between('2015-01-01', '2019-04-30'); const accuracy = faker.finance.amount(0, 5, 2); const communication = faker.finance.amount(0, 5, 2); const cleanliness = faker.finance.amount(0, 5, 2); const checkIn = faker.finance.amount(0, 5, 2); const value = faker.finance.amount(0, 5, 2); const location = faker.finance.amount(0, 5, 2); const realDate = moment(date).format('YYYY-MM-DD'); db.query(`INSERT INTO Messages(message, user_id, username, profile_picture, listing, date, accuracy, communication, cleanliness, check_in, value, location) VALUES('${message}', ${userId}, '${username}', '${profilePic}', ${listing}, '${realDate}', ${accuracy}, ${communication}, ${cleanliness}, ${checkIn}, ${value}, ${location});`, (err, data) => { if (err) { console.log('ERROR GETTING DATA INSERTED', err); } else { console.log('SUCCESSFUL ENTRY', data); } }); } };
it("makes a PUT request contianing the VM's tfaCode to the settingsUrl passed on instantiation", (done) => { var code = faker.finance.account(); vm.tfaCode(code); vm.submitSettings() .done(callback) .always(function() { assert.calledWith(callback, { code: code }); done(); }); server.respond(); });
fn : function(req, res, query) { var results = []; var NameArr = ['卡尔玛','潘森','卡特琳娜','安妮','布隆','艾希','盖伦','赵信','嘉文','瑞文',] for (var i = 0; i < query.pageSize; i++) { results.push({ id : faker.random.number().toString(),// 计划ID advId : faker.random.number().toString(),// 广告主ID advName : NameArr[(faker.random.number()+'').slice(-1)],// 广告主名称 name : faker.name.firstName(),// 计划名称 budgetAmountTotal : faker.finance.amount(),// 计划预算 budgetAmountDaily : faker.finance.amount(),// 计划每日预算 verificationStatus : [ "CREATING", "PENGDING", "APPROVED", "DENIED" ][faker.random .number() % 4],// 应用审核状态 availabilityStatus : [ "ONLINE", "OFFLINE_COMPLETEDONLINE", "OFFLINE_OUT_OF_DAILY_BUDGET", "OFFLINE_OUT_OF_TOTAL_BUDGET", "OFFLINE_UNKNOWN_EXECEPTION", "OFFLINE_SUSPEND" ][faker.random .number() % 6],// 应用审核通过以后才可能有这个状态,应用投放状态 createdAt : faker.date.past().getTime() }); } return { ret : 1, result : { pageSize : query.pageSize, pageNum : query.pageNum, totalRecords : 400, results : results } }; },
it('returns the value of the name property of the currently set folder when the Node has auth', () => { vm.nodeHasAuth(true); vm.folder({ name: null, id: null }); assert.equal(vm.folderName(), ''); var name = faker.hacker.noun(); vm.folder({ name: name, id: faker.finance.account() }); assert.equal(vm.folderName(), name); });
it("returns the selected folder's name if set else 'None' when the User is owner", () => { vm.userIsOwner(true); vm.selected({ name: null, id: null }); assert.equal(vm.selectedFolderName(), 'None'); var name = faker.hacker.noun(); assert.notEqual(name, 'None'); vm.selected({ name: name, id: faker.finance.account() }); assert.equal(vm.selectedFolderName(), name); });
function generateChartGrid(_opts) { _opts = _opts || {}; var opts = _.defaults(_opts, defaultOpts); var randChartProps = { scale: { primaryScale: { prefix: faker.finance.currencySymbol(), suffix: " " + faker.hacker.noun() + "s", } }, input: { raw: defaultInput.init_data_ordinal, status: "VALID", valid: true }, chartSettings: [], data: [], extraPadding: { top: 0, right: 0, bottom: 0, left: 0 }, _grid: { type: opts.type }, numColors: 11, mobile: {} }; var randMetadata = { id: null, chartType: "chartgrid", title: faker.company.catchPhrase(), source: "Data: " + faker.company.companyName(), credit: faker.address.country() + " | " + faker.internet.domainName(), size: opts.size }; var chartProps = parseChartGrid(chartGridConfig, randChartProps); var anyDragged = false; return { chartProps: chartProps, metadata: randMetadata }; }
exports.order = function(app, count) { console.info('RUN FAKER ORDER'); var helper = faker.helpers; for(var i = count; i >= 0; i--){ var order = faker.helpers.contextualCard(); var shippingAddress = faker.helpers.userCard(); order._id = (i+1).toString(); order.orderId = 100000 + i; order.account = '#'+faker.finance.account(); order.name = shippingAddress.name; order.dob = dateFormat(order.dob); order.comment = faker.lorem.sentence(); order.shippingAddress = shippingAddress.address; order.shippingAddress.name = shippingAddress.name; order.createdAt = dateFormat(faker.date.past()); order.updatedAt = dateFormat(faker.date.past()); order.items = this.product(app,faker.commerce.price(1, 6, 0, '') * 1, false); order.transaction = faker.helpers.createTransaction(); order.transaction.date = dateFormat(order.transaction.date); // order.subtotal = faker.commerce.price(5.9, 7.9, 2, '') * 1; order.subtotal = 0; order.taxRate = 19.00; for (var item = 0; item < order.items.length; item++) { order.items[item].qty = faker.commerce.price(1, 3, 0, '') * 1; order.items[item].total = order.items[item].price_euro * order.items[item].qty; order.subtotal += order.items[item].total; } order.tax = faker.commerce.price(19, 19, 2, '') * 1; order.shipping = faker.commerce.price(5.9, 7.9, 2, '') * 1; order.discount = 0; order.total = parseFloat(((order.subtotal + order.shipping) * 1.19)).toFixed(2)*1; app.service('orders').create(order, {}).then(function(data) { // console.log('Created product data', 'data'); }); if(i==1) console.log('FAKER ORDER',order); // post('http://localhost:3030/cms', prod); }; // console.log('this.product',this.product); }
factory.define('coupon', CouponFactory, function(buildOptions) { var coupon = { account: buildOptions.account, charge: buildOptions.plan, reference_id: faker.random.alphaNumeric(), coupon_created: faker.date.recent(), amount_off: faker.finance.amount(), currency: "usd", duration: "1 Month", duration_in_months: 1, max_redemptions: faker.random.number(), percent_off: faker.random.number(), redeem_by: faker.date.future(), times_redeemed: faker.random.number(), valid: true } return coupon; });
"adverts": _.times( 12, function(n) { return { id: n, guid: faker.random.uuid(), ad_id: faker.finance.account() + faker.random.number(), ad_name: faker.commerce.productAdjective() + ' ' + faker.commerce.productName(), ad_price: faker.random.number() * 1000, ad_price_negotiable: faker.random.number() % 2 === 0 ? 1 : 0, ad_created: moment.utc(faker.date.past()).subtract(1, 'd').valueOf(), ad_posted: moment.utc(faker.date.past()).valueOf(), ad_region: faker.address.country(), ad_city: faker.address.city(), ad_condition: faker.random.number() % 2 === 0 ? 1 : 0, ad_verified: faker.random.number() % 2 === 0 ? 1 : 0, ad_img_featured: { url: 'asset/image/sample/ad/sample-image-' + chance.integer({ min: 1, max: 12 }) + '.jpg', alt: 'Featured Image' }, ad_img_gallery: function() { var _a = chance.unique( function() { return chance.integer({ min: 1, max: 10 }); }, 10); _a = _.map( _a, function( n ) { return { url: 'asset/image/sample/ad/sample-image-' + chance.integer({ min: 1, max: 12 }) + '.jpg', alt: 'Gallery Image' }; }); return _a; }(), seller_name: faker.company.companyName(), seller_contact: faker.phone.phoneNumberFormat(), seller_last_location: faker.address.country(), seller_last_login: moment.utc(faker.date.past()).subtract(1, 'w').valueOf(), seller_registered: moment.utc(faker.date.past()).subtract(1, 'M').valueOf(), seller_verified: faker.random.number() % 2 === 0 ? 1 : 0 }; })
var makeFakeData = function(overrides) { var nodeHasAuth = faker.random.number() ? true : false; var userHasAuth = faker.random.number() ? true : false; var userIsOwner = faker.random.number() ? true : false; var ownerName = faker.name.findName(); var folder = { name: faker.hacker.noun(), id: faker.finance.account(), path: faker.hacker.noun() }; var urlPath = faker.internet.domainWord(); var url = faker.internet.ip(); var urls = {}; urls[urlPath] = url; var data = { nodeHasAuth: nodeHasAuth, userHasAuth: userHasAuth, userIsOwner: userIsOwner, folder: folder, ownerName: ownerName, urls: urls }; return $.extend({}, data, overrides); };
return [0,1,2,3,4,5,6,7,8,9,10].map(() => ({ transactionType: faker.finance.transactionType(), amount:faker.finance.amount() }));
var faker = require('faker'); module.exports = { title : "开发者首页-7日收益概览API", desc : "开发者首页-7日收益概览API", type : 'GET', url : '/v1/dev/stats/chargeOf7Day', request : {}, res : { ok : { ret : 1,// 状态码表示成功 result : [// 7日收益数据 faker.finance.amount(), faker.finance.amount(), faker.finance.amount(), faker.finance.amount(), faker.finance.amount(), faker.finance.amount(), faker.finance.amount() ] }, err : { ret : 0, message : "当前用户不存在,请确认" } } };
var faker = require('faker'); var product = faker.commerce.product(); var price = faker.finance.amount(); for(i = 0; i <= 10; i++) { console.log(faker.commerce.product()); console.log('$' + faker.finance.amount()); }
exports.product = function(app, count, update) { if(update !== false) console.info('RUN FAKER PRODUCT'); var helper = faker.helpers; var products = []; for(var i = count; i >= 0; i--){ var name = faker.commerce.productName(); var price = parseFloat(faker.commerce.price()); var price_euro = faker.commerce.price(10.9, 17.9, 2, '') * 1; var price_dollar = faker.commerce.price(2.9, 7.9, 2, '') * 1; var prod = { _id: (i+1).toString(), active: faker.random.boolean(), sku: faker.finance.mask(), name: name, description: faker.lorem.sentences(), url: faker.internet.url() + '/' + faker.helpers.slugify(name), price_euro: price_euro, price_dollar: price_dollar, image: faker.image.fashion(), locales: [ {lang:'EN', title:name, description: faker.lorem.sentences()}, {lang:'ES', title:faker.commerce.productName(), description: faker.lorem.sentences()}, {lang:'FR', title:faker.commerce.productName(), description: faker.lorem.sentences()}, {lang:'IT', title:faker.commerce.productName(), description: faker.lorem.sentences()} ], images: [ { href: 'https://www.medic-world.com/skin/frontend/ultimo/mw/images/flags/mwd.png', // href: faker.image.fashion(), title: faker.random.words(), description: faker.random.words(), mediaType: 'jpg', } ], attributes: { color: faker.commerce.color(), material: faker.commerce.productMaterial(), adjective: faker.commerce.productAdjective(), }, base_color: '#'+(function lol(m,s,c){return s[m.floor(m.random() * s.length)] + (c && lol(m,s,c-1));})(Math,'0123456789ABCDEF',4), createdAt:'2016-12-18', updatedAt:'2016-12-18', }; if(update !== false) app.service('products').create(prod, {}).then(function(data) { // console.log('Created product data', 'data'); }); products.push(prod); if(i==1 && update !== false) console.log('FAKER product',prod); // post('http://localhost:3030/cms', prod); }; return products; }
router.get('/perform-signup', (req, res) => { const subscriptionId = faker.random.uuid() const subscriptionRenewalDate = faker.date.future() const creditCardExpirationDate = faker.date.future() const subscription = { customer: { your_customer_id: req.query.user_id, default_currency_iso_code: 'EUR', default_contact: { locale: req.query.locale, first_name: faker.name.firstName(), last_name: faker.name.lastName(), company: faker.company.companyName(), street: faker.address.streetName(), zip_code: faker.address.zipCode(), city: faker.address.city(), country_iso_code: 'US', email: faker.internet.email(), }, payment_information: { payment_method: 'visa', card_last_four_digits: `${faker.random.number({ min: 1000, max: 9999 })}`, card_expiration_date: `${creditCardExpirationDate.getMonth()}/${creditCardExpirationDate.getFullYear()}`, }, remote_ip: faker.internet.ip(), }, id: subscriptionId, // for mock retrieval billing_cycle_frequency: '6m', currency_iso_code: 'EUR', next_billing_at: subscriptionRenewalDate, next_renewal_at: subscriptionRenewalDate, plans: [ { plan_id: req.query.plan_id, plan_version: 0, quantity: 1, }, ], renewal_type: 'auto', started_at: new Date().toISOString(), status: 'active', subscription_id: subscriptionId, } const invoiceId = `${faker.random.number({ min: 100000000, max: 999999999 })}` const invoice = { currency_iso_code: 'EUR', customer_id: subscription.customer.your_customer_id, created_at: subscription.started_at, document_url: `/v1/customers/${subscription.customer.your_customer_id}/invoices/${invoiceId}`, gross: faker.finance.amount(), id: invoiceId, payment_provider_invoice_id: invoiceId, type: 'charge', } const notification = { notification_id: `notification_${subscriptionId}_created`, client_id: '', event: { type: 'subscription.created', id: `event_${subscriptionId}_created`, occurred_at: subscription.started_at, }, resource: { type: 'subscription', id: subscriptionId, current_state: subscription, }, } const mvtCampaign = req.query.mvt_campaign db('subscriptions').push(subscription) db('invoices').push(invoice) utils.createNotificationRequest(env, notification) .end((err) => { if (err) { res .status(500) .send(`An error occured while sending the notification: ${err}`) return } res .status(200) .send(`The following subscription has been created: subscription_id: ${subscription.subscription_id} plan_id: ${subscription.plans[0].plan_id} user_id: ${subscription.customer.your_customer_id} locale: ${subscription.customer.default_contact.locale} mvt_campaign: ${mvtCampaign} `) }) })