-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6021 from hotosm/enhancement/5999-ohsomeNow-stats
Restructured API endpoints for ohsomeNow stats
- Loading branch information
Showing
31 changed files
with
2,043 additions
and
1,966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import ReactTooltip from 'react-tooltip'; | ||
|
||
import { fetchExternalJSONAPI } from '../../network/genericJSONRequest'; | ||
import { OHSOME_STATS_BASE_URL } from '../../config'; | ||
import { InfoIcon } from '../svgIcons'; | ||
import messages from './messages'; | ||
|
||
function StatsTimestamp({ messageType }) { | ||
const intl = useIntl(); | ||
const [lastUpdated, setLastUpdated] = useState(null); | ||
|
||
useEffect(() => { | ||
fetchExternalJSONAPI(`${OHSOME_STATS_BASE_URL}/metadata`) | ||
.then((res) => { | ||
setLastUpdated(res.result.max_timestamp); | ||
}) | ||
.catch((error) => console.error(error)); | ||
}, []); | ||
|
||
const dateOptions = { | ||
year: 'numeric', | ||
month: 'short', | ||
day: '2-digit', | ||
hour: 'numeric', | ||
minute: 'numeric', | ||
}; | ||
|
||
return ( | ||
<div> | ||
<InfoIcon | ||
className="blue-grey h1 w1 v-mid ml2 pointer" | ||
data-tip={intl.formatMessage(messages[messageType], { | ||
formattedDate: intl.formatDate(lastUpdated, dateOptions), | ||
timeZone: intl.timeZone, | ||
})} | ||
data-for="ohsome-timestamp" | ||
/> | ||
<ReactTooltip id="ohsome-timestamp" place="top" className="mw6" effect="solid" /> | ||
</div> | ||
); | ||
} | ||
|
||
export default StatsTimestamp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineMessages } from 'react-intl'; | ||
|
||
export default defineMessages({ | ||
generic: { | ||
id: 'stats.ohsome.timestamp.generic', | ||
defaultMessage: | ||
'These statistics come from ohsomeNow Stats and were last updated at {formattedDate} ({timeZone}). Missing fields will be made available soon!', | ||
}, | ||
project: { | ||
id: 'stats.ohsome.timestamp.project', | ||
defaultMessage: | ||
'These stats were retrieved using the default changeset comment of the project and were last updated at {formattedDate} ({timeZone}).', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.