Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
authUser = null,
sort = 'desc', // asc || desc
search = null
} = {}) {
const query = {};
let dateDirection = -1;
if (createdAt) query.createdAt = { $lt: moment(createdAt).toDate() };
if (sort === 'asc') {
dateDirection = 1;
if (createdAt) query.createdAt = { $gt: moment(createdAt).toDate() };
}
if (search) {
const titleSearch = {};
const searchWords = search.split(' ').join('|');
titleSearch['title.rendered'] = {
$regex: new RegExp(`${searchWords}`, 'i')
};
// @TODO: Add this when content doesn't have so much extra data
// let contentSearch = {}
// contentSearch['content.rendered'] = { $regex: new RegExp(`${search}`, 'i') };
query.$or = [titleSearch];
}
const limitOption = parseInt(limit, 10);
const orderBy = { createdAt: dateDirection };
const queryPromise = this.find(query, 'title content author createdAt')
.populate('author', '-email -password -__v -verified')
.sort(orderBy)
.limit(limitOption);
let numberOfPages = 0; //eslint-disable-line
let dateDirection = -1;
if (createdAtBefore) query.date = { $lt: moment(createdAtBefore).toDate() };
if (createdAfter) {
dateDirection = 1;
query.date = { $gt: moment(createdAfter).toDate() };
}
if (tags.length > 0) query.tags = { $all: tags };
if (categories.length > 0) query.categories = { $all: categories };
if (topic) query.topics = { $in: topic };
if (search) {
const titleSearch = {};
const searchWords = search.split(' ').join('|');
titleSearch['title.rendered'] = {
$regex: new RegExp(`${searchWords}`, 'i')
};
// @TODO: Add this when content doesn't have so much extra data
// let contentSearch = {}
// contentSearch['content.rendered'] = { $regex: new RegExp(`${search}`, 'i') };
query.$or = [titleSearch];
}
if (transcripts === 'true') {
query.transcriptUrl = { $exists: true };
} else if (transcripts === 'false') {
query.transcriptUrl = { $exists: false };
}
const rows = swaps.map(swap => [
formatDate(swap.timeStarted, 'YYYY-MM-DD HH:mm:ss'), // The most Excel compatible datetime format
`${swap.baseCurrency}/${swap.quoteCurrency}`,
title(swap.orderType),
`${swap.baseCurrencyAmount} ${swap.baseCurrency}`,
`${swap.quoteCurrencyAmount} ${swap.quoteCurrency}`,
title(swap.statusFormatted),
getTXID(swap, 'myfee'),
getTXID(swap, 'alicepayment'),
getTXID(swap, 'alicespend'),
]);
const updateTouchBar = () => {
portfolioValue.label = `${appContainer.state.portfolio.name}: ${dashboardContainer.assetCount} ≈ ${dashboardContainer.totalAssetValueFormatted}`;
const swap = getLatestSwap();
latestSwap.label = swap ? `${swap.baseCurrency}/${swap.quoteCurrency} ${t(`details.${swap.orderType}`)} ${t('details.order')}: ${title(swap.statusFormatted)}` : '';
latestSwap.textColor = swap ? (
(swap.status === 'completed' && '#28af60' /* => var(--success-color) */) ||
(swap.status === 'failed' && '#f80759' /* => var(--error-color) */)
) : null;
};
const teams = Utils.find_value_with_path(aff, 'teams'.split('.')) || [];
if (!iname) {
aff.full = 'NC';
} else {
const teams_str = teams.map(t => `#POS#LANG${t._id}`).join('\n');
aff.full = `${iname}\n${teams_str}`;
}
aff.status = aff.ined_status ? `#POS#LANG${aff.ined_status}` : 'NC';
return aff;
});
}
const mapping = {
'denormalization.type.label': CSVPipeline.mapping['denormalization.type.label'],
subtype: CSVPipeline.mapping.subtype,
'title.content': CSVPipeline.mapping['title.content'],
subtitles: CSVPipeline.mapping.subtitles,
lang: CSVPipeline.mapping.lang,
'denormalization.journal': CSVPipeline.mapping['denormalization.journal'],
'denormalization.conference': CSVPipeline.mapping['denormalization.conference'],
'denormalization.contributors': {
__default: {
transformers: [],
picker: async (c, pub, lang, key, memoizer) => {
if (!('authors' in memoizer)) {
memoizer.authors = {};
}
const arr = [];
let idx = 0;
for (const i in c) {
const co = c[i];
if (!co || !co.label) {
const prepareState = state => title(state.replace('_', ' '));
let content = '';
if (sectionTitle === 'builds') {
content = (sectionContent as BuildResource[])
.map(prettyPrintBuilds)
.join(`\n\n`);
} else if (sectionTitle === 'environments') {
content = (sectionContent as EnvironmentResource[])
.map(prettyPrintEnvironment)
.join('\n\n');
} else if (sectionTitle === 'services') {
content = (sectionContent as ServiceResource[])
.map(prettyPrintServices)
.join('\n\n');
} else if (sectionTitle === 'variables') {
const data = sectionContent as VariablesContent;
sectionHeader = chalk`{cyan.bold ${title(
sectionTitle
)}} {dim for environment ${data.environmentSid}}`;
content = prettyPrintVariables(data);
} else if (sectionTitle === 'functions' || sectionTitle === 'assets') {
const data = sectionContent as FunctionOrAssetContent;
sectionHeader = chalk`{cyan.bold ${title(
sectionTitle
)}} {dim for environment ${data.environmentSid}}`;
content = prettyPrintFunctionsOrAssets(data);
}
const output = stripIndent`
${sectionHeader}\n\n${content}\n\n\n
`;
return output;
}
const { value } = event.target
const input = this.handler.input
const idx = input.selectionStart
const { replacingWithPaste } = this.state
const caretPosition = () => {
if (replacingWithPaste) {
input.selectionStart = 0
input.selectionEnd = input.value.length
} else {
input.selectionStart = input.selectionEnd = idx
}
}
this.setState({
replacingWithPaste: false,
value: toTitle(value)
}, caretPosition)
event.preventDefault()
}
`Do you mean ${code('build')} (object) with a property ${code(
'env'
)} (object) instead of ${code(prop)}?`
);
}
return 1;
}
if (keyword === 'type') {
const prop = dataPath.substr(1, dataPath.length);
output.error(
`The property ${code(prop)} in ${highlight(
'now.json'
)} can only be of type ${code(title(params.type))}.`
);
return 1;
}
output.error(
`Failed to validate ${highlight(
'now.json'
)}: ${message}\nDocumentation: ${
link('https://zeit.co/docs/v2/advanced/configuration')
}`
);
return 1;
}
if (error instanceof TooManyRequests) {
render() {
const {
children,
title = 'The Gluten Project',
description,
router,
searchState,
searchResults,
} = this.props
const htmlTitle = searchState.query
? `${searchResults && searchResults.nbHits} Certified Gluten-Free ${titleize(
searchState.query
)} (safe for Celiac) | The Gluten Project`
: title
const htmlDescription = searchState.query
? `We've compiled the entire list of all certified gluten-free ${
searchState.query
} products in one place. Additionally, we have where to buy the product, ingredient lists, and reviews. This is your one-stop shop for everything gluten-free.`
: description
const socialTitle = htmlTitle.replace(/ \| The Gluten Project$/, '')
return (