File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ScoreElement } from "../../types" ;
2
+ import { CHECKS_LIST_NAMES } from "../../constants/checks" ;
3
+
4
+ export const getRefinedChecks = (
5
+ from : ScoreElement [ ] = [ ] ,
6
+ to : ScoreElement [ ] = [ ] ,
7
+ ) => {
8
+ const haveMaxChecksNumber =
9
+ from . length === CHECKS_LIST_NAMES . length &&
10
+ to . length === CHECKS_LIST_NAMES . length ;
11
+
12
+ if ( haveMaxChecksNumber ) {
13
+ return {
14
+ common : CHECKS_LIST_NAMES ,
15
+ discrepancies : [ ] ,
16
+ } ;
17
+ }
18
+
19
+ const fromNames = from . map ( ( el : ScoreElement ) => el . name ) ;
20
+ const toNames = to . map ( ( el : ScoreElement ) => el . name ) ;
21
+ const allNames = new Set ( [ ...fromNames , ...toNames ] ) ;
22
+ const common = [ ] ;
23
+ const discrepancies = [ ] ;
24
+
25
+ for ( const name of allNames ) {
26
+ if ( fromNames . includes ( name ) && toNames . includes ( name ) ) {
27
+ common . push ( name ) ;
28
+ } else {
29
+ discrepancies . push ( name ) ;
30
+ }
31
+ }
32
+
33
+ return {
34
+ common : common . sort ( ) ,
35
+ discrepancies : discrepancies . sort ( ) ,
36
+ } ;
37
+ } ;
You can’t perform that action at this time.
0 commit comments