Skip to content

Commit 7ba9d23

Browse files
authored
Merge pull request #2039 from hackforla/2013-toggle-between-hf-socrata
2013 toggle between hf socrata
2 parents d2f46c2 + bd4592c commit 7ba9d23

File tree

6 files changed

+1297
-1220
lines changed

6 files changed

+1297
-1220
lines changed

.example.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ VITE_CONTACT_FORM=REDACTED
66
VITE_CONTENTFUL_SPACE=REDACTED
77
VITE_CONTENTFUL_TOKEN=REDACTED
88
VITE_MAPBOX_TOKEN=REDACTED
9+
VITE_DATA_SOURCE=HF # Options: HF, SOCRATA

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/layout/Footer/LastUpdated.jsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
Component to show the date of the last data update in the footer which assumes data is available in conn from DbContext,
3+
which is no longer a valid assumption if using Socrata or in new codebase structure
4+
*/
15
import React, { useContext, useEffect, useState } from 'react';
26
import moment from 'moment';
37
import Typography from '@mui/material/Typography';
@@ -6,6 +10,8 @@ import DbContext from '@db/DbContext';
610
import ddbh from '@utils/duckDbHelpers.js';
711
import { isEmpty, toNonBreakingSpaces } from '@utils';
812

13+
const DATA_SOURCE = import.meta.env.VITE_DATA_SOURCE;
14+
915
const useStyles = makeStyles(theme => ({
1016
lastUpdated: {
1117
fontWeight: theme.typography.fontWeightMedium,
@@ -19,30 +25,36 @@ function LastUpdated() {
1925
const [lastUpdated, setLastUpdated] = useState('');
2026
const { conn } = useContext(DbContext);
2127

28+
useEffect(() => {
29+
if (DATA_SOURCE === 'SOCRATA') {
30+
setLastUpdated(Date.now())
31+
}
32+
},[DATA_SOURCE])
33+
2234
useEffect(() => {
2335
const getLastUpdated = async () => {
2436
const getLastUpdatedSQL = 'select max(createddate) from requests_2025;';
25-
37+
2638
const lastUpdatedAsArrowTable = await conn.query(getLastUpdatedSQL);
2739
const results = ddbh.getTableData(lastUpdatedAsArrowTable);
28-
40+
2941
if (!isEmpty(results)) {
3042
const lastUpdatedValue = results[0];
3143
setLastUpdated(lastUpdatedValue);
3244
}
3345
};
34-
35-
getLastUpdated();
36-
}, [conn]);
46+
47+
if (DATA_SOURCE !== 'SOCRATA' && conn) {
48+
getLastUpdated();
49+
}
50+
}, [conn, DATA_SOURCE]);
3751

3852
return (
3953
lastUpdated && (
4054
<div>
4155
<Typography variant="body2" className={classes.lastUpdated}>
4256
{toNonBreakingSpaces(
43-
//* Quickfix - hard coded date last updated until 2025 data available
44-
// `Data last updated ${moment(lastUpdated).format('MM/DD/YY')}`
45-
`Data last updated 12/31/24`
57+
`Data last updated ${moment(lastUpdated).format('MM/DD/YY')}`
4658
)}
4759
</Typography>
4860
</div>

0 commit comments

Comments
 (0)