You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			30 lines
		
	
	
		
			743 B
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			30 lines
		
	
	
		
			743 B
		
	
	
	
		
			TypeScript
		
	
| 
								 
											7 years ago
										 
									 | 
							
								// tslint:disable no-console
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import { join } from 'path';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import { fromPairs, groupBy, map } from 'lodash';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import { ExceptionType } from './types';
							 | 
						||
| 
								 | 
							
								import { loadJSON } from './util';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const exceptionsPath = join(__dirname, 'exceptions.json');
							 | 
						||
| 
								 | 
							
								const exceptions: Array<ExceptionType> = loadJSON(exceptionsPath);
							 | 
						||
| 
								 | 
							
								const byRule = groupBy(exceptions, 'rule');
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const byRuleThenByCategory = fromPairs(
							 | 
						||
| 
								 | 
							
								  map(byRule, (list, ruleName) => {
							 | 
						||
| 
								 | 
							
								    const byCategory = groupBy(list, 'reasonCategory');
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    return [
							 | 
						||
| 
								 | 
							
								      ruleName,
							 | 
						||
| 
								 | 
							
								      fromPairs(
							 | 
						||
| 
								 | 
							
								        map(byCategory, (innerList, categoryName) => {
							 | 
						||
| 
								 | 
							
								          return [categoryName, innerList.length];
							 | 
						||
| 
								 | 
							
								        })
							 | 
						||
| 
								 | 
							
								      ),
							 | 
						||
| 
								 | 
							
								    ];
							 | 
						||
| 
								 | 
							
								  })
							 | 
						||
| 
								 | 
							
								);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								console.log(JSON.stringify(byRuleThenByCategory, null, '  '));
							 |