/* * Create a data source */ create(source, data = {}, sort = []) { let database = this.read(source); database.push(_.merge({}, data, {id: hasher(data)})); // Sort if we have to if (!_.isEmpty(sort)) database = _.orderBy(database, ...sort); // Dump results this.yaml.dump(path.resolve(this.base, `${source}.yml`), _.uniqBy(database, 'id')); return this.read(source, {id: hasher(data)}); }
/** * Get all endpoints for event * * @param {String} eventName * @param {Array<String>?} groupNames * @returns * @memberof EventCatalog */ getAllEndpoints(eventName, groupNames) { const res = []; this.events.forEach(list => { if (!utils.match(eventName, list.name)) return; if (groupNames == null || groupNames.length == 0 || groupNames.indexOf(list.group) !== -1) { list.endpoints.forEach(ep => { if (ep.isAvailable) res.push(ep); }); } }); return _.uniqBy(res, "id"); }
async create(createDraftDto: CreateDraftDto, userID: number) { const uniqCates = _.uniqBy(createDraftDto.categories, (c) => c.id); const categories: Category[] = uniqCates.map(cate => { const c = new Category(); return c; }); const uniqTags = _.uniqBy(createDraftDto.tags, (t) => t.id); const tags: Tag[] = uniqTags.map(t => { const tag = new Tag();
/* * Get list of sites */ getSites() { // Call to get user sites const pantheonUserSites = () => { const getSites = ['users', _.get(this.session, 'user_id'), 'memberships', 'sites']; return pantheonRequest(this.request, this.log, 'get', getSites, {params: {limit: MAX_SITES}}) .then(sites => _.map(sites, (site, id) => _.merge(site, site.site))); }; // Call to get org sites const pantheonOrgSites = () => { const getOrgs = ['users', _.get(this.session, 'user_id'), 'memberships', 'organizations']; return pantheonRequest(this.request, this.log, 'get', getOrgs) .map(org => { if (org.role !== 'unprivileged') { const getOrgsSites = ['organizations', org.id, 'memberships', 'sites']; return pantheonRequest(this.request, this.log, 'get', getOrgsSites, {params: {limit: MAX_SITES}}) .map(site => _.merge(site, site.site)); } }) .then(sites => _.flatten(sites)); }; // Run both requests return Promise.all([pantheonUserSites(), pantheonOrgSites()]) // Combine, cache and all the things .then(sites => _.compact(_.sortBy(_.uniqBy(_.flatten(sites), 'name'), 'name'))) // Filter out any BAAAAD BIZZZNIZZZ .filter(site => !site.frozen); }
list.data = _.map(_.uniqBy(list.data, function(item) { return item.goods_id; }), (item) => {
function addStar (name, star) { const categories = getCategory() const category = categories.find(category => category.name === name) if (category) { category.stars.push(...star) category.stars = _.uniqBy(category.stars, 'id') setCategory(categories) } }
includePP._arrayToTree(request, includes, filters, (attErr, includeTree) => { if (attErr) return callback(attErr) let dataItems = response.data if (!(Array.isArray(dataItems))) dataItems = [ dataItems ] includeTree._dataItems = dataItems includePP._fillIncludeTree(includeTree, request, fiErr => { if (fiErr) return callback(fiErr) includeTree._dataItems = [ ] response.included = includePP._getDataItemsFromTree(includeTree) response.included = _.uniqBy(response.included, someItem => `${someItem.type}~~${someItem.id}`) return callback() }) })
const findReviewersByState = (reviews, state) => { // filter out review submitted comments because it does not nullify an approved state. // Other possible states are PENDING and REQUEST_CHANGES. At those states the user has not approved the PR. // See https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request // While submitting a review requires the states be PENDING, REQUEST_CHANGES, COMMENT and APPROVE // The payload actually returns the state in past tense: i.e. APPROVED, COMMENTED const relevantReviews = reviews.filter(element => element.state.toLowerCase() !== 'commented') // order it by date of submission. The docs says the order is chronological but we sort it so that // uniqBy will extract the correct last submitted state for the user. const ordered = _.orderBy(relevantReviews, ['submitted_at'], ['desc']) const uniqueByUser = _.uniqBy(ordered, 'user.login') // approved reviewers are ones that are approved and not nullified by other submissions later. return uniqueByUser .filter(element => element.state.toLowerCase() === state) .map(review => review.user && review.user.login) }
_.uniqBy(operationParams.concat(pathParams), (param) => { return param.name + param.in; })
Board.find({}) .where('uuid').in(integratedBoardsUuids) .select('-__v') .exec(function(err, boards) { if (err) { next(err); } else if (boards.length > 0) { boards.forEach(function(board) { board.integratedComponents = _.concat(board.integratedComponents, integratedBoards[board.uuid]); board.integratedComponents = _.uniqBy(board.integratedComponents, 'uid'); board.save(next); }); } else { next(err); } });
const FunctionImportStatements = ({ exportedFunctions, packagedArguments }) => { const importedFunctions = Object.keys(exportedFunctions); // Functions in objects have names like obj.fun1, obj.fun2 const cleanImportedFunctions = _.uniqBy( importedFunctions.map(name => ({ identifier: name.split('.')[0], meta: exportedFunctions[name].meta, })), 'identifier', ); const importStatements = cleanImportedFunctions.map(({ identifier, meta }) => { const { isDefault, isEcmaDefault, importPath } = meta; const props = { identifier, importPath, packagedArguments }; if (isEcmaDefault) return EcmaDefaultImportStatement(props); if (isDefault) return DefaultImportStatement(props); return DestructureImportStatement(props); }); return importStatements.join('\n'); }
var torrent = {}; torrent.infohash = infohash; torrent.listIP = _.uniqBy(this.listIP, function (e) { return e.host + e.port })
}) let uniqBidder = _.uniqBy(removedThatBidder, 'userId')
function addStar (name, star) { const categories = getCategory() const category = categories.find(category => category.name === name) if (category) { category.stars.push(...star) category.stars = _.uniqBy(category.stars, 'id') setCategory(categories) } }
includePP._arrayToTree(request, includes, filters, (attErr, includeTree) => { if (attErr) return callback(attErr) let dataItems = response.data if (!(Array.isArray(dataItems))) dataItems = [ dataItems ] includeTree._dataItems = dataItems includePP._fillIncludeTree(includeTree, request, fiErr => { if (fiErr) return callback(fiErr) includeTree._dataItems = [ ] response.included = includePP._getDataItemsFromTree(includeTree) response.included = _.uniqBy(response.included, someItem => `${someItem.type}~~${someItem.id}`) return callback() }) })