File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,19 @@ export const GlobalStats = () => {
77 return sum + ( product . stats . screens ?. total || 0 ) ;
88 } , 0 ) ;
99
10+ const medianScreensPerProduct = ( ( ) => {
11+ const screens = products
12+ . map ( product => product . stats . screens ?. total )
13+ . filter ( total => total !== undefined )
14+ . sort ( ( a , b ) => a - b ) ;
15+
16+ const mid = Math . floor ( screens . length / 2 ) ;
17+
18+ return screens . length % 2 === 0
19+ ? ( screens [ mid - 1 ] + screens [ mid ] ) / 2
20+ : screens [ mid ] ;
21+ } ) ( ) ;
22+
1023 return (
1124 < div className = "flex gap-10 items-center" >
1225 < div className = "flex gap-5 font-mono h-12 items-center" >
@@ -25,6 +38,14 @@ export const GlobalStats = () => {
2538 { screenCount . toLocaleString ( ) }
2639 </ div >
2740 </ div >
41+ < div className = "flex gap-5 font-mono h-12 items-center" >
42+ < div >
43+ Median Screens per Product
44+ </ div >
45+ < div >
46+ { medianScreensPerProduct . toLocaleString ( ) }
47+ </ div >
48+ </ div >
2849 </ div >
2950 )
3051}
You can’t perform that action at this time.
0 commit comments