File tree Expand file tree Collapse file tree 6 files changed +37
-16
lines changed Expand file tree Collapse file tree 6 files changed +37
-16
lines changed Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ export default {
15
15
transform : {
16
16
"^.+\\.(ts|tsx)$" : "ts-jest"
17
17
} ,
18
+ verbose : true ,
18
19
} ;
Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ describe("Database", () => {
16
16
database . put ( imgsArray ) ;
17
17
18
18
it ( "gets closest image" , ( ) => {
19
- let closestImg = database . closest ( { " sub" : "01" , " type" : "tsnr_rpt" } ) ;
19
+ let closestImg = database . closest ( { sub : "01" , type : "tsnr_rpt" } ) ;
20
20
expect ( closestImg . sub ) . toBe ( "01" ) ;
21
21
expect ( closestImg . type ) . toBe ( "skull_strip_report" ) ;
22
22
23
- closestImg = database . closest ( { " sub" : "03" , " type" : "tsnr_rpt" } ) ;
23
+ closestImg = database . closest ( { sub : "03" , type : "tsnr_rpt" } ) ;
24
24
expect ( closestImg . sub ) . toBe ( "01" ) ;
25
25
expect ( closestImg . type ) . toBe ( "skull_strip_report" ) ;
26
26
} ) ;
@@ -29,7 +29,10 @@ describe("Database", () => {
29
29
let [ exactImg ] = database . findAll ( { sub : "01" , type : "skull_strip_report" } ) ;
30
30
expect ( exactImg . hash ) . toBe ( "1" ) ;
31
31
32
- let result = database . findAll ( { sub : "03" } ) ;
32
+ let result = database . findAll ( { sub : "03" , type : "skull_strip_report" } ) ;
33
+ expect ( result . length ) . toBe ( 0 ) ;
34
+
35
+ result = database . findAll ( { sub : "03" } ) ;
33
36
expect ( result . length ) . toBe ( 0 ) ;
34
37
} ) ;
35
38
Original file line number Diff line number Diff line change @@ -46,23 +46,33 @@ export class Database {
46
46
for ( const key of basedOnEntities ) {
47
47
const value = obj [ key ] ;
48
48
49
- if ( value === null ) {
49
+ if ( value == null ) { // == catches both `null` and `undefined`
50
50
continue ;
51
51
}
52
- if ( ! ( value in this . indexSets [ key ] ) ) {
53
- continue ;
52
+ if ( ! ( value in this . indexSets [ key ] ) ) { // unknown value
53
+ if ( exact ) {
54
+ return null ;
55
+ } else {
56
+ continue ;
57
+ }
54
58
}
55
59
56
- let indexSet = this . indexSets [ key ] [ value ] ;
57
- if ( matches === null ) {
60
+ const indexSet = this . indexSets [ key ] [ value ] ;
61
+
62
+ if ( matches == null ) {
58
63
matches = indexSet ;
59
64
} else {
60
- indexSet = matches . intersection ( indexSet ) ;
61
- if ( ! exact && indexSet . length === 0 ) {
62
- break ;
65
+ const intersectionSet = matches . intersection ( indexSet ) ;
66
+
67
+ if ( intersectionSet . length === 0 ) {
68
+ if ( exact ) {
69
+ return null ;
70
+ } else {
71
+ break ; // return what we have
72
+ }
63
73
}
64
74
65
- matches = indexSet ;
75
+ matches = intersectionSet ;
66
76
}
67
77
}
68
78
Original file line number Diff line number Diff line change @@ -216,11 +216,15 @@ qc-explorer {
216
216
font-weight : 600 ;
217
217
font-size : 12.5px ;
218
218
}
219
+
219
220
img {
220
- object-fit : contain ;
221
221
width : 100% ;
222
222
height : 100% ;
223
+
223
224
background-color : white ;
225
+
226
+ object-fit : contain ;
227
+ image-rendering : crisp-edges ;
224
228
}
225
229
}
226
230
}
Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ qc-zoom {
18
18
img {
19
19
width : 100% ;
20
20
height : 100% ;
21
+
21
22
object-fit : cover ;
23
+ image-rendering : crisp-edges ;
22
24
}
23
25
}
24
26
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export class Sidebar extends HTMLElement {
36
36
const importButton = h (
37
37
"a" ,
38
38
[ new Attribute ( "class" , "dropdown-item" ) ] ,
39
- [ t ( "Import... " ) ]
39
+ [ t ( "Import" ) ]
40
40
) ;
41
41
const fileInput = h (
42
42
"input" ,
@@ -134,11 +134,12 @@ export class Sidebar extends HTMLElement {
134
134
const { rating } = obj ;
135
135
delete obj [ "rating" ] ;
136
136
137
- if ( rating == "none" ) {
137
+ if ( rating === "none" ) {
138
138
continue ;
139
139
}
140
140
141
- for ( const img of database . findAll ( obj ) ) {
141
+ const imgs = database . findAll ( obj ) ;
142
+ for ( const img of imgs ) {
142
143
viewModel . ratingsViewModel . set ( img . hash , rating ) ;
143
144
}
144
145
}
You can’t perform that action at this time.
0 commit comments