@@ -17,10 +17,20 @@ import descriptionsData from '../data/descriptions.json';
1717
1818const { primaryPurple600, gray500, white } = vars ;
1919
20+ const formatDate = ( dateStr : string ) : string => {
21+ const date = new Date ( dateStr + 'T00:00:00' ) ;
22+ return date . toLocaleDateString ( 'en-US' , {
23+ year : 'numeric' ,
24+ month : 'short' ,
25+ day : 'numeric' ,
26+ } ) ;
27+ } ;
28+
2029const SummaryPage = ( ) => {
2130 const [ data , setData ] = useState < { [ x : string ] : null } > ( { } ) ;
2231 const [ loaded , setLoaded ] = useState ( false ) ;
2332 const [ value , setValue ] = useState ( 0 ) ;
33+ const [ lastUpdated , setLastUpdated ] = useState < string > ( '' ) ;
2434
2535 // @ts -expect-error Explanation: Handling Event properly
2636 const handleChange = ( event : React . SyntheticEvent , newValue : number ) => {
@@ -50,7 +60,14 @@ const SummaryPage = () => {
5060 [ FILES . CATEGORY ] : null ,
5161 } ;
5262
53- for ( const file in FILES ) {
63+ const statFiles = [
64+ FILES . POPULATION ,
65+ FILES . PHENOTYPE ,
66+ FILES . SPECIES ,
67+ FILES . CATEGORY ,
68+ ] ;
69+
70+ for ( const file of statFiles ) {
5471 const request = new XMLHttpRequest ( ) ;
5572 request . open (
5673 'GET' ,
@@ -63,7 +80,7 @@ const SummaryPage = () => {
6380 }
6481 }
6582
66- for ( const file in FILES ) {
83+ for ( const file of statFiles ) {
6784 const request = new XMLHttpRequest ( ) ;
6885 request . open (
6986 'GET' ,
@@ -196,20 +213,40 @@ const SummaryPage = () => {
196213 }
197214 } ) ;
198215
216+ // Fetch version info for "last updated" date
217+ const versionRequest = new XMLHttpRequest ( ) ;
218+ versionRequest . open (
219+ 'GET' ,
220+ SCKAN_DATABASE_SUMMARY_URL_LATEST + DATABASE_FILES [ FILES . INFO ] ,
221+ false ,
222+ ) ;
223+ versionRequest . send ( null ) ;
224+ if ( versionRequest . status === 200 ) {
225+ const versionData = JSON . parse ( versionRequest . responseText ) ;
226+ const dateValue =
227+ versionData ?. results ?. bindings ?. [ 0 ] ?. sckan_version ?. value ;
228+ if ( dateValue ) {
229+ setLastUpdated ( formatDate ( dateValue ) ) ;
230+ }
231+ }
232+
199233 setLoaded ( true ) ;
200234 setData ( results ) ;
201235 } , [ ] ) ;
202236
203237 const getDataPerSection = ( section : any ) => {
204238 let total = 0 ;
239+ let totalChange = 0 ;
205240 const results = section . map ( ( item : any ) => {
206241 total += Number ( item . count ) ;
242+ totalChange += Number ( item . change || 0 ) ;
207243 return (
208244 < Detail
209245 keyName = { item . label }
210246 value = { item . count }
211247 labels = { item . label }
212248 index = { Math . random ( ) }
249+ change = { Number ( item . change ) }
213250 />
214251 ) ;
215252 } ) ;
@@ -219,6 +256,7 @@ const SummaryPage = () => {
219256 value = { total }
220257 labels = "Total"
221258 index = { Math . random ( ) }
259+ change = { totalChange }
222260 /> ,
223261 ) ;
224262 return results ;
@@ -278,9 +316,11 @@ const SummaryPage = () => {
278316 >
279317 Database summary
280318 </ Typography >
281- < Typography variant = "body1" color = { gray500 } >
282- Last updated on Apr 24, 2025
283- </ Typography >
319+ { lastUpdated && (
320+ < Typography variant = "body1" color = { gray500 } >
321+ Last updated on { lastUpdated }
322+ </ Typography >
323+ ) }
284324 </ Stack >
285325 < Box
286326 sx = { {
0 commit comments