How to use merge-options - 10 common examples

To help you get started, we’ve selected a few merge-options examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
CollectiveId: {
      [Op.not]: 1, // OpenCollective collective
    },
  },
};

const lastWeekDonations = merge({}, createdLastWeek, donation, excludeOcTeam, credit);
const lastWeekExpenses = merge({}, updatedLastWeek, excludeOcTeam);

const pendingLastWeekExpenses = merge({}, lastWeekExpenses, pendingExpense);
const approvedLastWeekExpenses = merge({}, lastWeekExpenses, approvedExpense);
const rejectedLastWeekExpenses = merge({}, lastWeekExpenses, rejectedExpense);
const paidLastWeekExpenses = merge({}, lastWeekExpenses, paidExpense);

const weekBeforeDonations = merge({}, createdSameWeekPreviousMonth, donation, excludeOcTeam, credit);
const paidWeekBeforeExpenses = merge({}, updatedSameWeekPreviousMonth, excludeOcTeam, paidExpense);

const groupAndOrderBy = (table, attribute = 'currency') => {
  return {
    plain: false,
    group: [`${table}.${attribute}`],
    attributes: [[attribute, 'currency']],
    order: [attribute],
  };
};

const onlyIncludeCollectiveType = {
  include: [
    {
      model: Collective,
      as: 'collective',
      where: {
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
export default function run() {
  return Promise.props({
    // Donation statistics

    stripeDonationCount: Transaction.count(merge({}, lastWeekDonations, service('stripe'))),

    priorStripeDonationCount: Transaction.count(merge({}, weekBeforeDonations, service('stripe'))),

    manualDonationCount: Transaction.count(merge({}, lastWeekDonations, service('opencollective'))),

    priorManualDonationCount: Transaction.count(merge({}, weekBeforeDonations, service('opencollective'))),

    paypalDonationCount: Transaction.count(merge({}, lastWeekDonations, service('paypal'))),

    priorPaypalDonationCount: Transaction.count(merge({}, weekBeforeDonations, service('paypal'))),

    revenue: Transaction.aggregate(
      'platformFeeInHostCurrency',
      'SUM',
      merge({}, lastWeekDonations, groupAndOrderBy('Transaction', 'hostCurrency')),
    ),

    priorRevenue: Transaction.aggregate(
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
paidExpenseAmount: Expense.aggregate('amount', 'SUM', merge({}, paidLastWeekExpenses, groupAndOrderBy('Expense'))),

    priorPaidExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, paidWeekBeforeExpenses, groupAndOrderBy('Expense')),
    ),

    // Collective statistics

    activeCollectivesWithTransactions: Transaction.findAll(
      merge({ attributes: ['CollectiveId'] }, createdLastWeek, distinct, excludeOcTeam, onlyIncludeCollectiveType),
    ).map(row => row.CollectiveId),

    priorActiveCollectivesWithTransactions: Transaction.findAll(
      merge(
        { attributes: ['CollectiveId'] },
        createdSameWeekPreviousMonth,
        distinct,
        excludeOcTeam,
        onlyIncludeCollectiveType,
      ),
    ).map(row => row.CollectiveId),

    activeCollectivesWithExpenses: Expense.findAll(
      merge({ attributes: ['CollectiveId'] }, updatedLastWeek, distinct, excludeOcTeam),
    ).map(row => row.CollectiveId),

    priorActiveCollectivesWithExpenses: Expense.findAll(
      merge({ attributes: ['CollectiveId'] }, updatedSameWeekPreviousMonth, distinct, excludeOcTeam),
    ).map(row => row.CollectiveId),
github nuxt-community / blog-module / src / index.js View on Github external
api_key: undefined, // eslint-disable-line camelcase
      sso_config: undefined // eslint-disable-line camelcase
    },
    twitter: null,
    og: null,
    fb: null,
    markdown: {
      plugins: [
        require('markdown-it-decorate'),
        require('markdown-it-emoji')
      ]
    }
  }
  const nuxtOptions = this.nuxt.options

  options = merge(defaults, options, {
    publicPath: (nuxtOptions.build || {}).publicPath || defaults.publicPath,
    static: nuxtOptions.dev ? defaults.static : (options.static === true),
    base: nuxtOptions.dev ? options.devBase || defaults.base : options.base || ''
  })
  options.rootDir = nuxtOptions.rootDir
  options.path = path.resolve(nuxtOptions.rootDir, options.dir)

  blog.context = this
  blog.addSource(`${options.path}/**/*.md`)

  // Register blog routes.
  this.extendRoutes((...any) => registerRoutes(options, ...any))
  // Register api server.
  serve(this, options)
  // Register build process.
  build(this, options)
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
'SUM',
      merge({}, approvedLastWeekExpenses, groupAndOrderBy('Expense')),
    ).map(row => `${row.currency} ${formatCurrency(row.SUM, row.currency)}`),

    rejectedExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, rejectedLastWeekExpenses, groupAndOrderBy('Expense')),
    ).map(row => `${row.currency} ${formatCurrency(row.SUM, row.currency)}`),

    paidExpenseAmount: Expense.aggregate('amount', 'SUM', merge({}, paidLastWeekExpenses, groupAndOrderBy('Expense'))),

    priorPaidExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, paidWeekBeforeExpenses, groupAndOrderBy('Expense')),
    ),

    // Collective statistics

    activeCollectivesWithTransactions: Transaction.findAll(
      merge({ attributes: ['CollectiveId'] }, createdLastWeek, distinct, excludeOcTeam, onlyIncludeCollectiveType),
    ).map(row => row.CollectiveId),

    priorActiveCollectivesWithTransactions: Transaction.findAll(
      merge(
        { attributes: ['CollectiveId'] },
        createdSameWeekPreviousMonth,
        distinct,
        excludeOcTeam,
        onlyIncludeCollectiveType,
      ),
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
// Expense statistics

    pendingExpenseCount: Expense.count(pendingLastWeekExpenses),

    approvedExpenseCount: Expense.count(approvedLastWeekExpenses),

    rejectedExpenseCount: Expense.count(rejectedLastWeekExpenses),

    paidExpenseCount: Expense.count(paidLastWeekExpenses),

    priorPaidExpenseCount: Expense.count(paidWeekBeforeExpenses),

    pendingExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, pendingLastWeekExpenses, groupAndOrderBy('Expense')),
    ).map(row => `${row.currency} ${formatCurrency(row.SUM, row.currency)}`),

    approvedExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, approvedLastWeekExpenses, groupAndOrderBy('Expense')),
    ).map(row => `${row.currency} ${formatCurrency(row.SUM, row.currency)}`),

    rejectedExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, rejectedLastWeekExpenses, groupAndOrderBy('Expense')),
    ).map(row => `${row.currency} ${formatCurrency(row.SUM, row.currency)}`),

    paidExpenseAmount: Expense.aggregate('amount', 'SUM', merge({}, paidLastWeekExpenses, groupAndOrderBy('Expense'))),
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
const approvedExpense = { where: { status: expenseStatus.APPROVED } };
const rejectedExpense = { where: { status: expenseStatus.REJECTED } };
const paidExpense = { where: { status: expenseStatus.PAID } };

const credit = { where: { type: 'CREDIT' } };

const excludeOcTeam = {
  where: {
    CollectiveId: {
      [Op.not]: 1, // OpenCollective collective
    },
  },
};

const lastWeekDonations = merge({}, createdLastWeek, donation, excludeOcTeam, credit);
const lastWeekExpenses = merge({}, updatedLastWeek, excludeOcTeam);

const pendingLastWeekExpenses = merge({}, lastWeekExpenses, pendingExpense);
const approvedLastWeekExpenses = merge({}, lastWeekExpenses, approvedExpense);
const rejectedLastWeekExpenses = merge({}, lastWeekExpenses, rejectedExpense);
const paidLastWeekExpenses = merge({}, lastWeekExpenses, paidExpense);

const weekBeforeDonations = merge({}, createdSameWeekPreviousMonth, donation, excludeOcTeam, credit);
const paidWeekBeforeExpenses = merge({}, updatedSameWeekPreviousMonth, excludeOcTeam, paidExpense);

const groupAndOrderBy = (table, attribute = 'currency') => {
  return {
    plain: false,
    group: [`${table}.${attribute}`],
    attributes: [[attribute, 'currency']],
    order: [attribute],
  };
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
'SUM',
      merge({}, rejectedLastWeekExpenses, groupAndOrderBy('Expense')),
    ).map(row => `${row.currency} ${formatCurrency(row.SUM, row.currency)}`),

    paidExpenseAmount: Expense.aggregate('amount', 'SUM', merge({}, paidLastWeekExpenses, groupAndOrderBy('Expense'))),

    priorPaidExpenseAmount: Expense.aggregate(
      'amount',
      'SUM',
      merge({}, paidWeekBeforeExpenses, groupAndOrderBy('Expense')),
    ),

    // Collective statistics

    activeCollectivesWithTransactions: Transaction.findAll(
      merge({ attributes: ['CollectiveId'] }, createdLastWeek, distinct, excludeOcTeam, onlyIncludeCollectiveType),
    ).map(row => row.CollectiveId),

    priorActiveCollectivesWithTransactions: Transaction.findAll(
      merge(
        { attributes: ['CollectiveId'] },
        createdSameWeekPreviousMonth,
        distinct,
        excludeOcTeam,
        onlyIncludeCollectiveType,
      ),
    ).map(row => row.CollectiveId),

    activeCollectivesWithExpenses: Expense.findAll(
      merge({ attributes: ['CollectiveId'] }, updatedLastWeek, distinct, excludeOcTeam),
    ).map(row => row.CollectiveId),
github opencollective / opencollective-api / cron / weekly / platform-report.js View on Github external
merge({}, weekBeforeDonations, groupAndOrderBy('Transaction'), service('stripe')),
    ),

    manualDonationAmount: Transaction.aggregate(
      'amount',
      'SUM',
      merge({}, lastWeekDonations, groupAndOrderBy('Transaction'), service('opencollective')),
    ),

    priorManualDonationAmount: Transaction.aggregate(
      'amount',
      'SUM',
      merge({}, weekBeforeDonations, groupAndOrderBy('Transaction'), service('opencollective')),
    ),

    paypalReceivedCount: Activity.count(merge({}, createdLastWeek, paypalReceived)),

    paypalDonationAmount: Transaction.sum('amount', merge({}, lastWeekDonations, service('paypal'))),

    priorPaypalDonationAmount: Transaction.sum('amount', merge({}, weekBeforeDonations, service('paypal'))),

    // Expense statistics

    pendingExpenseCount: Expense.count(pendingLastWeekExpenses),

    approvedExpenseCount: Expense.count(approvedLastWeekExpenses),

    rejectedExpenseCount: Expense.count(rejectedLastWeekExpenses),

    paidExpenseCount: Expense.count(paidLastWeekExpenses),

    priorPaidExpenseCount: Expense.count(paidWeekBeforeExpenses),
github ipfs-shipyard / ipfs-companion / add-on / src / lib / ipfs-client / embedded-chromesockets.js View on Github external
async function buildConfig (opts) {
  const defaultOpts = JSON.parse(optionDefaults.ipfsNodeConfig)
  defaultOpts.libp2p = {
    config: {
      dht: {
        // TODO: check if below is needed after js-ipfs is released with DHT disabled
        enabled: false
      }
    }
  }
  const userOpts = JSON.parse(opts.ipfsNodeConfig)
  const ipfsNodeConfig = mergeOptions.call({ concatArrays: true }, defaultOpts, userOpts, { start: false })

  // Detect when API or Gateway port is not available (taken by something else)
  // We find the next free port and update configuration to use it instead
  const multiaddr2port = (ma) => parseInt(new URL(multiaddr2httpUrl(ma)).port, 10)
  const gatewayPort = multiaddr2port(ipfsNodeConfig.config.Addresses.Gateway)
  const apiPort = multiaddr2port(ipfsNodeConfig.config.Addresses.API)
  log(`checking if ports are available: api: ${apiPort}, gateway: ${gatewayPort}`)
  const freeGatewayPort = await getPort({ port: getPort.makeRange(gatewayPort, gatewayPort + 100) })
  const freeApiPort = await getPort({ port: getPort.makeRange(apiPort, apiPort + 100) })
  if (gatewayPort !== freeGatewayPort || apiPort !== freeApiPort) {
    log(`updating config to available ports: api: ${freeApiPort}, gateway: ${freeGatewayPort}`)
    const addrs = ipfsNodeConfig.config.Addresses
    addrs.Gateway = addrs.Gateway.replace(gatewayPort.toString(), freeGatewayPort.toString())
    addrs.API = addrs.API.replace(apiPort.toString(), freeApiPort.toString())
  }

merge-options

Merge Option Objects

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis