MCPcopy Create free account
hub / github.com/facebook/Rapid / getSharedEntityIssues

Method getSharedEntityIssues

modules/core/ValidationSystem.js:407–434  ·  view source on GitHub ↗

* getSharedEntityIssues * Gets the issues that the given entityIDs have in common, matching the given options * (This just calls `getIssues`, then filters for the given entity IDs) * The issues are sorted for relevance * * @param {Array|Set} entityIDs - Array or Set of entityIDs to

(entityIDs, options)

Source from the content-addressed store, hash-verified

405 * @return {Array} An Array containing the issues
406 */
407 getSharedEntityIssues(entityIDs, options) {
408 const orderedIssueTypes = [ // Show some issue types in a particular order:
409 'missing_tag', 'missing_role', // - missing data first
410 'outdated_tags', 'mismatched_geometry', // - identity issues
411 'crossing_ways', 'almost_junction', // - geometry issues where fixing them might solve connectivity issues
412 'disconnected_way', 'impossible_oneway' // - finally connectivity issues
413 ];
414
415 const allIssues = this.getIssues(options);
416 const forEntityIDs = new Set(entityIDs);
417
418 return allIssues
419 .filter(issue => (issue.entityIds ?? []).some(entityID => forEntityIDs.has(entityID)))
420 .sort((issue1, issue2) => {
421 if (issue1.type === issue2.type) { // issues of the same type, sort deterministically
422 return issue1.id < issue2.id ? -1 : 1;
423 }
424 const index1 = orderedIssueTypes.indexOf(issue1.type);
425 const index2 = orderedIssueTypes.indexOf(issue2.type);
426 if (index1 !== -1 && index2 !== -1) { // both issue types have explicit sort orders
427 return index1 - index2;
428 } else if (index1 === -1 && index2 === -1) { // neither issue type has an explicit sort order, sort by type
429 return issue1.type < issue2.type ? -1 : 1;
430 } else { // order explicit types before everything else
431 return index1 !== -1 ? -1 : 1;
432 }
433 });
434 }
435
436
437 /**

Callers 2

getEntityIssuesMethod · 0.95
reloadIssuesFunction · 0.80

Calls 2

getIssuesMethod · 0.95
filterMethod · 0.80

Tested by

no test coverage detected